Sha256: f4ca89b46e6201e3da2b0efc7387fe7304255ed5ce250bee8d47b0a0c03fb0cd

Contents?: true

Size: 1.07 KB

Versions: 13

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # This cop checks the indentation of the first line of the
      # right-hand-side of a multi-line assignment.
      #
      # @example
      #   # bad
      #   value =
      #   if foo
      #     'bar'
      #   end
      #
      #   # good
      #   value =
      #     if foo
      #     'bar'
      #   end
      #
      # The indentation of the remaining lines can be corrected with
      # other cops such as `IndentationConsistency` and `EndAlignment`.
      class IndentAssignment < Cop
        include CheckAssignment
        include AutocorrectAlignment

        MSG = 'Indent the first line of the right-hand-side of a ' \
              'multi-line assignment.'.freeze

        def check_assignment(node, rhs)
          return unless rhs
          return unless node.loc.operator
          return if node.loc.operator.line == rhs.loc.line

          base = display_column(node.source_range)
          check_alignment([rhs], base + configured_indentation_width)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/cop/style/indent_assignment.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/cop/style/indent_assignment.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/style/indent_assignment.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/style/indent_assignment.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/style/indent_assignment.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/style/indent_assignment.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/style/indent_assignment.rb
rubocop-0.47.1 lib/rubocop/cop/style/indent_assignment.rb
rubocop-0.47.0 lib/rubocop/cop/style/indent_assignment.rb
rubocop-0.46.0 lib/rubocop/cop/style/indent_assignment.rb
rubocop-0.45.0 lib/rubocop/cop/style/indent_assignment.rb
rubocop-0.44.1 lib/rubocop/cop/style/indent_assignment.rb
rubocop-0.44.0 lib/rubocop/cop/style/indent_assignment.rb