It seems that the Rails/I18nLocaleTexts cop does not consistently detect inline locale strings in controller redirects.
In the following example, the cop correctly flags the notice message, but does not flag the alert message, even though both are inline strings and should be treated the same:
Steps to reproduce the problem
Expected behavior
Both alert and notice (and any other flash message keys) with inline strings should be flagged by Rails/I18nLocaleTexts.
Actual behavior
def update
unless @daily_revenue.unpaid?
redirect_back_or_to campaign_managers_daily_revenues_path,
alert: 'Cannot edit non-unpaid records'
return
end
# ...
end
$ rubocop app/controllers/daily_revenues_controller.rb
Inspecting 1 file
.
1 file inspected, no offenses detected
RuboCop version
$ [bundle exec] rubocop -V
1.85.1 (using Parser 3.3.10.2, Prism 1.9.0, rubocop-ast 1.49.1, analyzing as Ruby 3.4, running on ruby 3.4.8) [x86_64-linux]
- rubocop-capybara 2.22.1
- rubocop-factory_bot 2.28.0
- rubocop-migration 0.7.1
- rubocop-performance 1.26.1
- rubocop-rails 2.34.3
- rubocop-rake 0.7.1
- rubocop-rspec 3.9.0
- rubocop-rspec_rails 2.32.0
- rubocop-thread_safety 0.7.3
It seems that the
Rails/I18nLocaleTextscop does not consistently detect inline locale strings in controller redirects.In the following example, the cop correctly flags the notice message, but does not flag the alert message, even though both are inline strings and should be treated the same:
Steps to reproduce the problem
Expected behavior
Both
alertandnotice(and any other flash message keys) with inline strings should be flagged byRails/I18nLocaleTexts.Actual behavior
$ rubocop app/controllers/daily_revenues_controller.rb Inspecting 1 file . 1 file inspected, no offenses detectedRuboCop version