Sha256: 5dad688835f3a6f25d69195b0fc64193af19280f79271f1e421e20f324a08e28

Contents?: true

Size: 690 Bytes

Versions: 4

Compression:

Stored size: 690 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Lint
      # Identifies Float literals which are, like, really really really
      # really really really really really big. Too big. No-one needs Floats
      # that big. If you need a float that big, something is wrong with you.
      #
      # @example
      #
      #   # bad
      #   float = 3.0e400
      #
      #   # good
      #   float = 42.9
      class FloatOutOfRange < Base
        MSG = 'Float out of range.'

        def on_float(node)
          return unless node.value.infinite? || (node.value.zero? && /[1-9]/.match?(node.source))

          add_offense(node)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-1.70.0 lib/rubocop/cop/lint/float_out_of_range.rb
rubocop-1.69.2 lib/rubocop/cop/lint/float_out_of_range.rb
rubocop-1.69.1 lib/rubocop/cop/lint/float_out_of_range.rb
rubocop-1.69.0 lib/rubocop/cop/lint/float_out_of_range.rb