[rubygems/rubygems] util/rubocop -A --only Lint/BinaryOperatorWithIdenticalOperands

Many of class of RubyGems have original <=> methods. We should ignore
  these cops for testing.

https://github.com/rubygems/rubygems/commit/0a8645dc3b
This commit is contained in:
Hiroshi SHIBATA 2023-03-22 14:54:18 +09:00
Родитель a3670249fa
Коммит 19e9c4004b
9 изменённых файлов: 15 добавлений и 13 удалений

Просмотреть файл

@ -231,7 +231,7 @@ class TestGemPlatform < Gem::TestCase
my = Gem::Platform.new %w[cpu my_platform 1]
other = Gem::Platform.new %w[cpu other_platform 1]
assert(my === my)
assert(my === my) # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
refute(other === my)
refute(my === other)
end

Просмотреть файл

@ -194,7 +194,7 @@ class TestGemSource < Gem::TestCase
installed = Gem::Source::Installed.new
local = Gem::Source::Local.new
assert_equal(0, remote.<=>(remote), "remote <=> remote")
assert_equal(0, remote.<=>(remote), "remote <=> remote") # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(-1, remote.<=>(specific), "remote <=> specific")
assert_equal(1, specific.<=>(remote), "specific <=> remote")
@ -215,7 +215,7 @@ class TestGemSource < Gem::TestCase
sourceA = Gem::Source.new "http://example.com/a"
sourceB = Gem::Source.new "http://example.com/b"
assert_equal(0, sourceA.<=>(sourceA), "sourceA <=> sourceA")
assert_equal(0, sourceA.<=>(sourceA), "sourceA <=> sourceA") # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(1, sourceA.<=>(sourceB), "sourceA <=> sourceB")
assert_equal(1, sourceB.<=>(sourceA), "sourceB <=> sourceA")
end

Просмотреть файл

@ -215,7 +215,7 @@ class TestGemSourceGit < Gem::TestCase
installed = Gem::Source::Installed.new
vendor = Gem::Source::Vendor.new "vendor/foo"
assert_equal(0, git.<=>(git), "git <=> git")
assert_equal(0, git.<=>(git), "git <=> git") # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(1, git.<=>(remote), "git <=> remote")
assert_equal(-1, remote.<=>(git), "remote <=> git")

Просмотреть файл

@ -14,7 +14,7 @@ class TestGemSourceInstalled < Gem::TestCase
git = Gem::Source::Git.new "a", "a", nil
vendor = Gem::Source::Vendor.new "a"
assert_equal(0, installed.<=>(installed), "installed <=> installed")
assert_equal(0, installed.<=>(installed), "installed <=> installed") # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(-1, remote.<=>(installed), "remote <=> installed")
assert_equal(1, installed.<=>(remote), "installed <=> remote")

Просмотреть файл

@ -92,7 +92,7 @@ class TestGemSourceLocal < Gem::TestCase
installed = Gem::Source::Installed.new
local = Gem::Source::Local.new
assert_equal(0, local.<=>(local), "local <=> local")
assert_equal(0, local.<=>(local), "local <=> local") # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(-1, remote.<=>(local), "remote <=> local")
assert_equal(1, local.<=>(remote), "local <=> remote")

Просмотреть файл

@ -39,9 +39,11 @@ class TestGemSourceLock < Gem::TestCase
vendor = Gem::Source::Vendor.new "vendor/a"
v_lock = Gem::Source::Lock.new vendor
# rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(0, g_lock.<=>(g_lock), "g_lock <=> g_lock")
assert_equal(0, i_lock.<=>(i_lock), "i_lock <=> i_lock")
assert_equal(0, v_lock.<=>(v_lock), "v_lock <=> v_lock")
# rubocop:enable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(1, g_lock.<=>(i_lock), "g_lock <=> i_lock")
assert_equal(-1, i_lock.<=>(g_lock), "i_lock <=> g_lock")

Просмотреть файл

@ -45,7 +45,7 @@ class TestGemSourceSpecificFile < Gem::TestCase
installed = Gem::Source::Installed.new
local = Gem::Source::Local.new
assert_equal(0, specific.<=>(specific), "specific <=> specific")
assert_equal(0, specific.<=>(specific), "specific <=> specific") # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(-1, remote.<=>(specific), "remote <=> specific")
assert_equal(1, specific.<=>(remote), "specific <=> remote")
@ -69,7 +69,7 @@ class TestGemSourceSpecificFile < Gem::TestCase
assert_nil a1_source.<=>(b1_source), "a1_source <=> b1_source"
assert_equal(-1, a1_source.<=>(a2_source), "a1_source <=> a2_source")
assert_equal(0, a1_source.<=>(a1_source), "a1_source <=> a1_source")
assert_equal(0, a1_source.<=>(a1_source), "a1_source <=> a1_source") # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(1, a2_source.<=>(a1_source), "a2_source <=> a1_source")
end
end

Просмотреть файл

@ -15,7 +15,7 @@ class TestGemSourceVendor < Gem::TestCase
git = Gem::Source::Git.new "a", "a", nil
installed = Gem::Source::Installed.new
assert_equal(0, vendor.<=>(vendor), "vendor <=> vendor")
assert_equal(0, vendor.<=>(vendor), "vendor <=> vendor") # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(1, vendor.<=>(remote), "vendor <=> remote")
assert_equal(-1, remote.<=>(vendor), "remote <=> vendor")

Просмотреть файл

@ -2194,7 +2194,7 @@ dependencies: []
s2 = util_spec "b", "1"
assert_equal(-1, (s1 <=> s2))
assert_equal(0, (s1 <=> s1))
assert_equal(0, (s1 <=> s1)) # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(1, (s2 <=> s1))
end
@ -2205,7 +2205,7 @@ dependencies: []
end
assert_equal(-1, (s1 <=> s2))
assert_equal(0, (s1 <=> s1))
assert_equal(0, (s1 <=> s1)) # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(1, (s2 <=> s1))
end
@ -2214,7 +2214,7 @@ dependencies: []
s2 = util_spec "a", "2"
assert_equal(-1, (s1 <=> s2))
assert_equal(0, (s1 <=> s1))
assert_equal(0, (s1 <=> s1)) # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
assert_equal(1, (s2 <=> s1))
end
@ -2438,7 +2438,7 @@ end
def test_to_ruby_nested_hash
metadata = {}
metadata[metadata] = metadata
metadata[:metadata] = {}
@a2.metadata = metadata