Class: RuboCop::Cop::Neeto::DirectEnvAccess
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Neeto::DirectEnvAccess
- Defined in:
- lib/rubocop/cop/neeto/direct_env_access.rb
Overview
‘config/secrets.yml` provides a single source of truth for all environment variables and their fallback values, loaded via Rails’ built-in ‘config_for`. Direct usage of `ENV` bypasses this system, making it harder to track what environment variables are being used and their defaults. This cop enforces that all environment variable access goes through `Rails.application.secrets`.
Constant Summary collapse
- MSG =
"Do not use ENV directly. " \ "Use Rails.application.secrets to maintain a single source of truth for configuration."
Instance Method Summary collapse
Instance Method Details
#on_const(node) ⇒ Object
39 40 41 42 43 |
# File 'lib/rubocop/cop/neeto/direct_env_access.rb', line 39 def on_const(node) return unless env_access?(node) add_offense(node) end |