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
This commit is contained in:
Neal Chambers
2023-08-01 10:01:40 +09:00
parent 44cf2faa1e
commit a263110799
2 changed files with 2 additions and 8 deletions

View File

@@ -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:

View File

@@ -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)