summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Jankowski <matt@jankowski.online>2023-12-15 09:34:24 -0500
committerGitHub <noreply@github.com>2023-12-15 14:34:24 +0000
commite5717c9bc6cb5a1bea4c93048024f6247566f8ce (patch)
tree56f454c332f59109fe2f92f7165416dba82c120b
parent1ee8d1e50e2e113af63348c6d16ee5cface22e33 (diff)
Fix `Style/Lambda` cop (#28378)
-rw-r--r--.rubocop_todo.yml8
-rw-r--r--config/initializers/simple_form.rb2
-rw-r--r--config/routes.rb10
3 files changed, 6 insertions, 14 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 03cc2e75d35..c323aa877b4 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -386,14 +386,6 @@ Style/InverseMethods:
- 'app/services/update_account_service.rb'
- 'spec/controllers/activitypub/replies_controller_spec.rb'
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: line_count_dependent, lambda, literal
-Style/Lambda:
- Exclude:
- - 'config/initializers/simple_form.rb'
- - 'config/routes.rb'
-
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/MapToHash:
Exclude:
diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb
index 6d9d7b8aeb3..a8bc4b19211 100644
--- a/config/initializers/simple_form.rb
+++ b/config/initializers/simple_form.rb
@@ -164,7 +164,7 @@ SimpleForm.setup do |config|
# config.item_wrapper_class = nil
# How the label text should be generated altogether with the required text.
- config.label_text = lambda { |label, required, _explicit_label| "#{label} #{required}" }
+ config.label_text = ->(label, required, _explicit_label) { "#{label} #{required}" }
# You can define the class to use on all labels. Default is nil.
# config.label_class = nil
diff --git a/config/routes.rb b/config/routes.rb
index 150b26cf1ed..85c3b18556e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -51,7 +51,7 @@ Rails.application.routes.draw do
get 'health', to: 'health#show'
- authenticate :user, lambda { |u| u.role&.can?(:view_devops) } do
+ authenticate :user, ->(user) { user.role&.can?(:view_devops) } do
mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
mount PgHero::Engine, at: 'pghero', as: :pghero
end
@@ -105,10 +105,10 @@ Rails.application.routes.draw do
}
# rubocop:disable Style/FormatStringToken - those do not go through the usual formatting functions and are not safe to correct
- get '/users/:username', to: redirect_with_vary('/@%{username}'), constraints: lambda { |req| req.format.nil? || req.format.html? }
- get '/users/:username/following', to: redirect_with_vary('/@%{username}/following'), constraints: lambda { |req| req.format.nil? || req.format.html? }
- get '/users/:username/followers', to: redirect_with_vary('/@%{username}/followers'), constraints: lambda { |req| req.format.nil? || req.format.html? }
- get '/users/:username/statuses/:id', to: redirect_with_vary('/@%{username}/%{id}'), constraints: lambda { |req| req.format.nil? || req.format.html? }
+ get '/users/:username', to: redirect_with_vary('/@%{username}'), constraints: ->(req) { req.format.nil? || req.format.html? }
+ get '/users/:username/following', to: redirect_with_vary('/@%{username}/following'), constraints: ->(req) { req.format.nil? || req.format.html? }
+ get '/users/:username/followers', to: redirect_with_vary('/@%{username}/followers'), constraints: ->(req) { req.format.nil? || req.format.html? }
+ get '/users/:username/statuses/:id', to: redirect_with_vary('/@%{username}/%{id}'), constraints: ->(req) { req.format.nil? || req.format.html? }
# rubocop:enable Style/FormatStringToken
get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }