I came across code written by somebody which caught some exception and tried logging that as ERROR without printing stacktrace.
I expected below usage
log.error("message", exception);
However it was
log.error("message");
How to catch such coding errors by static code analyzers or any such tool?
You can use Eclipse and do a File Search over your Workspace with Regular Expression like this:
This is the best option as you will see the results in the Search panel and be able to jump to the files/lines directly with double-click.
Also a simple editor like Notepad++ can do the job with its Find in Files option with Regular expressions enabled. Unfortunately, the Notepad++ is not able to do a regex
ORlike(this|that)so to findlog.debug(...)s andlog.info(...)s you would need to replace theerrorkeyword manually. Just select the directory of your project and use a pattern like this: