makandra / makandra-rubocop

makandra's default Rubocop configuration
MIT License
6 stars 1 forks source link

Discussion: Rails/UnknownEnv #11

Closed denzelem closed 4 years ago

denzelem commented 4 years ago

https://github.com/rubocop-hq/rubocop/issues/4956 https://www.rubydoc.info/gems/rubocop/0.53.0/RuboCop/Cop/Rails/UnknownEnv

Example:

app/controllers/application_controller:14:78: C: Rails/UnknownEnv: Unknown environment staging?.
  before_action :some_action, if: -> { Rails.env.staging? }

Fix:

Rails/UnknownEnv:
  Environments:
    - production
    - development
    - test
    - staging

I would like to disable this cop, this seems not be useful for us.

denzelem commented 4 years ago

Just for documentation purpose: This cop seems to help avoiding errors like Users.delete_all unless Rails.env.producton?, because this will return false even if it is a typo.

denzelem commented 4 years ago

Changed in 6315f692c42ac9afa028824d3b10be8e23245a28 and released in 4.1.0.