问题描述
包有以下 package-info.java:
Package has following package-info.java:
@ParametersAreNonnullByDefault
package foo;
import javax.annotation.ParametersAreNonnullByDefault;
类有如下方法:
private static String toIsoString(@Nullable Instant dateTime) {
return dateTime == null ? null : dateTime.toString();
}
SonarQube(版本 6.2,SonarJava 4.14.0.11784)给出以下警告(squid:S2583):
On which SonarQube (Version 6.2, SonarJava 4.14.0.11784) gives the following warning (squid:S2583):
如何让 SonarQube 相信代码实际上是正确的?
How can I convince SonarQube that the code is actually correct?
有趣的是,Idea 中的 SonarLint 插件 (3.0.0.2041) 不会生成相同的警告.
Interestingly, SonarLint plugin (3.0.0.2041) in Idea doesn't generate the same warning.
推荐答案
显然,这个问题是由于我们使用 sonar-scanner 没有指定 sonar.java.libraries.由于它是多模块 maven 项目,我们不清楚如何正确指定 sonar.java.libraries.
Apparently, this problem was caused by us using sonar-scanner without specifying sonar.java.libraries. Since it's multimodule maven project it wasn't clear to us how to specify sonar.java.libraries correctly.
来自 SonarSource 的 Nicolas Peru 建议我们应该使用 sonar maven 插件,而不是 sonar-scanner,因为该插件可以访问项目的构建类路径.确实为我们解决了这个问题.
Nicolas Peru, from SonarSource, suggested that we should use sonar maven plugin, instead of sonar-scanner, as the plugin has access to build classpath of the project. Indeed that solved this problem for us.
这篇关于@Nullable 和 SonarQube '有条件执行的块应该可以访问' 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)