Parent

Methods

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Style::SpaceInsideBlockBraces

Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

Public Instance Methods

on_block(node) click to toggle source
# File lib/rubocop/cop/style/space_inside_block_braces.rb, line 13
def on_block(node)
  return if node.loc.begin.is?('do') # No braces.

  # If braces are on separate lines, and the Blocks cop is enabled,
  # those braces will be changed to do..end by the user or by
  # auto-correct, so reporting space issues is not useful, and it
  # creates auto-correct conflicts.
  if config.for_cop('Style/Blocks')['Enabled'] &&
      Util.block_length(node) > 0
    return
  end

  left_brace, right_brace = node.loc.begin, node.loc.end

  check_inside(node, left_brace, right_brace)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.