-
Notifications
You must be signed in to change notification settings - Fork 90
UnnecessaryThrows should not change API for protected methods #553
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
UnnecessaryThrows should not change API for protected methods #553
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/main/resources/META-INF/rewrite/examples.yml
- lines 2337-2336
- lines 2352-2364
- lines 2801-2800
- lines 2820-2831
|
What should we do when we the code has 3 levels of inheritance? class PlainText {
// someone allows for exceptions
protected void check() throws CheckedException {
basicChecks()
}
}class ConfidentialText extends PlainText{
// someone allows for exceptions
@Override
protected void check() throws CheckedException {
advancedChecks()
}
}class TopSecret extends ConfidentialText {
// someone allows for exceptions
@Override
protected void check() throws CheckedException {
doesNotThrow()
}
}Will this not clean up the throws clause of |
|
You're right, thanks! I thought the third level would get the exceptions declared on the top level still, but turns out that's not the case. Adjusted the logic to now look for final on the method or the class on protected methods before we change the signature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/main/resources/META-INF/rewrite/examples.yml
- lines 2337-2336
- lines 2352-2364
- lines 2801-2800
- lines 2820-2831
Jenson3210
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Potentially add a C3 which does not get changed in the tests? Non final class and non final method. Although that is also covered by your original test case, it might be very clear how it behaves and what the difference is between these 3.
|
Thanks for the help improving the approach! On mobile here from the plane, so I'll merge as is 😅 |
Unnecessary throwsapache/maven#2291isOverride()rewrite#5412