有没有办法配置 Checkstyle、PMD 或 FindBugs Maven 插件来检测这样的代码:
logger.debug("string" + stringVariable);
代替:
logger.debug("format string {}", stringVariable);
最佳答案
好问题!
我刚刚找到了一组适用于您的情况(以及更多)的 findbugs 附加规则:https://github.com/eller86/findbugs-slf4j
检查 SLF4J_FORMAT_SHOULD_BE_CONST
应该允许您在格式字符串中找到字符串连接。
关于java - 如何检测记录器语句中的字符串连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19922884/