This cops checks the indentation of the first key in a hash literal where the opening brace and the first key are on separate lines. The other keys' indentations are handled by the AlignHash cop.
Hash literals that are arguments in a method call with parentheses, and where the opening curly brace of the hash is on the same line as the opening parenthesis of the method call, shall have their first key indented one step (two spaces) more than the position inside the opening parenthesis.
Other hash literals shall have their first key indented one step more than the start of the line where the opening curly brace is.
# File lib/rubocop/cop/style/indent_hash.rb, line 21 def on_hash(node) left_brace = node.loc.begin check(node, left_brace, nil) if left_brace end
# File lib/rubocop/cop/style/indent_hash.rb, line 26 def on_send(node) _receiver, _method_name, *args = *node left_parenthesis = node.loc.begin return unless left_parenthesis args.each do |arg| on_node(:hash, arg, :send) do |hash_node| left_brace = hash_node.loc.begin if left_brace && left_brace.line == left_parenthesis.line check(hash_node, left_brace, left_parenthesis) ignore_node(hash_node) end end end end
Generated with the Darkfish Rdoc Generator 2.