Class: Rubocop::Cop::Style::SpaceAfterColon
- Includes:
- SpaceAfterCommaEtc
- Defined in:
- lib/rubocop/cop/style/space_after_comma_etc.rb
Overview
Checks for colon (:) not follwed by some kind of space.
Constant Summary
Constants included from SpaceAfterCommaEtc
Rubocop::Cop::Style::SpaceAfterCommaEtc::MSG
Constants inherited from Cop
Constants included from Util
Instance Attribute Summary
Attributes inherited from Cop
#config, #corrections, #offences, #processed_source
Instance Method Summary collapse
- #kind(token) ⇒ Object
-
#offset(token) ⇒ Object
The colon following a label will not appear in the token array.
Methods included from SpaceAfterCommaEtc
Methods inherited from Cop
#add_offence, all, #autocorrect?, #config_to_allow_offences, #config_to_allow_offences=, #cop_config, cop_name, #cop_name, cop_type, #debug?, #exclude_file?, #exclude_paths, #ignore_node, #include_file?, #include_paths, inherited, #initialize, lint?, #message, non_rails, rails?, #relevant_file?, style?, #support_autocorrect?
Methods included from Util
block_length, command?, comment_line?, const_name, first_part_of_call_chain, lambda?, lambda_or_proc?, line_range, on_node, proc?, range_with_surrounding_space, source_range, strip_quotes
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#kind(token) ⇒ Object
65 66 67 68 69 |
# File 'lib/rubocop/cop/style/space_after_comma_etc.rb', line 65 def kind(token) case token.type when :tLABEL, :tCOLON then 'colon' end end |
#offset(token) ⇒ Object
The colon following a label will not appear in the token array. Instad we get a tLABEL token, whose length we use to calculate where we expect a space.
58 59 60 61 62 63 |
# File 'lib/rubocop/cop/style/space_after_comma_etc.rb', line 58 def offset(token) case token.type when :tLABEL then token.text.length + 1 when :tCOLON then 1 end end |