Class: Rubocop::Cop::Style::SpaceBeforeModifierKeyword
- Defined in:
- lib/rubocop/cop/style/space_before_modifier_keyword.rb
Overview
Here we check if modifier keywords are preceded by a space.
Constant Summary collapse
- MSG =
'Put a space before the modifier keyword.'
Constants inherited from Cop
Instance Attribute Summary
Attributes inherited from Cop
#config, #corrections, #offences, #processed_source
Instance Method Summary collapse
- #on_if(node) ⇒ Object (also: #on_while, #on_until)
Methods inherited from Cop
#add_offence, all, #autocorrect?, #autocorrect_action, #convention, #cop_config, #cop_name, cop_name, cop_type, #debug?, #ignore_node, inherited, #initialize, lint?, #message, rails?, style?, #warning
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#on_if(node) ⇒ Object Also known as: on_while, on_until
10 11 12 13 14 15 16 17 |
# File 'lib/rubocop/cop/style/space_before_modifier_keyword.rb', line 10 def on_if(node) if modifier?(node) kw = node.loc.keyword b = kw.begin_pos left_of_kw = Parser::Source::Range.new(kw.source_buffer, b - 1, b) convention(node, left_of_kw) unless left_of_kw.is?(' ') end end |