Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.28.0] Problem with ENV.fetch #10557

Closed
afuno opened this issue Apr 21, 2022 · 0 comments · Fixed by #10558
Closed

[1.28.0] Problem with ENV.fetch #10557

afuno opened this issue Apr 21, 2022 · 0 comments · Fixed by #10558
Labels

Comments

@afuno
Copy link

afuno commented Apr 21, 2022

Hello. Today updated from version 1.27.0 to version 1.28.0. Then I ran bundle exec rubocop -A and got this change:

ENV.fetch("BUNDLE_GEMFILE", nil) ||= File.expand_path("../Gemfile", __dir__)

Before rubocop, this line looked like this:

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

This code cannot work. But this code is fixed in this way only after the update.

1.28.0 (using Parser 3.1.2.0, rubocop-ast 1.17.0, running on ruby 3.1.2 aarch64-linux-musl)
  - rubocop-performance 1.13.3
  - rubocop-rails 2.14.2
  - rubocop-rspec 2.10.0
@koic koic added the bug label Apr 21, 2022
koic added a commit to koic/rubocop that referenced this issue Apr 21, 2022
Fixes rubocop#10557.

This PR fixes a false positive for `Style/FetchEnvVar`
when `ENV['key']` is a receiver of `||=`.
bbatsov pushed a commit that referenced this issue Apr 21, 2022
Fixes #10557.

This PR fixes a false positive for `Style/FetchEnvVar`
when `ENV['key']` is a receiver of `||=`.
ydah added a commit to ydah/rubocop that referenced this issue Apr 23, 2022
This PR improves the edge case of `Style/FetchEnvVar`.
There are cases that are false positive
and true negative, and it eliminates them.

false positive cases are as follows:
```ruby
ENV['X'] &&= y
```

true negative cases are as follows:
```ruby
y ||= ENV['X']
y &&= ENV['X']
```

This PR follows up on the same issue
as the Issue raised at rubocop#10557.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants