From 97b601725768f0c3aca7cdb9f64a9faefe0188e3 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Fri, 27 Dec 2024 12:35:54 +0900 Subject: [PATCH] Suppress RuboCop offenses This commit sppresses the following RuboCop offenses: ```console Offenses: test/rubocop/cop/minitest/global_expectations_test.rb:167:10: C: [Correctable] Style/MultipleComparison: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead. if style == :_ || style == :any ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test/rubocop/cop/minitest/global_expectations_test.rb:190:10: C: [Correctable] Style/MultipleComparison: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead. if style == :value || style == :any ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test/rubocop/cop/minitest/global_expectations_test.rb:213:10: C: [Correctable] Style/MultipleComparison: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead. if style == :expect || style == :any ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test/rubocop/cop/minitest/global_expectations_test.rb:328:10: C: [Correctable] Style/MultipleComparison: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead. if style == :_ || style == :any ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test/rubocop/cop/minitest/global_expectations_test.rb:351:10: C: [Correctable] Style/MultipleComparison: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead. if style == :_ || style == :any ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test/rubocop/cop/minitest/global_expectations_test.rb:374:10: C: [Correctable] Style/MultipleComparison: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead. if style == :value || style == :any ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test/rubocop/cop/minitest/global_expectations_test.rb:397:10: C: [Correctable] Style/MultipleComparison: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead. if style == :expect || style == :any ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test/rubocop/cop/minitest/global_expectations_test.rb:420:10: C: [Correctable] Style/MultipleComparison: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead. if style == :value || style == :any ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test/rubocop/cop/minitest/global_expectations_test.rb:443:10: C: [Correctable] Style/MultipleComparison: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead. if style == :expect || style == :any ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 137 files inspected, 9 offenses detected, 9 offenses autocorrectable ``` --- .../cop/minitest/global_expectations_test.rb | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test/rubocop/cop/minitest/global_expectations_test.rb b/test/rubocop/cop/minitest/global_expectations_test.rb index 3d73e956..198b252e 100644 --- a/test/rubocop/cop/minitest/global_expectations_test.rb +++ b/test/rubocop/cop/minitest/global_expectations_test.rb @@ -3,6 +3,10 @@ require_relative '../../../test_helper' class GlobalExpectationsTest < Minitest::Test + UNDERSCORE_ANY_STYLES = %i[_ any].freeze + VALUE_ANY_STYLES = %i[value any].freeze + EXPECT_ANY_STYLES = %i[expect any].freeze + def setup configure_enforced_style(style) end @@ -164,7 +168,7 @@ def style end define_method(:"test_no_offense_when_using_expect_form_of_#{matcher}") do - if style == :_ || style == :any + if UNDERSCORE_ANY_STYLES.include?(style) assert_no_offenses(<<~RUBY) it 'does something' do _(n).#{matcher} 42 @@ -187,7 +191,7 @@ def style end define_method(:"test_no_offense_when_using_expect_form_of_#{matcher}_with_value_method") do - if style == :value || style == :any + if VALUE_ANY_STYLES.include?(style) assert_no_offenses(<<~RUBY) it 'does something' do value(n).#{matcher} 42 @@ -210,7 +214,7 @@ def style end define_method(:"test_no_offense_when_using_expect_form_of_#{matcher}_with_expect_method") do - if style == :expect || style == :any + if EXPECT_ANY_STYLES.include?(style) assert_no_offenses(<<~RUBY) it 'does something' do expect(n).#{matcher} 42 @@ -325,7 +329,7 @@ def test_works_with_chained_method_calls end define_method(:"test_no_offense_when_using_expect_form_of_#{matcher}") do - if style == :_ || style == :any + if UNDERSCORE_ANY_STYLES.include?(style) assert_no_offenses(<<~RUBY) it 'does something' do _(n).#{matcher} 42 @@ -348,7 +352,7 @@ def test_works_with_chained_method_calls end define_method(:"test_no_offense_when_using_expect_form_of_#{matcher}_with_block") do - if style == :_ || style == :any + if UNDERSCORE_ANY_STYLES.include?(style) assert_no_offenses(<<~RUBY) it 'does something' do _ { n }.#{matcher} 42 @@ -371,7 +375,7 @@ def test_works_with_chained_method_calls end define_method(:"test_no_offense_when_using_expect_form_of_#{matcher}_with_value_method") do - if style == :value || style == :any + if VALUE_ANY_STYLES.include?(style) assert_no_offenses(<<~RUBY) it 'does something' do value(n).#{matcher} 42 @@ -394,7 +398,7 @@ def test_works_with_chained_method_calls end define_method(:"test_no_offense_when_using_expect_form_of_#{matcher}_with_expect_method") do - if style == :expect || style == :any + if EXPECT_ANY_STYLES.include?(style) assert_no_offenses(<<~RUBY) it 'does something' do expect(n).#{matcher} 42 @@ -417,7 +421,7 @@ def test_works_with_chained_method_calls end define_method(:"test_no_offense_when_using_expect_form_of_#{matcher}_with_value_method_and_block") do - if style == :value || style == :any + if VALUE_ANY_STYLES.include?(style) assert_no_offenses(<<~RUBY) it 'does something' do value { n }.#{matcher} 42 @@ -440,7 +444,7 @@ def test_works_with_chained_method_calls end define_method(:"test_no_offense_when_using_expect_form_of_#{matcher}_with_expect_method_and_block") do - if style == :expect || style == :any + if EXPECT_ANY_STYLES.include?(style) assert_no_offenses(<<~RUBY) it 'does something' do expect { n }.#{matcher} 42