From 2e1391fdd25627be0ff569f1f5091f4b1471a1a0 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 12 Jul 2023 04:08:51 -0400 Subject: [PATCH] Fix `Naming/MemoizedInstanceVariableName` cop (#25928) --- .rubocop_todo.yml | 13 ------------- app/controllers/api/v1/bookmarks_controller.rb | 2 +- app/controllers/api/v1/favourites_controller.rb | 2 +- app/controllers/concerns/rate_limit_headers.rb | 2 +- app/lib/activitypub/activity.rb | 4 ++-- app/services/resolve_url_service.rb | 2 +- app/services/search_service.rb | 2 +- config/initializers/rack_attack.rb | 4 ++-- 8 files changed, 9 insertions(+), 22 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 036fa37fa..9de96aa5b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -158,19 +158,6 @@ Naming/FileName: Exclude: - 'config/locales/sr-Latn.rb' -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyleForLeadingUnderscores. -# SupportedStylesForLeadingUnderscores: disallowed, required, optional -Naming/MemoizedInstanceVariableName: - Exclude: - - 'app/controllers/api/v1/bookmarks_controller.rb' - - 'app/controllers/api/v1/favourites_controller.rb' - - 'app/controllers/concerns/rate_limit_headers.rb' - - 'app/lib/activitypub/activity.rb' - - 'app/services/resolve_url_service.rb' - - 'app/services/search_service.rb' - - 'config/initializers/rack_attack.rb' - # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. # SupportedStyles: snake_case, normalcase, non_integer # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 diff --git a/app/controllers/api/v1/bookmarks_controller.rb b/app/controllers/api/v1/bookmarks_controller.rb index 0cc231840..498eb16f4 100644 --- a/app/controllers/api/v1/bookmarks_controller.rb +++ b/app/controllers/api/v1/bookmarks_controller.rb @@ -21,7 +21,7 @@ class Api::V1::BookmarksController < Api::BaseController end def results - @_results ||= account_bookmarks.joins(:status).eager_load(:status).to_a_paginated_by_id( + @results ||= account_bookmarks.joins(:status).eager_load(:status).to_a_paginated_by_id( limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id) ) diff --git a/app/controllers/api/v1/favourites_controller.rb b/app/controllers/api/v1/favourites_controller.rb index bd7f3d775..faf1bda96 100644 --- a/app/controllers/api/v1/favourites_controller.rb +++ b/app/controllers/api/v1/favourites_controller.rb @@ -21,7 +21,7 @@ class Api::V1::FavouritesController < Api::BaseController end def results - @_results ||= account_favourites.joins(:status).eager_load(:status).to_a_paginated_by_id( + @results ||= account_favourites.joins(:status).eager_load(:status).to_a_paginated_by_id( limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id) ) diff --git a/app/controllers/concerns/rate_limit_headers.rb b/app/controllers/concerns/rate_limit_headers.rb index 30702f00e..5b83d8575 100644 --- a/app/controllers/concerns/rate_limit_headers.rb +++ b/app/controllers/concerns/rate_limit_headers.rb @@ -61,7 +61,7 @@ module RateLimitHeaders end def request_time - @_request_time ||= Time.now.utc + @request_time ||= Time.now.utc end def reset_period_offset diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 5d9596254..51384ef98 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -143,11 +143,11 @@ class ActivityPub::Activity end def follow_request_from_object - @follow_request ||= FollowRequest.find_by(target_account: @account, uri: object_uri) unless object_uri.nil? + @follow_request_from_object ||= FollowRequest.find_by(target_account: @account, uri: object_uri) unless object_uri.nil? end def follow_from_object - @follow ||= ::Follow.find_by(target_account: @account, uri: object_uri) unless object_uri.nil? + @follow_from_object ||= ::Follow.find_by(target_account: @account, uri: object_uri) unless object_uri.nil? end def fetch_remote_original_status diff --git a/app/services/resolve_url_service.rb b/app/services/resolve_url_service.rb index d6e528654..19a94e77a 100644 --- a/app/services/resolve_url_service.rb +++ b/app/services/resolve_url_service.rb @@ -63,7 +63,7 @@ class ResolveURLService < BaseService end def fetch_resource_service - @_fetch_resource_service ||= FetchResourceService.new + @fetch_resource_service ||= FetchResourceService.new end def resource_url diff --git a/app/services/search_service.rb b/app/services/search_service.rb index 778ea85fb..30937471b 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -82,7 +82,7 @@ class SearchService < BaseService end def url_resource - @_url_resource ||= ResolveURLService.new.call(@query, on_behalf_of: @account) + @url_resource ||= ResolveURLService.new.call(@query, on_behalf_of: @account) end def url_resource_symbol diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb index da0b04af1..d0af0fe94 100644 --- a/config/initializers/rack_attack.rb +++ b/config/initializers/rack_attack.rb @@ -5,9 +5,9 @@ require 'doorkeeper/grape/authorization_decorator' class Rack::Attack class Request def authenticated_token - return @token if defined?(@token) + return @authenticated_token if defined?(@authenticated_token) - @token = Doorkeeper::OAuth::Token.authenticate( + @authenticated_token = Doorkeeper::OAuth::Token.authenticate( Doorkeeper::Grape::AuthorizationDecorator.new(self), *Doorkeeper.configuration.access_token_methods )