Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #10569. This PR fixes a false positive for `Style/FetchEnvVar` when using the same value of `ENV` as `if` condition in the body. The `ENV` var as a `if` condition is currently allowed. So the `ENV` var already used in the condition will be accepted as well. And the following (maybe) corner case is accepted in this PR. ```ruby if ENV['foo'] ENV.delete('foo') puts 'some code' puts ENV['foo'] puts 'other code' end ``` #10569 (comment)
- Loading branch information
Showing
3 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [#10569](https://github.com/rubocop/rubocop/issues/10569): Fix a false positive for `Style/FetchEnvVar` when using the same `ENV` var as `if` condition in the body. ([@koic][]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters