maven + Sonarqube

gresting 2020-08-05 02:39:02
环境:maven 3.6.1,sonarQube8.4.1

1. Missing blame information for the following files

我们可以通过命令或者直接在eclipse中跑sonar报告,来帮助提高代码质量和检查覆盖率等。

我们在获取sonar report的时候,在log和sonarQube页面的警告中会有"Missing blame information for the following files"的警告信息,这个是因为我们有改修或者追加的source没有存储到源代码管理中,这个和sonar-scm-git-plugin有关。
如果我们想解除这个警告,其实很简单(自己调查的时候走了很多弯路),我们只需要把本地改修的代码commit即可。

如果改修的代码不需要存储到源代码管理中,我们只需要打开sonarQube,然后在configuration中找到SCM,然后把“Disable the SCM Sensor”有效化即可(不推荐,一般我们的代码都是通过git管理的,不需要做这个处理)。


2. Bytecode of dependencies was not provided for analysis of source files, you might end up with less precise results. Bytecode can be provided using sonar.java.libraries property.

如果我们看到这个警告,我们就需要配置sonar.java.libraries,不同环境的配置方式不同,我是在maven的setting.xml配置sonar。
一般配置需要指定:
sonar.jdbc.url,
sonar.jdbc.username,
sonar.jdbc.password,
sonar.host.url,
sonar.java.binaries,
解决这个问题,我追加配置了上面说的sonar.java.libraries,在这个标签中配置commons-lang3-3.9.jar包即可。

3. sonar.jacoco.reportPaths换成sonar.coverage.jacoco.xmlReportPaths

sonarQube的最新版本中,已经不支持分析非xml的report,所以我们在升级sonarQube后,记得删除之前配置的sonar.jacoco.reportPaths,换成sonar.coverage.jacoco.xmlReportPaths去指定。

一般sonar.coverage.jacoco.xmlReportPaths有默认路径是**/target/site/jacoco/jacoco.xml,如果不需要指定新路径,我们就可以不设定这个值,使用默认的,如果我们需要重新指定新路径,可以通过sonar.coverage.jacoco.xmlReportPaths重新设定路径。
...全文
2731 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
gresting 2020-08-06
  • 打赏
  • 举报
回复
补充个图

50,526

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧