-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
SLF4J_MANUALLY_PROVIDED_MESSAGE should be able to fail even if only getMessage() and no cause #69
Comments
Wait a second, SLF4J_MANUALLY_PROVIDED_MESSAGE already does this for |
Whoa... wait, I spent some time to dig into the code (
but not this, as the README actually explains if I had RTFM:
At least in our project, this is IMHO not really what we want to check for... I can't think of a reason we would only want the So I've change this issue's title to clarify what this is now about, and create a completely separate new issue #70 re. |
@KengoTODA can the Detectors be made configurable (how, example?), or would it be simpler to just have two separate detectors / bug patterns for enforcing the getMessage() with/without cause style? |
Signed-off-by: Michael Vorburger <[email protected]>
Hm, AFAIK it is used in projects where the message of an exception contains some useful information and the code that catch the exception knows that only the message itself could be interesting but it does not make sense to log the whole stack trace etc. |
@maggu2810 yeah it seems like there are clearly different requirements in different projects. So how would you (and @KengoTODA) feel about it if I simply proposed an additional detector named e.g. |
If it make sense for projects to forbid the calling of any member function for exception in the slf4j I don't care as long as it is optional. But does your community forbid it for logging only or in general for the exception usage? How do you want to detect: final String msg = ex.getMessage();
logger.warn("Catched an error: {}", msg, ex); Wouldn't it make more sense to use PMD and its |
do you happen to know how to make a Detector excluded by default?
our main concern is for corret logging only; generally saying "thou shall never use Throwable.getMessage()" probably doesn't make sense IMHO.
I guess you cannot really, but if someone really wants to "cheat" any tool, he typically somehow always can anyway, of course?
Introducing another tool such as PMD is not that trivial in a large community... build time impact needs to be assessed, IDE support ideally needs to be guaranteed... we would rather get more out of FindBugs (SpotBugs) which, after years, we have now adopted, instead of adding more tools to the zoo... 😸 I am motivated to contribute a PR for this, after #72 is in. |
We should have a new check here which detects this kind of non-sense I'm seeing suprisingly often:
as well as
e.getStackTrace()
ande.getLocalizedMessage()
(anything else?), because I cannot really think of any good reason why you would want those methods of Exception in log args (can you?).If I find the time may be I'll contribute it in the coming days.
The text was updated successfully, but these errors were encountered: