From 2a00c89a7d2789002a55d3c8f0dd3bfc58b20d17 Mon Sep 17 00:00:00 2001 From: Nikita Vasilevsky Date: Mon, 15 Nov 2021 13:51:28 -0500 Subject: [PATCH] Enable Lint/DuplicateMethods rubocop rule --- .rubocop.yml | 3 +++ actionpack/test/controller/routing_test.rb | 2 -- .../lib/active_support/core_ext/time/calculations.rb | 2 +- .../lib/active_support/notifications/instrumenter.rb | 4 ++-- activesupport/test/array_inquirer_test.rb | 2 +- activesupport/test/string_inquirer_test.rb | 2 +- activesupport/test/subscriber_test.rb | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5ad6a39673..2e0353e861 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -208,6 +208,9 @@ Lint/AmbiguousRegexpLiteral: Lint/DuplicateRequire: Enabled: true +Lint/DuplicateMethods: + Enabled: true + Lint/ErbNewArguments: Enabled: true diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index ac10b8aa06..c5c0637a8f 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -1917,8 +1917,6 @@ class RouteSetTest < ActiveSupport::TestCase include ActionDispatch::RoutingVerbs - alias :routes :set - def test_generate_with_optional_params_recalls_last_request @set = make_set false diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index f2dd4aae89..09553d3400 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -305,7 +305,7 @@ class Time other.is_a?(DateTime) ? to_f - other.to_f : minus_without_coercion(other) end alias_method :minus_without_coercion, :- - alias_method :-, :minus_with_coercion + alias_method :-, :minus_with_coercion # rubocop:disable Lint/DuplicateMethods # Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances # can be chronologically compared with a Time diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb index 9088fd8182..9826dccd84 100644 --- a/activesupport/lib/active_support/notifications/instrumenter.rb +++ b/activesupport/lib/active_support/notifications/instrumenter.rb @@ -153,7 +153,7 @@ module ActiveSupport Process.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :float_millisecond) end rescue - def now_cpu + def now_cpu # rubocop:disable Lint/DuplicateMethods 0.0 end end @@ -165,7 +165,7 @@ module ActiveSupport 0 end else - def now_allocations + def now_allocations # rubocop:disable Lint/DuplicateMethods GC.stat(:total_allocated_objects) end end diff --git a/activesupport/test/array_inquirer_test.rb b/activesupport/test/array_inquirer_test.rb index 2c31c50fc6..2cdd7240e2 100644 --- a/activesupport/test/array_inquirer_test.rb +++ b/activesupport/test/array_inquirer_test.rb @@ -55,7 +55,7 @@ class ArrayInquirerTest < ActiveSupport::TestCase ensure Array.class_eval do undef_method :respond_to_missing? - def respond_to_missing?(name, include_private = false) + def respond_to_missing?(name, include_private = false) # rubocop:disable Lint/DuplicateMethods super end end diff --git a/activesupport/test/string_inquirer_test.rb b/activesupport/test/string_inquirer_test.rb index 4e904e996d..ac3c8ca28b 100644 --- a/activesupport/test/string_inquirer_test.rb +++ b/activesupport/test/string_inquirer_test.rb @@ -38,7 +38,7 @@ class StringInquirerTest < ActiveSupport::TestCase ensure String.class_eval do undef_method :respond_to_missing? - def respond_to_missing?(name, include_private = false) + def respond_to_missing?(name, include_private = false) # rubocop:disable Lint/DuplicateMethods super end end diff --git a/activesupport/test/subscriber_test.rb b/activesupport/test/subscriber_test.rb index b374241738..232a1e6088 100644 --- a/activesupport/test/subscriber_test.rb +++ b/activesupport/test/subscriber_test.rb @@ -34,7 +34,7 @@ end # Monkey patch subscriber to test that only one subscriber per method is added. class TestSubscriber remove_method :open_party - def open_party(event) + def open_party(event) # rubocop:disable Lint/DuplicateMethods events << event end end