Sha256: f4aebb0190fa1d8fd1da005a54927fcf7fa3ea1116405cf914fd5cdbbd4ca224

Contents?: true

Size: 863 Bytes

Versions: 9

Compression:

Stored size: 863 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Layout
      # Here we check if the elements of a multi-line array literal are
      # aligned.
      #
      # @example
      #   # bad
      #   a = [1, 2, 3,
      #     4, 5, 6]
      #   array = ['run',
      #        'forrest',
      #        'run']
      #
      #   # good
      #   a = [1, 2, 3,
      #        4, 5, 6]
      #   a = ['run',
      #        'forrest',
      #        'run']
      class ArrayAlignment < Cop
        include Alignment

        MSG = 'Align the elements of an array literal if they span more ' \
              'than one line.'

        def on_array(node)
          check_alignment(node.children)
        end

        def autocorrect(node)
          AlignmentCorrector.correct(processed_source, node, column_delta)
        end
      end
    end
  end
end

Version data entries

9 entries across 8 versions & 3 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/cop/layout/array_alignment.rb
rubocop-0.80.1 lib/rubocop/cop/layout/array_alignment.rb
rubocop-0.80.0 lib/rubocop/cop/layout/array_alignment.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/cop/layout/array_alignment.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/rubocop-0.79.0/lib/rubocop/cop/layout/array_alignment.rb
rubocop-0.79.0 lib/rubocop/cop/layout/array_alignment.rb
rubocop-0.78.0 lib/rubocop/cop/layout/array_alignment.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.77.0/lib/rubocop/cop/layout/array_alignment.rb
rubocop-0.77.0 lib/rubocop/cop/layout/array_alignment.rb