diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /rubocop/cop/rspec/env_assignment.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'rubocop/cop/rspec/env_assignment.rb')
-rw-r--r-- | rubocop/cop/rspec/env_assignment.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/rubocop/cop/rspec/env_assignment.rb b/rubocop/cop/rspec/env_assignment.rb index e3075e7bd90..add7897c624 100644 --- a/rubocop/cop/rspec/env_assignment.rb +++ b/rubocop/cop/rspec/env_assignment.rb @@ -16,7 +16,9 @@ module RuboCop # before do # stub_env('FOO', 'bar') # end - class EnvAssignment < RuboCop::Cop::Cop + class EnvAssignment < RuboCop::Cop::Base + extend RuboCop::Cop::AutoCorrector + MESSAGE = "Don't assign to ENV, use `stub_env` instead." def_node_search :env_assignment?, <<~PATTERN @@ -28,11 +30,7 @@ module RuboCop def on_send(node) return unless env_assignment?(node) - add_offense(node, location: :expression, message: MESSAGE) - end - - def autocorrect(node) - lambda do |corrector| + add_offense(node, message: MESSAGE) do |corrector| corrector.replace(node.loc.expression, stub_env(env_key(node), env_value(node))) end end |