Sha256: afaae6e3631c8c491dc9a919f4206417950ae8c015fb9868d88c087eeb2df1b3

Contents?: true

Size: 487 Bytes

Versions: 18

Compression:

Stored size: 487 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    class NumericLiterals < Cop
      ERROR_MESSAGE = 'Add underscores to large numeric literals to ' +
        'improve their readability.'

      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
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rubocop-0.7.2 lib/rubocop/cop/numeric_literals.rb
rubocop-0.7.1 lib/rubocop/cop/numeric_literals.rb
rubocop-0.7.0 lib/rubocop/cop/numeric_literals.rb
rubocop-0.6.1 lib/rubocop/cop/numeric_literals.rb
rubocop-0.6.0 lib/rubocop/cop/numeric_literals.rb
rubocop-0.5.0 lib/rubocop/cop/numeric_literals.rb
rubocop-0.4.6 lib/rubocop/cop/numeric_literals.rb
rubocop-0.4.5 lib/rubocop/cop/numeric_literals.rb
rubocop-0.4.4 lib/rubocop/cop/numeric_literals.rb
rubocop-0.4.3 lib/rubocop/cop/numeric_literals.rb
rubocop-0.4.2 lib/rubocop/cop/numeric_literals.rb
rubocop-0.4.1 lib/rubocop/cop/numeric_literals.rb
rubocop-0.4.0 lib/rubocop/cop/numeric_literals.rb
rubocop-0.3.2 lib/rubocop/cop/numeric_literals.rb
rubocop-0.3.1 lib/rubocop/cop/numeric_literals.rb
rubocop-0.3.0 lib/rubocop/cop/numeric_literals.rb
rubocop-0.2.1 lib/rubocop/cop/numeric_literals.rb
rubocop-0.2.0 lib/rubocop/cop/numeric_literals.rb