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

[Feature Request] Unused rescue variable name #462

Open
Blacksmoke16 opened this issue Jun 24, 2024 · 0 comments
Open

[Feature Request] Unused rescue variable name #462

Blacksmoke16 opened this issue Jun 24, 2024 · 0 comments

Comments

@Blacksmoke16
Copy link
Contributor

I recently learned in a rescue block, you do not have to provide a variable name if you do not need access to the exception instance. E.g.

begin
  raise MyException.new("OH NO!")
rescue MyException
  puts "Rescued MyException"
end

# Output: Rescued MyException

works just fine.

Similar to how ameba will flag unused local/block variables, I'm wondering if it should also flag cases like:

begin
  raise MyException.new("OH NO!")
rescue ex : MyException
  puts "Rescued MyException"
end

where the ex variable is unused, and suggest changing it to rescue MyException.

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

No branches or pull requests

2 participants