UnnecessaryThrows should not change API for protected methods#553
UnnecessaryThrows should not change API for protected methods#553
Conversation
|
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. |
Jenson3210
left a comment
There was a problem hiding this comment.
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