Fix Performance/DeletePrefix cop (#24796)
parent
05e3abe9d9
commit
668a19a2f3
|
@ -303,21 +303,6 @@ Performance/CollectionLiteralInLoop:
|
|||
- 'config/deploy.rb'
|
||||
- 'lib/mastodon/media_cli.rb'
|
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: SafeMultiline.
|
||||
Performance/DeletePrefix:
|
||||
Exclude:
|
||||
- 'app/controllers/authorize_interactions_controller.rb'
|
||||
- 'app/controllers/concerns/signature_verification.rb'
|
||||
- 'app/controllers/intents_controller.rb'
|
||||
- 'app/lib/activitypub/case_transform.rb'
|
||||
- 'app/lib/permalink_redirector.rb'
|
||||
- 'app/lib/webfinger_resource.rb'
|
||||
- 'app/services/activitypub/fetch_remote_actor_service.rb'
|
||||
- 'app/services/backup_service.rb'
|
||||
- 'app/services/resolve_account_service.rb'
|
||||
- 'app/services/tag_search_service.rb'
|
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Performance/MapCompact:
|
||||
Exclude:
|
||||
|
|
|
@ -59,7 +59,7 @@ class AuthorizeInteractionsController < ApplicationController
|
|||
end
|
||||
|
||||
def uri_param
|
||||
params[:uri] || params.fetch(:acct, '').gsub(/\Aacct:/, '')
|
||||
params[:uri] || params.fetch(:acct, '').delete_prefix('acct:')
|
||||
end
|
||||
|
||||
def set_body_classes
|
||||
|
|
|
@ -244,7 +244,7 @@ module SignatureVerification
|
|||
end
|
||||
|
||||
if key_id.start_with?('acct:')
|
||||
stoplight_wrap_request { ResolveAccountService.new.call(key_id.gsub(/\Aacct:/, ''), suppress_errors: false) }
|
||||
stoplight_wrap_request { ResolveAccountService.new.call(key_id.delete_prefix('acct:'), suppress_errors: false) }
|
||||
elsif !ActivityPub::TagManager.instance.local_uri?(key_id)
|
||||
account = ActivityPub::TagManager.instance.uri_to_actor(key_id)
|
||||
account ||= stoplight_wrap_request { ActivityPub::FetchRemoteKeyService.new.call(key_id, id: false, suppress_errors: false) }
|
||||
|
|
|
@ -9,7 +9,7 @@ class IntentsController < ApplicationController
|
|||
if uri.scheme == 'web+mastodon'
|
||||
case uri.host
|
||||
when 'follow'
|
||||
return redirect_to authorize_interaction_path(uri: uri.query_values['uri'].gsub(/\Aacct:/, ''))
|
||||
return redirect_to authorize_interaction_path(uri: uri.query_values['uri'].delete_prefix('acct:'))
|
||||
when 'share'
|
||||
return redirect_to share_path(text: uri.query_values['text'])
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ module ActivityPub::CaseTransform
|
|||
when Symbol then camel_lower(value.to_s).to_sym
|
||||
when String
|
||||
camel_lower_cache[value] ||= if value.start_with?('_:')
|
||||
"_:#{value.gsub(/\A_:/, '').underscore.camelize(:lower)}"
|
||||
"_:#{value.delete_prefix('_:').underscore.camelize(:lower)}"
|
||||
else
|
||||
value.underscore.camelize(:lower)
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ class PermalinkRedirector
|
|||
end
|
||||
|
||||
def path_segments
|
||||
@path_segments ||= @path.gsub(/\A\//, '').split('/')
|
||||
@path_segments ||= @path.delete_prefix('/').split('/')
|
||||
end
|
||||
|
||||
def find_status_url_by_id(id)
|
||||
|
|
|
@ -57,7 +57,7 @@ class WebfingerResource
|
|||
end
|
||||
|
||||
def resource_without_acct_string
|
||||
resource.gsub(/\Aacct:/, '')
|
||||
resource.delete_prefix('acct:')
|
||||
end
|
||||
|
||||
def local_username
|
||||
|
|
|
@ -67,7 +67,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
|
|||
end
|
||||
|
||||
def split_acct(acct)
|
||||
acct.gsub(/\Aacct:/, '').split('@')
|
||||
acct.delete_prefix('acct:').split('@')
|
||||
end
|
||||
|
||||
def supported_context?
|
||||
|
|
|
@ -100,7 +100,7 @@ class ResolveAccountService < BaseService
|
|||
end
|
||||
|
||||
def split_acct(acct)
|
||||
acct.gsub(/\Aacct:/, '').split('@')
|
||||
acct.delete_prefix('acct:').split('@')
|
||||
end
|
||||
|
||||
def fetch_account!
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class TagSearchService < BaseService
|
||||
def call(query, options = {})
|
||||
@query = query.strip.gsub(/\A#/, '')
|
||||
@query = query.strip.delete_prefix('#')
|
||||
@offset = options.delete(:offset).to_i
|
||||
@limit = options.delete(:limit).to_i
|
||||
@options = options
|
||||
|
|
Loading…
Reference in New Issue