Class: Rubocop::Cop::NumericLiterals
- Defined in:
- lib/rubocop/cop/numeric_literals.rb
Constant Summary collapse
- ERROR_MESSAGE =
'Add underscores to large numeric literals to ' + 'improve their readability.'
Instance Attribute Summary
Attributes inherited from Cop
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, #has_report?, inherited, #initialize
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#inspect(file, source, tokens, sexp) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/rubocop/cop/numeric_literals.rb', line 9 def inspect(file, source, tokens, sexp) tokens.each do |t| if [:on_int, :on_float].include?(t.type) && t.text.split('.').grep(/\d{6}/).any? add_offence(:convention, t.pos.lineno, ERROR_MESSAGE) end end end |