From a263110799c420982030fffdef2e044a826cad89 Mon Sep 17 00:00:00 2001 From: Neal Chambers Date: Tue, 1 Aug 2023 10:01:40 +0900 Subject: [PATCH] Safely autocorrect Rails/DotSeparatedKeys Inspecting 1481 files ........................................................................C................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ Offenses: app/controllers/api/v1/base_controller.rb:72:66: C: [Corrected] Rails/DotSeparatedKeys: Use the dot-separated keys instead of specifying the :scope option. message = I18n.t(:missing_parameter, param: error.param, scope: :api) ^^^^^^^^^^^ app/controllers/api/v1/base_controller.rb:79:84: C: [Corrected] Rails/DotSeparatedKeys: Use the dot-separated keys instead of specifying the :scope option. message = I18n.t(:unpermitted_parameters, params: error.params.join(", "), scope: :api) ^^^^^^^^^^^ 1481 files inspected, 2 offenses detected, 2 offenses corrected --- .rubocop_todo.yml | 6 ------ app/controllers/api/v1/base_controller.rb | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9fd43b1e0a..ab39868802 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -478,12 +478,6 @@ Rails/CompactBlank: - 'lib/reporting/report_ruler.rb' - 'lib/reporting/reports/enterprise_fee_summary/parameters.rb' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Rails/DotSeparatedKeys: - Exclude: - - 'app/controllers/api/v1/base_controller.rb' - # Offense count: 27 # This cop supports safe autocorrection (--autocorrect). Rails/DurationArithmetic: diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb index cc62b6978f..2cf59888fb 100644 --- a/app/controllers/api/v1/base_controller.rb +++ b/app/controllers/api/v1/base_controller.rb @@ -69,14 +69,14 @@ module Api end def missing_parameter(error) - message = I18n.t(:missing_parameter, param: error.param, scope: :api) + message = I18n.t('api.missing_parameter', param: error.param) render status: :unprocessable_entity, json: json_api_error(message) end def unpermitted_parameters(error) - message = I18n.t(:unpermitted_parameters, params: error.params.join(", "), scope: :api) + message = I18n.t('api.unpermitted_parameters', params: error.params.join(", ")) render status: :unprocessable_entity, json: json_api_error(message)