Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How detect string concatenation in logger statements?

Is there a way to configure the Checkstyle, PMD, or FindBugs Maven plugins to detect code like this:

logger.debug("string" + stringVariable);

Instead of:

logger.debug("format string {}", stringVariable);
like image 749
Cherry Avatar asked Nov 12 '13 07:11

Cherry


1 Answers

Excellent question!

I' ve just found a collection of additional rules for findbugs which covers your case (and some more): https://github.com/eller86/findbugs-slf4j

Check SLF4J_FORMAT_SHOULD_BE_CONST should allow you to find string concatenation inside format string.

like image 112
Slava Semushin Avatar answered Oct 03 '22 00:10

Slava Semushin