Skip to content

Commit

Permalink
update env linter for rubocop deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Dec 9, 2024
1 parent 4e7011f commit fda41ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/cops/lint/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Cop
module Lint
# This cops checks for direct usage of ENV variables and
# Rails.env
class Env < RuboCop::Cop::Cop
class Env < RuboCop::Cop::Base
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"
Expand All @@ -19,12 +19,12 @@ class Env < RuboCop::Cop::Cop
def on_const(node)
return unless env?(node)
return if allowed_env?(node.parent.children.last.children.last)
add_offense(node.parent, location: :selector, message: MSG_ENV + USAGE_MSG)
add_offense(node.parent, message: MSG_ENV + USAGE_MSG)
end

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

private
Expand Down

0 comments on commit fda41ac

Please sign in to comment.