Class: RuboCop::Cop::Lint::Env
- Inherits:
-
Cop
- Object
- Cop
- RuboCop::Cop::Lint::Env
- Defined in:
- lib/jets/rubocop/cop/lint_env.rb
Overview
This cops checks for direct usage of ENV variables and Rails.env
Constant Summary collapse
- MSG_ENV =
"Avoid direct usage of ENV in application code"
- MSG_RAILS_ENV =
"Avoid direct usage of Rails.env in application code"
- USAGE_MSG =
", use configuration parameters instead"
Instance Method Summary collapse
Instance Method Details
#on_const(node) ⇒ Object
21 22 23 24 |
# File 'lib/jets/rubocop/cop/lint_env.rb', line 21 def on_const(node) return unless env?(node) add_offense(node.parent, location: :selector, message: MSG_ENV + USAGE_MSG) end |
#on_send(node) ⇒ Object
26 27 28 29 |
# File 'lib/jets/rubocop/cop/lint_env.rb', line 26 def on_send(node) return unless rails_env?(node) add_offense(node.parent, location: :selector, message: MSG_RAILS_ENV + USAGE_MSG) end |