Sha256: dbf1dc425efd823f04a049cff4beef73ff4c3ed52d6ceb58d31edd8130dbaa35

Contents?: true

Size: 742 Bytes

Versions: 14

Compression:

Stored size: 742 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Minitest
      # This cop enforces the test to use `refute_in_delta`
      # instead of using `refute_equal` to compare floats.
      #
      # @example
      #   # bad
      #   refute_equal(0.2, actual)
      #   refute_equal(0.2, actual, 'message')
      #
      #   # good
      #   refute_in_delta(0.2, actual)
      #   refute_in_delta(0.2, actual, 0.001, 'message')
      #
      class RefuteInDelta < Base
        include InDeltaMixin
        extend AutoCorrector

        RESTRICT_ON_SEND = %i[refute_equal].freeze

        def_node_matcher :equal_floats_call, <<~PATTERN
          (send nil? :refute_equal $_ $_ $...)
        PATTERN
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rubocop-minitest-0.19.1 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.19.0 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.18.0 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.17.2 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.17.1 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.17.0 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.16.0 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.15.2 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.15.1 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.15.0 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.14.0 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.13.0 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.12.1 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.12.0 lib/rubocop/cop/minitest/refute_in_delta.rb