Class: RuboCop::Cop::Lint::Env

Inherits:
Cop
  • Object
show all
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



23
24
25
26
# File 'lib/jets/rubocop/cop/lint_env.rb', line 23

def on_const(node)
  return unless env?(node)
  add_offense(node.parent, location: :selector, message: MSG_ENV + USAGE_MSG)
end

#on_send(node) ⇒ Object



28
29
30
31
# File 'lib/jets/rubocop/cop/lint_env.rb', line 28

def on_send(node)
  return unless rails_env?(node)
  add_offense(node.parent, location: :selector, message: MSG_RAILS_ENV + USAGE_MSG)
end