You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've gotten accustomed to preferring if Rails.env.production? over if Rails.env == 'production' as a result of following the Rails/EnvironmentComparison rule. I noticed recently that code like this is still permissible:
caseRails.envwhen"production"fooelsebarend
This seems to violate the spirit of the rule, and also like it could be detected with static analysis.
Similarly, case statements that use pattern matching are also permitted:
I've gotten accustomed to preferring
if Rails.env.production?
overif Rails.env == 'production'
as a result of following the Rails/EnvironmentComparison rule. I noticed recently that code like this is still permissible:This seems to violate the spirit of the rule, and also like it could be detected with static analysis.
Similarly, case statements that use pattern matching are also permitted:
Perhaps this should also trigger an offense. What do you think?
Expected behavior
The examples above ought to produce Rails/EnvironmentComparison offenses.
Perhaps they could also be corrected to the equivalent
if ... else ... end
statements, but if they produced offenses that would be a good start.Actual behavior
The examples above do not produce offenses.
Steps to reproduce the problem
Write code such as the above and run rubocop.
RuboCop version
The text was updated successfully, but these errors were encountered: