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
Issue #14625: fix inspection violation OptionalGetWithoutIsPresent JavaParserTest testSingleLineComment #14811
Conversation
Green inspections ci....
|
@romani , |
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.
Item:
.that(singleLineComment.isPresent()) | ||
.isTrue(); | ||
|
||
final DetailAST comment = singleLineComment.get(); |
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.
Please just use Optional#orElseThrow
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.
@nrmancuso , orElseThrow requires a Supplier argument, only default constructor is compatible.
Without arg to Ctor, we get another inspection problem NewExceptionWithoutArguments
We have to set default to NullPointerException if we want to use this method.
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.
Please see if the change is okay.
We don't have any inspection problems now :
https://app.circleci.com/pipelines/github/checkstyle/checkstyle/25317/workflows/f58f4c4d-4e4a-4371-97ca-1e215f61dbe2/jobs/581130?invite=true#step-103-4471_36
…Present JavaParserTest tAHSLCN
@MANISH-K-07 we will probably not be able to take a generic approach to this inspection unless all violations are in test classes. Any that are in test classes can be sent in one PR |
@nrmancuso , Please also see #14810 , #14814 , #14815 related to this issue I have moved TailRecursion problems to new issue like you suggested :) |
Part of #14625
Deals with one problem of OptionalGetWithoutIsPresent inspection.
https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html
https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#isPresent--
https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#get--
https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#orElseThrow-java.util.function.Supplier-