Skip to content

Add support for != comparison to Rails/UnknownEnv#1592

Merged
koic merged 1 commit intorubocop:masterfrom
lovro-bikic:unknown-env-inequality-comparison
Feb 28, 2026
Merged

Add support for != comparison to Rails/UnknownEnv#1592
koic merged 1 commit intorubocop:masterfrom
lovro-bikic:unknown-env-inequality-comparison

Conversation

@lovro-bikic
Copy link
Contributor

@lovro-bikic lovro-bikic commented Feb 28, 2026

Expands Rails/UnknownEnv so it registers offenses for unknown environment names in inequality comparisons:

Rails.env != 'proudction'
'proudction' != Rails.env

At the time of writing, there are ~1.4k search results for this pattern on GitHub.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.
  • If this is a new cop, consider making a corresponding update to the Rails Style Guide.

@@ -0,0 +1 @@
* [#1592](https://github.com/rubocop/rubocop-rails/pull/1592): Add support for `!=` comparison to `Rails/UnknownEnv`. ([@lovro-bikic][])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the nature of a linter, it would make the changelig entry easier to understand if the text began with either "Fix false positives" or "Fix false negatives", whichever is appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@lovro-bikic lovro-bikic force-pushed the unknown-env-inequality-comparison branch from c1b09ad to 436b225 Compare February 28, 2026 12:46
@lovro-bikic lovro-bikic force-pushed the unknown-env-inequality-comparison branch from 436b225 to 528699c Compare February 28, 2026 12:47
@koic koic merged commit e7d48bd into rubocop:master Feb 28, 2026
16 checks passed
@koic
Copy link
Member

koic commented Feb 28, 2026

Thanks!

@lovro-bikic lovro-bikic deleted the unknown-env-inequality-comparison branch February 28, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants