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

Style/FetchEnvVar should not warn on method call with safe navigation #10579

Closed
jcoyne opened this issue Apr 25, 2022 · 0 comments · Fixed by #10580
Closed

Style/FetchEnvVar should not warn on method call with safe navigation #10579

jcoyne opened this issue Apr 25, 2022 · 0 comments · Fixed by #10580
Labels

Comments

@jcoyne
Copy link

jcoyne commented Apr 25, 2022

Currently ENV["VAR"].some_method is permitted. However the cop triggers if you use the safe navigation operator to call that method. I don't think it should.

So that would allow something like this:

ENV['ROLES']&.split(';')
@jcoyne jcoyne changed the title Style/FetchEnvVar should not warn on method call with Style/FetchEnvVar should not warn on method call with safe navigation Apr 25, 2022
@koic koic added the bug label Apr 25, 2022
koic added a commit to koic/rubocop that referenced this issue Apr 25, 2022
Fixes rubocop#10579.

This PR fixes a false positive for `Style/FetchEnvVar` when calling a method
with safe navigation.
bbatsov pushed a commit that referenced this issue Apr 25, 2022
Fixes #10579.

This PR fixes a false positive for `Style/FetchEnvVar` when calling a method
with safe navigation.
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