class RuboCop::Cop::Layout::MultilineHashKeyLineBreaks
This cop ensures that each key in a multi-line hash starts on a separate line.
@example
# bad { a: 1, b: 2, c: 3 } # good { a: 1, b: 2, c: 3 }
Constants
- MSG
Public Instance Methods
autocorrect(node)
click to toggle source
# File lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb, line 38 def autocorrect(node) EmptyLineCorrector.insert_before(node) end
on_hash(node)
click to toggle source
# File lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb, line 29 def on_hash(node) # This cop only deals with hashes wrapped by a set of curly # braces like {foo: 1}. That is, not a kwargs hashes. # Style/MultilineMethodArgumentLineBreaks handles those. return unless starts_with_curly_brace?(node) check_line_breaks(node, node.children) if node.loc.begin end
Private Instance Methods
starts_with_curly_brace?(node)
click to toggle source
# File lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb, line 44 def starts_with_curly_brace?(node) node.loc.begin end