Sha256: 214540d7663e8f98d1070a8d8e469dec3b3b0c70f0947d22ee7b04caff296cbd
Contents?: true
Size: 908 Bytes
Versions: 2
Compression:
Stored size: 908 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop module Layout # This hint checks for a line break before the first element in a # multi-line hash. # # @example # # # bad # { a: 1, # b: 2} # # # good # { # a: 1, # b: 2 } class FirstHashElementLineBreak < Cop include FirstElementLineBreak MSG = 'Add a line break before the first element of a ' \ 'multi-line hash.' def on_hash(node) # node.loc.begin tells us whether the hash opens with a { # If it doesn't, Style/FirstMethodArgumentLineBreak will handle it check_children_line_break(node, node.children) if node.loc.begin end def autocorrect(node) EmptyLineCorrector.insert_before(node) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rbhint-0.87.1.rc1 | lib/rubocop/cop/layout/first_hash_element_line_break.rb |
rbhint-0.85.1.rc2 | lib/rubocop/cop/layout/first_hash_element_line_break.rb |