GuardLogStatementJavaUtil should not apply to SLF4J Logger
A source code analyzer
Brought to you by:
adangel,
juansotuyo
The GuardLogStatementJavaUtil rule fires for every log event for an org.slf4j.Logger instance -- but since SLF4J Logger's intentionally do lazy evaluation on the logging statements, adding guards is not necessary.
This rule should not apply to org.slf4j.Logger instances.
This will be fixed with PMD 5.3.2 (commit: https://github.com/pmd/pmd/commit/a0d116ca6d205a1ef65bbf02c50ceec84277a2f7)
The rule will ignore any classes, which import something from slf4j. Please note, that your statement is only true, if you use message parameters ("{}") - otherwise you would fall back to string concatenation and this would be done before calling the log method - and then a guard would be necessary.