mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Update rubocop and rubocop-rspec (#26329)
This commit is contained in:
parent
fe31571965
commit
b970ed6098
@ -1,6 +1,6 @@
|
|||||||
# This configuration was generated by
|
# This configuration was generated by
|
||||||
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp`
|
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp`
|
||||||
# using RuboCop version 1.54.2.
|
# using RuboCop version 1.56.1.
|
||||||
# The point is for the user to remove these configuration records
|
# The point is for the user to remove these configuration records
|
||||||
# one by one as the offenses are removed from the code base.
|
# one by one as the offenses are removed from the code base.
|
||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
@ -61,38 +61,8 @@ Lint/EmptyBlock:
|
|||||||
- 'spec/fabricators/access_token_fabricator.rb'
|
- 'spec/fabricators/access_token_fabricator.rb'
|
||||||
- 'spec/fabricators/conversation_fabricator.rb'
|
- 'spec/fabricators/conversation_fabricator.rb'
|
||||||
- 'spec/fabricators/system_key_fabricator.rb'
|
- 'spec/fabricators/system_key_fabricator.rb'
|
||||||
- 'spec/helpers/admin/action_logs_helper_spec.rb'
|
|
||||||
- 'spec/lib/activitypub/adapter_spec.rb'
|
- 'spec/lib/activitypub/adapter_spec.rb'
|
||||||
- 'spec/models/account_alias_spec.rb'
|
|
||||||
- 'spec/models/account_deletion_request_spec.rb'
|
|
||||||
- 'spec/models/account_moderation_note_spec.rb'
|
|
||||||
- 'spec/models/announcement_mute_spec.rb'
|
|
||||||
- 'spec/models/announcement_reaction_spec.rb'
|
|
||||||
- 'spec/models/announcement_spec.rb'
|
|
||||||
- 'spec/models/backup_spec.rb'
|
|
||||||
- 'spec/models/conversation_mute_spec.rb'
|
|
||||||
- 'spec/models/custom_filter_keyword_spec.rb'
|
|
||||||
- 'spec/models/custom_filter_spec.rb'
|
|
||||||
- 'spec/models/device_spec.rb'
|
|
||||||
- 'spec/models/encrypted_message_spec.rb'
|
|
||||||
- 'spec/models/featured_tag_spec.rb'
|
|
||||||
- 'spec/models/follow_recommendation_suppression_spec.rb'
|
|
||||||
- 'spec/models/list_account_spec.rb'
|
|
||||||
- 'spec/models/list_spec.rb'
|
|
||||||
- 'spec/models/login_activity_spec.rb'
|
|
||||||
- 'spec/models/mute_spec.rb'
|
|
||||||
- 'spec/models/preview_card_spec.rb'
|
|
||||||
- 'spec/models/preview_card_trend_spec.rb'
|
|
||||||
- 'spec/models/relay_spec.rb'
|
|
||||||
- 'spec/models/scheduled_status_spec.rb'
|
|
||||||
- 'spec/models/status_stat_spec.rb'
|
|
||||||
- 'spec/models/status_trend_spec.rb'
|
|
||||||
- 'spec/models/system_key_spec.rb'
|
|
||||||
- 'spec/models/tag_follow_spec.rb'
|
|
||||||
- 'spec/models/unavailable_domain_spec.rb'
|
|
||||||
- 'spec/models/user_invite_request_spec.rb'
|
|
||||||
- 'spec/models/user_role_spec.rb'
|
- 'spec/models/user_role_spec.rb'
|
||||||
- 'spec/models/web/setting_spec.rb'
|
|
||||||
|
|
||||||
Lint/NonLocalExitFromIterator:
|
Lint/NonLocalExitFromIterator:
|
||||||
Exclude:
|
Exclude:
|
||||||
@ -135,7 +105,7 @@ Lint/UselessAssignment:
|
|||||||
|
|
||||||
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 146
|
Max: 144
|
||||||
|
|
||||||
# Configuration parameters: CountBlocks, Max.
|
# Configuration parameters: CountBlocks, Max.
|
||||||
Metrics/BlockNesting:
|
Metrics/BlockNesting:
|
||||||
@ -164,6 +134,19 @@ Naming/VariableNumber:
|
|||||||
- 'spec/models/domain_block_spec.rb'
|
- 'spec/models/domain_block_spec.rb'
|
||||||
- 'spec/models/user_spec.rb'
|
- 'spec/models/user_spec.rb'
|
||||||
|
|
||||||
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||||
|
# Configuration parameters: SafeMultiline.
|
||||||
|
Performance/DeletePrefix:
|
||||||
|
Exclude:
|
||||||
|
- 'app/models/featured_tag.rb'
|
||||||
|
|
||||||
|
Performance/MapMethodChain:
|
||||||
|
Exclude:
|
||||||
|
- 'app/models/feed.rb'
|
||||||
|
- 'lib/mastodon/cli/maintenance.rb'
|
||||||
|
- 'spec/services/bulk_import_service_spec.rb'
|
||||||
|
- 'spec/services/import_service_spec.rb'
|
||||||
|
|
||||||
RSpec/AnyInstance:
|
RSpec/AnyInstance:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'spec/controllers/activitypub/inboxes_controller_spec.rb'
|
- 'spec/controllers/activitypub/inboxes_controller_spec.rb'
|
||||||
@ -762,6 +745,15 @@ Style/RedundantFetchBlock:
|
|||||||
- 'config/initializers/paperclip.rb'
|
- 'config/initializers/paperclip.rb'
|
||||||
- 'config/puma.rb'
|
- 'config/puma.rb'
|
||||||
|
|
||||||
|
# This cop supports safe autocorrection (--autocorrect).
|
||||||
|
# Configuration parameters: AllowMultipleReturnValues.
|
||||||
|
Style/RedundantReturn:
|
||||||
|
Exclude:
|
||||||
|
- 'app/controllers/api/v1/directories_controller.rb'
|
||||||
|
- 'app/controllers/auth/confirmations_controller.rb'
|
||||||
|
- 'app/lib/ostatus/tag_manager.rb'
|
||||||
|
- 'app/models/form/import.rb'
|
||||||
|
|
||||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||||
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
|
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
|
||||||
# AllowedMethods: present?, blank?, presence, try, try!
|
# AllowedMethods: present?, blank?, presence, try, try!
|
||||||
|
10
Gemfile.lock
10
Gemfile.lock
@ -147,6 +147,7 @@ GEM
|
|||||||
faraday_middleware (~> 1.0, >= 1.0.0.rc1)
|
faraday_middleware (~> 1.0, >= 1.0.0.rc1)
|
||||||
net-http-persistent (~> 4.0)
|
net-http-persistent (~> 4.0)
|
||||||
nokogiri (~> 1, >= 1.10.8)
|
nokogiri (~> 1, >= 1.10.8)
|
||||||
|
base64 (0.1.1)
|
||||||
bcrypt (3.1.18)
|
bcrypt (3.1.18)
|
||||||
better_errors (2.10.1)
|
better_errors (2.10.1)
|
||||||
erubi (>= 1.0.0)
|
erubi (>= 1.0.0)
|
||||||
@ -637,7 +638,8 @@ GEM
|
|||||||
sidekiq (>= 2.4.0)
|
sidekiq (>= 2.4.0)
|
||||||
rspec-support (3.12.0)
|
rspec-support (3.12.0)
|
||||||
rspec_chunked (0.6)
|
rspec_chunked (0.6)
|
||||||
rubocop (1.54.2)
|
rubocop (1.56.1)
|
||||||
|
base64 (~> 0.1.1)
|
||||||
json (~> 2.3)
|
json (~> 2.3)
|
||||||
language_server-protocol (>= 3.17.0)
|
language_server-protocol (>= 3.17.0)
|
||||||
parallel (~> 1.10)
|
parallel (~> 1.10)
|
||||||
@ -645,7 +647,7 @@ GEM
|
|||||||
rainbow (>= 2.2.2, < 4.0)
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
regexp_parser (>= 1.8, < 3.0)
|
regexp_parser (>= 1.8, < 3.0)
|
||||||
rexml (>= 3.2.5, < 4.0)
|
rexml (>= 3.2.5, < 4.0)
|
||||||
rubocop-ast (>= 1.28.0, < 2.0)
|
rubocop-ast (>= 1.28.1, < 2.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (>= 2.4.0, < 3.0)
|
unicode-display_width (>= 2.4.0, < 3.0)
|
||||||
rubocop-ast (1.29.0)
|
rubocop-ast (1.29.0)
|
||||||
@ -654,14 +656,14 @@ GEM
|
|||||||
rubocop (~> 1.41)
|
rubocop (~> 1.41)
|
||||||
rubocop-factory_bot (2.23.1)
|
rubocop-factory_bot (2.23.1)
|
||||||
rubocop (~> 1.33)
|
rubocop (~> 1.33)
|
||||||
rubocop-performance (1.18.0)
|
rubocop-performance (1.19.0)
|
||||||
rubocop (>= 1.7.0, < 2.0)
|
rubocop (>= 1.7.0, < 2.0)
|
||||||
rubocop-ast (>= 0.4.0)
|
rubocop-ast (>= 0.4.0)
|
||||||
rubocop-rails (2.20.2)
|
rubocop-rails (2.20.2)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
rack (>= 1.1)
|
rack (>= 1.1)
|
||||||
rubocop (>= 1.33.0, < 2.0)
|
rubocop (>= 1.33.0, < 2.0)
|
||||||
rubocop-rspec (2.22.0)
|
rubocop-rspec (2.23.2)
|
||||||
rubocop (~> 1.33)
|
rubocop (~> 1.33)
|
||||||
rubocop-capybara (~> 2.17)
|
rubocop-capybara (~> 2.17)
|
||||||
rubocop-factory_bot (~> 2.22)
|
rubocop-factory_bot (~> 2.22)
|
||||||
|
@ -68,8 +68,8 @@ class Importer::BaseImporter
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def in_work_unit(*args, &block)
|
def in_work_unit(...)
|
||||||
work_unit = Concurrent::Promises.future_on(@executor, *args, &block)
|
work_unit = Concurrent::Promises.future_on(@executor, ...)
|
||||||
|
|
||||||
work_unit.on_fulfillment!(&@on_progress)
|
work_unit.on_fulfillment!(&@on_progress)
|
||||||
work_unit.on_rejection!(&@on_failure)
|
work_unit.on_rejection!(&@on_failure)
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
class Redis
|
class Redis
|
||||||
module NamespaceExtensions
|
module NamespaceExtensions
|
||||||
def exists?(*args, &block)
|
def exists?(...)
|
||||||
call_with_namespace('exists?', *args, &block)
|
call_with_namespace('exists?', ...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,8 +16,7 @@ describe Api::V1::Instances::TranslationLanguagesController do
|
|||||||
context 'when a translation service is configured' do
|
context 'when a translation service is configured' do
|
||||||
before do
|
before do
|
||||||
service = instance_double(TranslationService::DeepL, languages: { nil => %w(en de), 'en' => ['de'] })
|
service = instance_double(TranslationService::DeepL, languages: { nil => %w(en de), 'en' => ['de'] })
|
||||||
allow(TranslationService).to receive(:configured?).and_return(true)
|
allow(TranslationService).to receive_messages(configured?: true, configured: service)
|
||||||
allow(TranslationService).to receive(:configured).and_return(service)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns language matrix' do
|
it 'returns language matrix' do
|
||||||
|
@ -20,8 +20,7 @@ describe Api::V1::Statuses::TranslationsController do
|
|||||||
before do
|
before do
|
||||||
translation = TranslationService::Translation.new(text: 'Hello')
|
translation = TranslationService::Translation.new(text: 'Hello')
|
||||||
service = instance_double(TranslationService::DeepL, translate: [translation])
|
service = instance_double(TranslationService::DeepL, translate: [translation])
|
||||||
allow(TranslationService).to receive(:configured?).and_return(true)
|
allow(TranslationService).to receive_messages(configured?: true, configured: service)
|
||||||
allow(TranslationService).to receive(:configured).and_return(service)
|
|
||||||
Rails.cache.write('translation_service/languages', { 'es' => ['en'] })
|
Rails.cache.write('translation_service/languages', { 'es' => ['en'] })
|
||||||
post :create, params: { status_id: status.id }
|
post :create, params: { status_id: status.id }
|
||||||
end
|
end
|
||||||
|
@ -7,8 +7,7 @@ describe Admin::FilterHelper do
|
|||||||
params = ActionController::Parameters.new(
|
params = ActionController::Parameters.new(
|
||||||
{ test: 'test' }
|
{ test: 'test' }
|
||||||
)
|
)
|
||||||
allow(helper).to receive(:params).and_return(params)
|
allow(helper).to receive_messages(params: params, url_for: '/test')
|
||||||
allow(helper).to receive(:url_for).and_return('/test')
|
|
||||||
result = helper.filter_link_to('text', { resolved: true })
|
result = helper.filter_link_to('text', { resolved: true })
|
||||||
|
|
||||||
expect(result).to match(/text/)
|
expect(result).to match(/text/)
|
||||||
|
@ -31,9 +31,7 @@ describe ApplicationHelper do
|
|||||||
context 'with a body class string from a controller' do
|
context 'with a body class string from a controller' do
|
||||||
before do
|
before do
|
||||||
without_partial_double_verification do
|
without_partial_double_verification do
|
||||||
allow(helper).to receive(:body_class_string).and_return('modal-layout compose-standalone')
|
allow(helper).to receive_messages(body_class_string: 'modal-layout compose-standalone', current_theme: 'default', current_account: Fabricate(:account))
|
||||||
allow(helper).to receive(:current_theme).and_return('default')
|
|
||||||
allow(helper).to receive(:current_account).and_return(Fabricate(:account))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,8 +25,7 @@ RSpec.describe HomeHelper do
|
|||||||
|
|
||||||
it 'returns a link to the account' do
|
it 'returns a link to the account' do
|
||||||
without_partial_double_verification do
|
without_partial_double_verification do
|
||||||
allow(helper).to receive(:current_account).and_return(account)
|
allow(helper).to receive_messages(current_account: account, prefers_autoplay?: false)
|
||||||
allow(helper).to receive(:prefers_autoplay?).and_return(false)
|
|
||||||
result = helper.account_link_to(account)
|
result = helper.account_link_to(account)
|
||||||
|
|
||||||
expect(result).to match "@#{account.acct}"
|
expect(result).to match "@#{account.acct}"
|
||||||
@ -101,8 +100,7 @@ RSpec.describe HomeHelper do
|
|||||||
|
|
||||||
context 'with open registrations' do
|
context 'with open registrations' do
|
||||||
it 'returns correct sign up message' do
|
it 'returns correct sign up message' do
|
||||||
allow(helper).to receive(:closed_registrations?).and_return(false)
|
allow(helper).to receive_messages(closed_registrations?: false, open_registrations?: true)
|
||||||
allow(helper).to receive(:open_registrations?).and_return(true)
|
|
||||||
result = helper.sign_up_message
|
result = helper.sign_up_message
|
||||||
|
|
||||||
expect(result).to eq t('auth.register')
|
expect(result).to eq t('auth.register')
|
||||||
@ -111,9 +109,7 @@ RSpec.describe HomeHelper do
|
|||||||
|
|
||||||
context 'with approved registrations' do
|
context 'with approved registrations' do
|
||||||
it 'returns correct sign up message' do
|
it 'returns correct sign up message' do
|
||||||
allow(helper).to receive(:closed_registrations?).and_return(false)
|
allow(helper).to receive_messages(closed_registrations?: false, open_registrations?: false, approved_registrations?: true)
|
||||||
allow(helper).to receive(:open_registrations?).and_return(false)
|
|
||||||
allow(helper).to receive(:approved_registrations?).and_return(true)
|
|
||||||
result = helper.sign_up_message
|
result = helper.sign_up_message
|
||||||
|
|
||||||
expect(result).to eq t('auth.apply_for_account')
|
expect(result).to eq t('auth.apply_for_account')
|
||||||
|
@ -14,13 +14,12 @@ describe Admin::SystemCheck::ElasticsearchCheck do
|
|||||||
before do
|
before do
|
||||||
allow(Chewy).to receive(:enabled?).and_return(true)
|
allow(Chewy).to receive(:enabled?).and_return(true)
|
||||||
allow(Chewy.client.cluster).to receive(:health).and_return({ 'status' => 'green', 'number_of_nodes' => 1 })
|
allow(Chewy.client.cluster).to receive(:health).and_return({ 'status' => 'green', 'number_of_nodes' => 1 })
|
||||||
allow(Chewy.client.indices).to receive(:get_mapping).and_return({
|
allow(Chewy.client.indices).to receive_messages(get_mapping: {
|
||||||
AccountsIndex.index_name => AccountsIndex.mappings_hash.deep_stringify_keys,
|
AccountsIndex.index_name => AccountsIndex.mappings_hash.deep_stringify_keys,
|
||||||
StatusesIndex.index_name => StatusesIndex.mappings_hash.deep_stringify_keys,
|
StatusesIndex.index_name => StatusesIndex.mappings_hash.deep_stringify_keys,
|
||||||
InstancesIndex.index_name => InstancesIndex.mappings_hash.deep_stringify_keys,
|
InstancesIndex.index_name => InstancesIndex.mappings_hash.deep_stringify_keys,
|
||||||
TagsIndex.index_name => TagsIndex.mappings_hash.deep_stringify_keys,
|
TagsIndex.index_name => TagsIndex.mappings_hash.deep_stringify_keys,
|
||||||
})
|
}, get_settings: {
|
||||||
allow(Chewy.client.indices).to receive(:get_settings).and_return({
|
|
||||||
'chewy_specifications' => {
|
'chewy_specifications' => {
|
||||||
'settings' => {
|
'settings' => {
|
||||||
'index' => {
|
'index' => {
|
||||||
|
@ -23,8 +23,7 @@ describe ReportFilter do
|
|||||||
it 'combines filters on Report' do
|
it 'combines filters on Report' do
|
||||||
filter = described_class.new(account_id: '123', resolved: true, target_account_id: '456')
|
filter = described_class.new(account_id: '123', resolved: true, target_account_id: '456')
|
||||||
|
|
||||||
allow(Report).to receive(:where).and_return(Report.none)
|
allow(Report).to receive_messages(where: Report.none, resolved: Report.none)
|
||||||
allow(Report).to receive(:resolved).and_return(Report.none)
|
|
||||||
filter.results
|
filter.results
|
||||||
expect(Report).to have_received(:where).with(account_id: '123')
|
expect(Report).to have_received(:where).with(account_id: '123')
|
||||||
expect(Report).to have_received(:where).with(target_account_id: '456')
|
expect(Report).to have_received(:where).with(target_account_id: '456')
|
||||||
|
@ -10,8 +10,7 @@ RSpec.describe SuspendAccountService, type: :service do
|
|||||||
let!(:list) { Fabricate(:list, account: local_follower) }
|
let!(:list) { Fabricate(:list, account: local_follower) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(FeedManager.instance).to receive(:unmerge_from_home).and_return(nil)
|
allow(FeedManager.instance).to receive_messages(unmerge_from_home: nil, unmerge_from_list: nil)
|
||||||
allow(FeedManager.instance).to receive(:unmerge_from_list).and_return(nil)
|
|
||||||
|
|
||||||
local_follower.follow!(account)
|
local_follower.follow!(account)
|
||||||
list.accounts << account
|
list.accounts << account
|
||||||
|
@ -29,8 +29,7 @@ RSpec.describe TranslateStatusService, type: :service do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
allow(TranslationService).to receive(:configured?).and_return(true)
|
allow(TranslationService).to receive_messages(configured?: true, configured: translation_service)
|
||||||
allow(TranslationService).to receive(:configured).and_return(translation_service)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns translated status content' do
|
it 'returns translated status content' do
|
||||||
|
@ -10,8 +10,7 @@ RSpec.describe UnsuspendAccountService, type: :service do
|
|||||||
let!(:list) { Fabricate(:list, account: local_follower) }
|
let!(:list) { Fabricate(:list, account: local_follower) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(FeedManager.instance).to receive(:merge_into_home).and_return(nil)
|
allow(FeedManager.instance).to receive_messages(merge_into_home: nil, merge_into_list: nil)
|
||||||
allow(FeedManager.instance).to receive(:merge_into_list).and_return(nil)
|
|
||||||
|
|
||||||
local_follower.follow!(account)
|
local_follower.follow!(account)
|
||||||
list.accounts << account
|
list.accounts << account
|
||||||
|
@ -4,15 +4,9 @@ require 'rails_helper'
|
|||||||
|
|
||||||
describe 'statuses/show.html.haml', without_verify_partial_doubles: true do
|
describe 'statuses/show.html.haml', without_verify_partial_doubles: true do
|
||||||
before do
|
before do
|
||||||
allow(view).to receive(:api_oembed_url).and_return('')
|
allow(view).to receive_messages(api_oembed_url: '', show_landing_strip?: true, site_title: 'example site', site_hostname: 'example.com', full_asset_url: '//asset.host/image.svg', current_account: nil, single_user_mode?: false)
|
||||||
allow(view).to receive(:show_landing_strip?).and_return(true)
|
|
||||||
allow(view).to receive(:site_title).and_return('example site')
|
|
||||||
allow(view).to receive(:site_hostname).and_return('example.com')
|
|
||||||
allow(view).to receive(:full_asset_url).and_return('//asset.host/image.svg')
|
|
||||||
allow(view).to receive(:local_time)
|
allow(view).to receive(:local_time)
|
||||||
allow(view).to receive(:local_time_ago)
|
allow(view).to receive(:local_time_ago)
|
||||||
allow(view).to receive(:current_account).and_return(nil)
|
|
||||||
allow(view).to receive(:single_user_mode?).and_return(false)
|
|
||||||
assign(:instance_presenter, InstancePresenter.new)
|
assign(:instance_presenter, InstancePresenter.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user