Repository navigation
Replies: 1 comment
|
PMD 7.27.0 will include a new rule UnusedReturnValue which will do this. Thanks for the suggestion! |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello,
In SLF4J 2, which is a very common and widespread java logging facade api, there are functions that are meant to fluently create new logging statements.
https://www.slf4j.org/api/org/slf4j/Logger.html see atDebug, atError, atWarning, atInfo, atTrace, atLevel
Those are very convenient, and allow to use closures to compute what to display only if the message has to be logged.
Common usage is like:
A very common error is to forget the ending
log()call.With code like:
you can spend an enormous amount of time wondering why your expected logging statement is not in the output.
If PMD could detect that the
org.slf4j.spi.LoggingEventBuilderreturned by the lastaddArgument()is neither used bylog()nor stored in a variable, we could catch this kind of errors before runtime.All reactions