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

Auto correcting substitues a rescued Exception with a blind rescue #1343

Closed
rousisk opened this issue Sep 22, 2014 · 5 comments
Closed

Auto correcting substitues a rescued Exception with a blind rescue #1343

rousisk opened this issue Sep 22, 2014 · 5 comments

Comments

@rousisk
Copy link

rousisk commented Sep 22, 2014

I completely agree with avoiding rescuing the Exception class but I think that auto correcting this:

rescue Exception => e

to

rescue => e

might be an issue, as the two are not equivalent (and in a not so obvious way for that matter).

Personally, when I use the auto correct feature (mostly for older projects) I am under the assumption that there won't be any behavioural changes and ideally nothing will break.

What do you think on that?

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 22, 2014

Hmm, that's a bug. rescue => e is equivalent to rescue StandardError => e.

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 22, 2014

On second thought - it's not. The idea is we want to replace the Exception with StandardError. While this is not equivalent it's unlikely to cause problems in practice.

@mikegee
Copy link
Contributor

mikegee commented Sep 22, 2014

@rousisk Lint/RescueException is the applicable cop. You will want to disable it in your .robocop.yml or with a source comment.

@rousisk
Copy link
Author

rousisk commented Sep 22, 2014

Thanks @mikegee, it's not a big issue anymore. I was just auto-correcting an existing, large, project and I started seeing test failures due to this substitution. That's the reason I perceived it as surprising or "not so safe". But totally agree with the underlying principle.

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 23, 2014

This issue is related to #950. Ideally, the cop won't do auto-corrections by default unless non-equivalent corrections are allowed.

@bbatsov bbatsov closed this as completed in a4f5b25 Nov 3, 2014
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

3 participants