Class: Rubocop::Cop::LineLength
- Defined in:
- lib/rubocop/cop/line_length.rb
Constant Summary collapse
- MSG =
'Line is too long. [%d/%d]'
Instance Attribute Summary
Attributes inherited from Cop
#debug, #disabled_lines, #offences
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, cop_name, #has_report?, #ignore_node, inherited, #initialize, #name, #on_comment
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Class Method Details
.max ⇒ Object
18 19 20 |
# File 'lib/rubocop/cop/line_length.rb', line 18 def self.max LineLength.config['Max'] end |
Instance Method Details
#inspect(source, tokens, ast, comments) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/rubocop/cop/line_length.rb', line 8 def inspect(source, tokens, ast, comments) source.each_with_index do |line, index| max = LineLength.max if line.length > max = sprintf(MSG, line.length, max) add_offence(:convention, index + 1, ) end end end |