-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[java] Improve rule UnnecessaryReturn to detect more cases #3195
Conversation
Generated by 🚫 Danger |
9dac040
to
b23330d
Compare
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.
I'll mention this PR in the release notes for 7.0.0
/** | ||
* Returns true if the node is the last child of its parent (or is the root node). | ||
*/ | ||
public static boolean isLastChild(Node it) { |
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.
This might be a candidate for Node itself... But that's for a separate PR/issue (Node API)
[java] Improve rule UnnecessaryReturn to detect more cases #3195
Describe the PR
Update UnnecessaryReturn. The rule is more general than before, so I guess there will be fps to find out. But it will also be much more useful. Namely it now checks return statements in initializers, constructors, and lambdas properly. Also it doesn't flag just a return statement at the very end of a method, which is exceedingly rare and useless, but recurses to find out whether we're at the end of the control flow graph of the method. So it should handle arbitrarily complex code.
Related issues
Ready?
./mvnw clean verify
passes (checked automatically by travis)