Class: Rubocop::Cop::SpaceAroundBraces

Inherits:
Cop
  • Object
show all
Includes:
SurroundingSpace
Defined in:
lib/rubocop/cop/surrounding_space.rb

Instance Attribute Summary

Attributes inherited from Cop

#correlations, #offences

Instance Method Summary collapse

Methods included from SurroundingSpace

#inspect

Methods inherited from Cop

#add_offence, #has_report?, inherited, #initialize

Constructor Details

This class inherits a constructor from Rubocop::Cop::Cop

Instance Method Details

#check_missing_space(tokens, ix, grammar_path) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rubocop/cop/surrounding_space.rb', line 68

def check_missing_space(tokens, ix, grammar_path)
  t = tokens[ix]
  case t.type
  when :on_lbrace
    unless surrounded_by_whitespace?(tokens[ix - 1, 3])
      add_offence(:convention, t.pos.lineno,
                  "Surrounding space missing for '{'.")
    end
  when :on_rbrace
    unless whitespace?(tokens[ix - 1])
      add_offence(:convention, t.pos.lineno,
                  "Space missing to the left of '}'.")
    end
  end
end

#check_unwanted_space(tokens, ix) ⇒ Object



65
66
# File 'lib/rubocop/cop/surrounding_space.rb', line 65

def check_unwanted_space(tokens, ix)
end