Sha256: 8664f2770dad8540548e1aaf34d658c540fac061641e39b9454cee151f0ca7ba

Contents?: true

Size: 873 Bytes

Versions: 5

Compression:

Stored size: 873 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # Here we check if the parameters on a multi-line method call are
      # aligned.
      class AlignParameters < Cop
        include AutocorrectAlignment

        MSG = 'Align the parameters of a method call if they span ' \
              'more than one line.'

        def on_send(node)
          _receiver, method, *args = *node

          return if method == :[]=
          return if args.size <= 1

          check_alignment(args, base_column(node, args))
        end

        private

        def fixed_indentation?
          cop_config['EnforcedStyle'] == 'with_fixed_indentation'
        end

        def base_column(node, args)
          if fixed_indentation?
            node.loc.column + 2
          else
            args.first.loc.column
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.21.0 lib/rubocop/cop/style/align_parameters.rb
rubocop-0.20.1 lib/rubocop/cop/style/align_parameters.rb
rubocop-0.20.0 lib/rubocop/cop/style/align_parameters.rb
rubocop-0.19.1 lib/rubocop/cop/style/align_parameters.rb
rubocop-0.19.0 lib/rubocop/cop/style/align_parameters.rb