class RuboCop::Cop::Lint::NoENV

@example

# bad
ENV[]

# bad
ENV.fetch(..)

# good
GetEnv[]

# good
GetEnv.fetch(...)

Constants

MSG

Public Instance Methods

autocorrect(node) click to toggle source
# File lib/rubocop/cop/lint/no_env.rb, line 31
def autocorrect(node)
  lambda do |corrector|
    if Gem::Version.new(RuboCop::Version.version) >= Gem::Version.new('0.82.0')
      corrector.replace(node, 'GetEnv')
    else
      corrector.replace(node.loc.expression, 'GetEnv')
    end
  end
end
on_const(node) click to toggle source
# File lib/rubocop/cop/lint/no_env.rb, line 24
def on_const(node)
  parent = node.parent
  return unless is_ENV_index?(parent) || is_ENV_fetch?(parent)

  add_offense(node)
end