It would be great if the Rails/UnknownEnv cop allowed for configuration for custom environment names that are acceptable for the application. For example, my application supports a "performance" Rails env, thus a call to the method Rails.env.performance? should be expected.
I envision this custom configuration being a YAML array of strings.
Rubocop will not fail because there was custom configuration for the Rails/UnknownEnv cop that included the environment "performance" as a supported environment name.
Rubocop fails due to the Rails/UnknownEnv cop disallowing code that calls Rails.env.performance?.
Run rubocop on a file that includes the code Rails.env.performance?.
0.51.0 (using Parser 2.4.0.0, running on ruby 2.4.1 x86_64-darwin16)
http://rubocop.readthedocs.io/en/latest/cops_rails/#railsunknownenv
You can configure custom environments with .rubocop.yml.
For example:
Rails/UnknownEnv:
Environments:
- production
- development
- test
- performance
Take care the default environments are also needed.
This doesn't make sense! We already have a folder on config with all environments that the application has, why not use it to know what are the envs of the app?
Probably the same reason Rubocop can't look at your code and assume that that's the way you intended to write it. If you create a config/environments/wibble.rb one can argue that you still should tell Rubocop that you _meant_ to stray away from standard practice.
Most helpful comment
http://rubocop.readthedocs.io/en/latest/cops_rails/#railsunknownenv
You can configure custom environments with
.rubocop.yml.For example:
Take care the default environments are also needed.