Sha256: a5337a655d3c5e17b80e7716ce6574b5c3270a0c65fcce68de4ebba05561f3c2

Contents?: true

Size: 757 Bytes

Versions: 2

Compression:

Stored size: 757 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 AlignArray < Cop
        include AutocorrectAlignment

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.49.1 lib/rubocop/cop/layout/align_array.rb
rubocop-0.49.0 lib/rubocop/cop/layout/align_array.rb