SonarQube 抱怨字符串不包含格式说明符."使用 org.slf4j.Logger
时,特别是方法public void debug(String msg)
".例如
SonarQube complains about "String contains no format specifiers." when using org.slf4j.Logger
, in particular method "public void debug(String msg)
". For example
log.info("message");
参考这条规则:https://wiki.sei.cmu.edu/confluence/display/c/FIO47-C.+Use+valid+format+strings
但是,在这条规则中,我们可以找到以下引用:
However, in this rule, we can find the following quote :
每个转换规范都由 % 字符引入紧随其后(按顺序)
Each conversion specification is introduced by the % character followed (in order) by
零个或多个标志(以任何顺序),它们修改了转换规范
Zero or more flags (in any order), which modify the meaning of the conversion specification
是我遗漏了什么,还是这条规则没有很好地执行?有这方面的经验吗?
Is it me that miss something, or is this rule not well implemented? Any experience with that ?
这是 SonarJava 5.1 引入的一个已知问题.您可以放心地将此问题视为误报 (FP) 和/或忽略它.在处理 JIRA 票证 SONARJAVA-2633 时已修复此问题.
This is a known issue introduced with SonarJava 5.1. You can safely consider this issue as a False Positive (FP) and/or ignore it. It has already been fixed while handling JIRA ticket SONARJAVA-2633.
该修复程序已与 2018 年 2 月 16 日发布的 5.1.1 版 SonarJava 分析器一起提供(需要 SonarQube LTS 6.7 或更高版本).
The fix has been delivered with version 5.1.1 of SonarJava analyzer, released on Feb 16, 2018 (requires SonarQube LTS 6.7 or superior).
SonarLint 独立用户更新
对于使用独立版本(未连接到任何 SonarQube 实例)的 SonarLint 用户,您可能仍会根据所使用的版本观察到问题.如果您正在使用:
For SonarLint users working with standalone versions (not connected to any SonarQube instance), you may still observe the issue depending of the version you are using. If you are using:
这篇关于Sonarqube,“字符串不包含格式说明符"记录常量字符串消息时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!