class RuboCop::Cop::Layout::FirstHashElementLineBreak
}}
c: 3
{ a: 1, b: {
# good
}}
c: 3
b: {
{ a: 1,
# bad
@example AllowMultilineFinalElement: true
}}
c: 3
{ a: 1, b: {
# bad
@example AllowMultilineFinalElement: false (default)
}}
c: 3
a: 1, b: {
{
# good
b: 2 }
a: 1,
{
# good
b: 2}
{ a: 1,
# bad
@example
multi-line hash.
Checks for a line break before the first element in a
def ignore_last_element?
def ignore_last_element? !!cop_config['AllowMultilineFinalElement'] end
def on_hash(node)
def on_hash(node) # node.loc.begin tells us whether the hash opens with a { # If it doesn't, Style/FirstMethodArgumentLineBreak will handle it return unless node.loc.begin check_children_line_break(node, node.children, ignore_last: ignore_last_element?) end