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

False positive Lint/UselessAssign #468

Open
Blacksmoke16 opened this issue Aug 20, 2024 · 0 comments
Open

False positive Lint/UselessAssign #468

Blacksmoke16 opened this issue Aug 20, 2024 · 0 comments

Comments

@Blacksmoke16
Copy link
Contributor

Blacksmoke16 commented Aug 20, 2024

hash = {"foo" => "bar"}

def call(v)
end

unless v = hash["foo"]?
  call v = "default"
end

v

Results in:

[W] Lint/UselessAssign: Useless assignment to variable `v`
> unless v = hash["foo"]?

The assignment is for sure not useless as it handles assigning v if that key is present in the hash, otherwise is assigned within the unless block.

Creating a new issue as unlike #447, this doesn't require any type declarations or macros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant