Sha256: 118f2c5d5b4f787a5c0e7045cc8c8a2252c4648631fb8c5fb30dcf52c6eba772

Contents?: true

Size: 769 Bytes

Versions: 5

Compression:

Stored size: 769 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Layout
      # This cop ensures that each item in a multi-line array
      # starts on a separate line.
      #
      # @example
      #
      #   # bad
      #   [
      #     a, b,
      #     c
      #   ]
      #
      #   # good
      #   [
      #     a,
      #     b,
      #     c
      #   ]
      class MultilineArrayLineBreaks < Cop
        include MultilineElementLineBreaks

        MSG = 'Each item in a multi-line array must start ' \
          'on a separate line.'.freeze

        def on_array(node)
          check_line_breaks(node, node.children)
        end

        def autocorrect(node)
          EmptyLineCorrector.insert_before(node)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.68.1 lib/rubocop/cop/layout/multiline_array_line_breaks.rb
rubocop-0.68.0 lib/rubocop/cop/layout/multiline_array_line_breaks.rb
rubocop-0.67.2 lib/rubocop/cop/layout/multiline_array_line_breaks.rb
rubocop-0.67.1 lib/rubocop/cop/layout/multiline_array_line_breaks.rb
rubocop-0.67.0 lib/rubocop/cop/layout/multiline_array_line_breaks.rb