From a71a0802d655fdd32bf1b48e8b400a5b1b13b370 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 17 Feb 2023 21:23:49 -0500 Subject: [PATCH] Autofix Rubocop Lint/SymbolConversion (#23683) --- .rubocop_todo.yml | 14 ------ app/lib/translation_service/deepl.rb | 2 +- app/services/backup_service.rb | 2 +- .../auth/registrations_controller_spec.rb | 4 +- .../auth/sessions_controller_spec.rb | 2 +- .../lib/activitypub/activity/announce_spec.rb | 6 +-- spec/lib/activitypub/activity/create_spec.rb | 6 +-- .../process_collection_service_spec.rb | 48 +++++++++---------- 8 files changed, 35 insertions(+), 49 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ddfe5c36b3..b9971a6106 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -298,20 +298,6 @@ Lint/ParenthesesAsGroupedExpression: - 'spec/lib/activitypub/activity/flag_spec.rb' - 'spec/models/import_spec.rb' -# Offense count: 35 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: strict, consistent -Lint/SymbolConversion: - Exclude: - - 'app/lib/translation_service/deepl.rb' - - 'app/services/backup_service.rb' - - 'spec/controllers/auth/registrations_controller_spec.rb' - - 'spec/controllers/auth/sessions_controller_spec.rb' - - 'spec/lib/activitypub/activity/announce_spec.rb' - - 'spec/lib/activitypub/activity/create_spec.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. diff --git a/app/lib/translation_service/deepl.rb b/app/lib/translation_service/deepl.rb index 537fd24c08..151d33d909 100644 --- a/app/lib/translation_service/deepl.rb +++ b/app/lib/translation_service/deepl.rb @@ -29,7 +29,7 @@ class TranslationService::DeepL < TranslationService def request(text, source_language, target_language) req = Request.new(:post, endpoint_url, form: { text: text, source_lang: source_language&.upcase, target_lang: target_language, tag_handling: 'html' }) - req.add_headers('Authorization': "DeepL-Auth-Key #{@api_key}") + req.add_headers(Authorization: "DeepL-Auth-Key #{@api_key}") req end diff --git a/app/services/backup_service.rb b/app/services/backup_service.rb index 037f519d3e..b880dfbe71 100644 --- a/app/services/backup_service.rb +++ b/app/services/backup_service.rb @@ -23,7 +23,7 @@ class BackupService < BaseService account.statuses.with_includes.reorder(nil).find_in_batches do |statuses| statuses.each do |status| item = serialize_payload(ActivityPub::ActivityPresenter.from_status(status), ActivityPub::ActivitySerializer, signer: @account) - item.delete(:'@context') + item.delete(:@context) unless item[:type] == 'Announce' || item[:object][:attachment].blank? item[:object][:attachment].each do |attachment| diff --git a/spec/controllers/auth/registrations_controller_spec.rb b/spec/controllers/auth/registrations_controller_spec.rb index 0ebf6641fa..38c003b534 100644 --- a/spec/controllers/auth/registrations_controller_spec.rb +++ b/spec/controllers/auth/registrations_controller_spec.rb @@ -178,7 +178,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do Setting.registrations_mode = 'approved' request.headers["Accept-Language"] = accept_language invite = Fabricate(:invite, max_uses: nil, expires_at: 1.hour.ago) - post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', 'invite_code': invite.code, agreement: 'true' } } + post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } } end it 'redirects to setup' do @@ -210,7 +210,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do Setting.require_invite_text = true request.headers["Accept-Language"] = accept_language invite = Fabricate(:invite, user: inviter, max_uses: nil, expires_at: 1.hour.from_now) - post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', 'invite_code': invite.code, agreement: 'true' } } + post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } } end it 'redirects to setup' do diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb index 64433ddf45..8f898ad1f6 100644 --- a/spec/controllers/auth/sessions_controller_spec.rb +++ b/spec/controllers/auth/sessions_controller_spec.rb @@ -127,7 +127,7 @@ RSpec.describe Auth::SessionsController, type: :controller do before do allow_any_instance_of(ActionDispatch::Request).to receive(:remote_ip).and_return(current_ip) - allow(UserMailer).to receive(:suspicious_sign_in).and_return(double('email', 'deliver_later!': nil)) + allow(UserMailer).to receive(:suspicious_sign_in).and_return(double('email', deliver_later!: nil)) user.update(current_sign_in_at: 1.month.ago) post :create, params: { user: { email: user.email, password: user.password } } end diff --git a/spec/lib/activitypub/activity/announce_spec.rb b/spec/lib/activitypub/activity/announce_spec.rb index e9cd6c68c1..1b34853843 100644 --- a/spec/lib/activitypub/activity/announce_spec.rb +++ b/spec/lib/activitypub/activity/announce_spec.rb @@ -82,9 +82,9 @@ RSpec.describe ActivityPub::Activity::Announce do content: 'Lorem ipsum', attributedTo: 'https://example.com/actor', to: { - 'type': 'OrderedCollection', - 'id': 'http://example.com/followers', - 'first': 'http://example.com/followers?page=true', + type: 'OrderedCollection', + id: 'http://example.com/followers', + first: 'http://example.com/followers?page=true', } } end diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index cd0f2df6e5..074aa54caa 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -252,9 +252,9 @@ RSpec.describe ActivityPub::Activity::Create do type: 'Note', content: 'Lorem ipsum', to: { - 'type': 'OrderedCollection', - 'id': 'http://example.com/followers', - 'first': 'http://example.com/followers?page=true', + type: 'OrderedCollection', + id: 'http://example.com/followers', + first: 'http://example.com/followers?page=true', } } end diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index cb60e1cb8b..cb7deb6265 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -107,23 +107,23 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do '@context': [ 'https://www.w3.org/ns/activitystreams', nil, - { 'object': 'https://www.w3.org/ns/activitystreams#object' } + { object: 'https://www.w3.org/ns/activitystreams#object' } ], - 'id': 'https://example.com/users/bob/fake-status/activity', - 'type': 'Create', - 'actor': 'https://example.com/users/bob', - 'published': '2022-01-22T15:00:00Z', - 'to': [ + id: 'https://example.com/users/bob/fake-status/activity', + type: 'Create', + actor: 'https://example.com/users/bob', + published: '2022-01-22T15:00:00Z', + to: [ 'https://www.w3.org/ns/activitystreams#Public' ], - 'cc': [ + cc: [ 'https://example.com/users/bob/followers' ], - 'signature': { - 'type': 'RsaSignature2017', - 'creator': 'https://example.com/users/bob#main-key', - 'created': '2022-03-09T21:57:25Z', - 'signatureValue': 'WculK0LelTQ0MvGwU9TPoq5pFzFfGYRDCJqjZ232/Udj4CHqDTGOSw5UTDLShqBOyycCkbZGrQwXG+dpyDpQLSe1UVPZ5TPQtc/9XtI57WlS2nMNpdvRuxGnnb2btPdesXZ7n3pCxo0zjaXrJMe0mqQh5QJO22mahb4bDwwmfTHgbD3nmkD+fBfGi+UV2qWwqr+jlV4L4JqNkh0gWljF5KTePLRRZCuWiQ/FAt7c67636cdIPf7fR+usjuZltTQyLZKEGuK8VUn2Gkfsx5qns7Vcjvlz1JqlAjyO8HPBbzTTHzUG2nUOIgC3PojCSWv6mNTmRGoLZzOscCAYQA6cKw==' + signature: { + type: 'RsaSignature2017', + creator: 'https://example.com/users/bob#main-key', + created: '2022-03-09T21:57:25Z', + signatureValue: 'WculK0LelTQ0MvGwU9TPoq5pFzFfGYRDCJqjZ232/Udj4CHqDTGOSw5UTDLShqBOyycCkbZGrQwXG+dpyDpQLSe1UVPZ5TPQtc/9XtI57WlS2nMNpdvRuxGnnb2btPdesXZ7n3pCxo0zjaXrJMe0mqQh5QJO22mahb4bDwwmfTHgbD3nmkD+fBfGi+UV2qWwqr+jlV4L4JqNkh0gWljF5KTePLRRZCuWiQ/FAt7c67636cdIPf7fR+usjuZltTQyLZKEGuK8VUn2Gkfsx5qns7Vcjvlz1JqlAjyO8HPBbzTTHzUG2nUOIgC3PojCSWv6mNTmRGoLZzOscCAYQA6cKw==' }, '@id': 'https://example.com/users/bob/statuses/107928807471117876/activity', '@type': 'https://www.w3.org/ns/activitystreams#Create', @@ -133,22 +133,22 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do 'https://www.w3.org/ns/activitystreams#cc': { '@id': 'https://example.com/users/bob/followers' }, - 'object': { - 'id': 'https://example.com/users/bob/fake-status', - 'type': 'Note', - 'published': '2022-01-22T15:00:00Z', - 'url': 'https://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=puck-was-here', - 'attributedTo': 'https://example.com/users/bob', - 'to': [ + object: { + id: 'https://example.com/users/bob/fake-status', + type: 'Note', + published: '2022-01-22T15:00:00Z', + url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=puck-was-here', + attributedTo: 'https://example.com/users/bob', + to: [ 'https://www.w3.org/ns/activitystreams#Public' ], - 'cc': [ + cc: [ 'https://example.com/users/bob/followers' ], - 'sensitive': false, - 'atomUri': 'https://example.com/users/bob/fake-status', - 'conversation': 'tag:example.com,2022-03-09:objectId=15:objectType=Conversation', - 'content': '

puck was here

', + sensitive: false, + atomUri: 'https://example.com/users/bob/fake-status', + conversation: 'tag:example.com,2022-03-09:objectId=15:objectType=Conversation', + content: '

puck was here

', '@id': 'https://example.com/users/bob/statuses/107928807471117876', '@type': 'https://www.w3.org/ns/activitystreams#Note',