Skip to content

Rails/I18nLocaleTexts false negative when using alert or notice in redirect_back_or_to #1595

Description

@ydakuka

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions