Fix Style/OptionalBooleanParameter
cop (#34968)
This commit is contained in:
parent
a2a6117143
commit
dc2cfd50a0
14 changed files with 17 additions and 29 deletions
|
@ -38,15 +38,3 @@ Style/FetchEnvVar:
|
||||||
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
|
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
|
||||||
Style/GuardClause:
|
Style/GuardClause:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Configuration parameters: AllowedMethods.
|
|
||||||
# AllowedMethods: respond_to_missing?
|
|
||||||
Style/OptionalBooleanParameter:
|
|
||||||
Exclude:
|
|
||||||
- 'app/lib/admin/system_check/message.rb'
|
|
||||||
- 'app/lib/request.rb'
|
|
||||||
- 'app/lib/webfinger.rb'
|
|
||||||
- 'app/services/block_domain_service.rb'
|
|
||||||
- 'app/services/fetch_resource_service.rb'
|
|
||||||
- 'app/workers/domain_block_worker.rb'
|
|
||||||
- 'app/workers/unfollow_follow_worker.rb'
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Admin::SystemCheck::MediaPrivacyCheck < Admin::SystemCheck::BaseCheck
|
||||||
end
|
end
|
||||||
|
|
||||||
def message
|
def message
|
||||||
Admin::SystemCheck::Message.new(@failure_message, @failure_value, @failure_action, true)
|
Admin::SystemCheck::Message.new(@failure_message, @failure_value, @failure_action, critical: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class Admin::SystemCheck::Message
|
class Admin::SystemCheck::Message
|
||||||
attr_reader :key, :value, :action, :critical
|
attr_reader :key, :value, :action, :critical
|
||||||
|
|
||||||
def initialize(key, value = nil, action = nil, critical = false)
|
def initialize(key, value = nil, action = nil, critical: false)
|
||||||
@key = key
|
@key = key
|
||||||
@value = value
|
@value = value
|
||||||
@action = action
|
@action = action
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Admin::SystemCheck::SoftwareVersionCheck < Admin::SystemCheck::BaseCheck
|
||||||
|
|
||||||
def message
|
def message
|
||||||
if software_updates.any?(&:urgent?)
|
if software_updates.any?(&:urgent?)
|
||||||
Admin::SystemCheck::Message.new(:software_version_critical_check, nil, admin_software_updates_path, true)
|
Admin::SystemCheck::Message.new(:software_version_critical_check, nil, admin_software_updates_path, critical: true)
|
||||||
elsif software_updates.any?(&:patch_type?)
|
elsif software_updates.any?(&:patch_type?)
|
||||||
Admin::SystemCheck::Message.new(:software_version_patch_check, nil, admin_software_updates_path)
|
Admin::SystemCheck::Message.new(:software_version_patch_check, nil, admin_software_updates_path)
|
||||||
else
|
else
|
||||||
|
|
|
@ -20,7 +20,7 @@ class PerOperationWithDeadline < HTTP::Timeout::PerOperation
|
||||||
@read_deadline = options.fetch(:read_deadline, READ_DEADLINE)
|
@read_deadline = options.fetch(:read_deadline, READ_DEADLINE)
|
||||||
end
|
end
|
||||||
|
|
||||||
def connect(socket_class, host, port, nodelay = false)
|
def connect(socket_class, host, port, nodelay = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||||
@socket = socket_class.open(host, port)
|
@socket = socket_class.open(host, port)
|
||||||
@socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) if nodelay
|
@socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) if nodelay
|
||||||
end
|
end
|
||||||
|
|
|
@ -65,7 +65,7 @@ class Webfinger
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def body_from_webfinger(url = standard_url, use_fallback = true)
|
def body_from_webfinger(url = standard_url, use_fallback: true)
|
||||||
webfinger_request(url).perform do |res|
|
webfinger_request(url).perform do |res|
|
||||||
if res.code == 200
|
if res.code == 200
|
||||||
body = res.body_with_limit
|
body = res.body_with_limit
|
||||||
|
@ -85,7 +85,7 @@ class Webfinger
|
||||||
def body_from_host_meta
|
def body_from_host_meta
|
||||||
host_meta_request.perform do |res|
|
host_meta_request.perform do |res|
|
||||||
if res.code == 200
|
if res.code == 200
|
||||||
body_from_webfinger(url_from_template(res.body_with_limit), false)
|
body_from_webfinger(url_from_template(res.body_with_limit), use_fallback: false)
|
||||||
else
|
else
|
||||||
raise Webfinger::Error, "Request for #{@uri} returned HTTP #{res.code}"
|
raise Webfinger::Error, "Request for #{@uri} returned HTTP #{res.code}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class BlockDomainService < BaseService
|
class BlockDomainService < BaseService
|
||||||
attr_reader :domain_block
|
attr_reader :domain_block
|
||||||
|
|
||||||
def call(domain_block, update = false)
|
def call(domain_block, update: false)
|
||||||
@domain_block = domain_block
|
@domain_block = domain_block
|
||||||
@domain_block_event = nil
|
@domain_block_event = nil
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class FetchResourceService < BaseService
|
||||||
def process(url, terminal: false)
|
def process(url, terminal: false)
|
||||||
@url = url
|
@url = url
|
||||||
|
|
||||||
perform_request { |response| process_response(response, terminal) }
|
perform_request { |response| process_response(response, terminal:) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform_request(&block)
|
def perform_request(&block)
|
||||||
|
@ -40,7 +40,7 @@ class FetchResourceService < BaseService
|
||||||
end.perform(&block)
|
end.perform(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_response(response, terminal = false)
|
def process_response(response, terminal: false)
|
||||||
@response_code = response.code
|
@response_code = response.code
|
||||||
return nil if response.code != 200
|
return nil if response.code != 200
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
class DomainBlockWorker
|
class DomainBlockWorker
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
def perform(domain_block_id, update = false)
|
def perform(domain_block_id, update = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||||
domain_block = DomainBlock.find_by(id: domain_block_id)
|
domain_block = DomainBlock.find_by(id: domain_block_id)
|
||||||
return true if domain_block.nil?
|
return true if domain_block.nil?
|
||||||
|
|
||||||
BlockDomainService.new.call(domain_block, update)
|
BlockDomainService.new.call(domain_block, update:)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ class UnfollowFollowWorker
|
||||||
|
|
||||||
sidekiq_options queue: 'pull'
|
sidekiq_options queue: 'pull'
|
||||||
|
|
||||||
def perform(follower_account_id, old_target_account_id, new_target_account_id, bypass_locked = false)
|
def perform(follower_account_id, old_target_account_id, new_target_account_id, bypass_locked = false) # rubocop:disable Style/OptionalBooleanParameter
|
||||||
follower_account = Account.find(follower_account_id)
|
follower_account = Account.find(follower_account_id)
|
||||||
old_target_account = Account.find(old_target_account_id)
|
old_target_account = Account.find(old_target_account_id)
|
||||||
new_target_account = Account.find(new_target_account_id)
|
new_target_account = Account.find(new_target_account_id)
|
||||||
|
|
|
@ -23,11 +23,11 @@ RSpec.describe Admin::SystemCheck::MediaPrivacyCheck do
|
||||||
|
|
||||||
describe 'message' do
|
describe 'message' do
|
||||||
it 'sends values to message instance' do
|
it 'sends values to message instance' do
|
||||||
allow(Admin::SystemCheck::Message).to receive(:new).with(nil, nil, nil, true)
|
allow(Admin::SystemCheck::Message).to receive(:new).with(nil, nil, nil, critical: true)
|
||||||
|
|
||||||
check.message
|
check.message
|
||||||
|
|
||||||
expect(Admin::SystemCheck::Message).to have_received(:new).with(nil, nil, nil, true)
|
expect(Admin::SystemCheck::Message).to have_received(:new).with(nil, nil, nil, critical: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Admin::SystemCheck::Message do
|
RSpec.describe Admin::SystemCheck::Message do
|
||||||
subject(:check) { described_class.new(:key_value, :value_value, :action_value, :critical_value) }
|
subject(:check) { described_class.new(:key_value, :value_value, :action_value, critical: :critical_value) }
|
||||||
|
|
||||||
it 'providers readers when initialized' do
|
it 'providers readers when initialized' do
|
||||||
expect(check.key).to eq :key_value
|
expect(check.key).to eq :key_value
|
||||||
|
|
|
@ -127,7 +127,7 @@ RSpec.describe Admin::SystemCheck::SoftwareVersionCheck do
|
||||||
check.message
|
check.message
|
||||||
|
|
||||||
expect(Admin::SystemCheck::Message).to have_received(:new)
|
expect(Admin::SystemCheck::Message).to have_received(:new)
|
||||||
.with(:software_version_critical_check, nil, admin_software_updates_path, true)
|
.with(:software_version_critical_check, nil, admin_software_updates_path, critical: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe DomainBlockWorker do
|
||||||
result = subject.perform(domain_block.id)
|
result = subject.perform(domain_block.id)
|
||||||
|
|
||||||
expect(result).to be_nil
|
expect(result).to be_nil
|
||||||
expect(service).to have_received(:call).with(domain_block, false)
|
expect(service).to have_received(:call).with(domain_block, update: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true for non-existent domain block' do
|
it 'returns true for non-existent domain block' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue