From 6d42820e5df4a2282af1194a98789b45027aabce Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 17 Feb 2023 21:22:01 -0500 Subject: [PATCH] Autofix Rubocop Lint/AmbiguousOperator (#23680) --- .rubocop_todo.yml | 8 -------- spec/controllers/api/v1/suggestions_controller_spec.rb | 2 +- spec/lib/request_spec.rb | 8 ++++---- spec/models/user_role_spec.rb | 4 ++-- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 12e4f14ec9..ddfe5c36b3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -183,14 +183,6 @@ Lint/AmbiguousBlockAssociation: - 'spec/services/unsuspend_account_service_spec.rb' - 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb' -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -Lint/AmbiguousOperator: - Exclude: - - 'spec/controllers/api/v1/suggestions_controller_spec.rb' - - 'spec/lib/request_spec.rb' - - 'spec/models/user_role_spec.rb' - # Offense count: 17 # This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperatorPrecedence: diff --git a/spec/controllers/api/v1/suggestions_controller_spec.rb b/spec/controllers/api/v1/suggestions_controller_spec.rb index 17f10b04fe..7805b6b4fe 100644 --- a/spec/controllers/api/v1/suggestions_controller_spec.rb +++ b/spec/controllers/api/v1/suggestions_controller_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Api::V1::SuggestionsController, type: :controller do json = body_as_json expect(json.size).to be >= 1 - expect(json.map { |i| i[:id] }).to include *[bob, jeff].map { |i| i.id.to_s } + expect(json.map { |i| i[:id] }).to include(*[bob, jeff].map { |i| i.id.to_s }) end end end diff --git a/spec/lib/request_spec.rb b/spec/lib/request_spec.rb index 8539944e28..e555a8b5a1 100644 --- a/spec/lib/request_spec.rb +++ b/spec/lib/request_spec.rb @@ -43,7 +43,7 @@ describe Request do before { stub_request(:get, 'http://example.com') } it 'executes a HTTP request' do - expect { |block| subject.perform &block }.to yield_control + expect { |block| subject.perform(&block) }.to yield_control expect(a_request(:get, 'http://example.com')).to have_been_made.once end @@ -54,18 +54,18 @@ describe Request do allow(resolver).to receive(:timeouts=).and_return(nil) allow(Resolv::DNS).to receive(:open).and_yield(resolver) - expect { |block| subject.perform &block }.to yield_control + expect { |block| subject.perform(&block) }.to yield_control expect(a_request(:get, 'http://example.com')).to have_been_made.once end it 'sets headers' do - expect { |block| subject.perform &block }.to yield_control + expect { |block| subject.perform(&block) }.to yield_control expect(a_request(:get, 'http://example.com').with(headers: subject.headers)).to have_been_made end it 'closes underlying connection' do expect_any_instance_of(HTTP::Client).to receive(:close) - expect { |block| subject.perform &block }.to yield_control + expect { |block| subject.perform(&block) }.to yield_control end it 'returns response which implements body_with_limit' do diff --git a/spec/models/user_role_spec.rb b/spec/models/user_role_spec.rb index abf7d0e27c..7294d14fea 100644 --- a/spec/models/user_role_spec.rb +++ b/spec/models/user_role_spec.rb @@ -139,7 +139,7 @@ RSpec.describe UserRole, type: :model do end it 'has negative position' do - expect(subject.position).to eq -1 + expect(subject.position).to eq(-1) end end @@ -159,7 +159,7 @@ RSpec.describe UserRole, type: :model do end it 'has negative position' do - expect(subject.position).to eq -1 + expect(subject.position).to eq(-1) end end