Module: RuboCop::Cop::InDeltaMixin Private

Included in:
Minitest::AssertInDelta, Minitest::RefuteInDelta
Defined in:
lib/rubocop/cop/mixin/in_delta_mixin.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Common functionality for ‘AssertInDelta` and `RefuteInDelta` cops.

Constant Summary collapse

MSG =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'Prefer using `%<good_method>s`.'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rubocop/cop/mixin/in_delta_mixin.rb', line 10

def on_send(node)
  equal_floats_call(node) do |expected, actual, message|
    message = message.first
    good_method = build_good_method(expected, actual, message)

    if expected.float_type? || actual.float_type?
      message = format(MSG, good_method: good_method)

      add_offense(node, message: message) do |corrector|
        corrector.replace(node, good_method)
      end
    end
  end
end