Sha256: 65fb535c115e90e4ffe107350c690a8d251315f7884a53c625161804d6385c05

Contents?: true

Size: 468 Bytes

Versions: 4

Compression:

Stored size: 468 Bytes

Contents

# encoding: utf-8

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

      def on_int(node)
        value, = *node

        if value > 10000 &&
            node.loc.expression.source.split('.').grep(/\d{6}/).any?
          add_offence(:convention, node.loc.expression.line, MSG)
        end
      end

      alias_method :on_float, :on_int
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.8.3 lib/rubocop/cop/numeric_literals.rb
rubocop-0.8.2 lib/rubocop/cop/numeric_literals.rb
rubocop-0.8.1 lib/rubocop/cop/numeric_literals.rb
rubocop-0.8.0 lib/rubocop/cop/numeric_literals.rb