rubocop / rubocop-rails

A RuboCop extension focused on enforcing Rails best practices and coding conventions.
https://docs.rubocop.org/rubocop-rails
MIT License
822 stars 263 forks source link

Cop idea: Rails/Env #1376

Open cdudas17 opened 1 month ago

cdudas17 commented 1 month ago

Is your feature request related to a problem? Please describe.

A problem that large Rails applications have is consistent behaviour across environments. Many application maintainers choose to solve this by using feature flags instead of environment flags for particular code behaviour.

Describe the solution you'd like

Instead of relying on env.production? or some environment in an application, we should push the dependency into an environmental config and rely on a feature flag mechanism. like if Feature.active? ... by detecting it with a Rubocop rule

Additional context

This is a custom Rubocop rule that we have ran in production for many years and is part of our initiative to open source and contribute some of our rules upstream

Fans of the 12 factor app design philosophy will find this particularly useful.