Class: RuboCop::Cop::Env::Assign
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Env::Assign
- Defined in:
- lib/rubocop/cop/env/assign.rb
Overview
Rubocop Cop for Checking ENV Checks for any assignments to the ENV in tests.
When assigning to ENV you assign to a global state. This can affect other tests when you do not reassign the original value back to the ENV. This also can affect other tests when you are running tests in separate threads. This can lead to flaky and hard to find bugs in your test suite. It is much safer to mock the return value of the index getter to return the correct value.
Constant Summary collapse
- MSG =
'Mock the return value of an ENV variable instead of assigning to ENV directly.'
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
30 31 32 33 34 |
# File 'lib/rubocop/cop/env/assign.rb', line 30 def on_send(node) return unless env_assign?(node) add_offense(node) end |