Sonarqube:缺少以下文件的责备信息

新手上路,请多包涵

在 SonarQube 分析期间,我收到警告 Missing blame information for the following files

 [INFO] [22:19:57.714] Sensor SCM Sensor
[INFO] [22:19:57.715] SCM provider for this project is: git
[INFO] [22:19:57.715] 48 files to be analyzed
[INFO] [22:19:58.448] 0/48 files analyzed
[WARN] [22:19:58.448] Missing blame information for the following files:
(snip 48 lines)
[WARN] [22:19:58.449] This may lead to missing/broken features in SonarQube
[INFO] [22:19:58.449] Sensor SCM Sensor (done) | time=735ms

我正在使用 SonarQube 5.5,分析是由 Maven 在 Jenkins 工作中在一个多模块 Java 项目中完成的。安装了 Git 插件 1.2。

在 bash shell 中对任何有问题的文件手动运行 git blame 会得到预期的输出。

我发现的相关问题都是关于 SVN 的,我的问题是 Git。

我如何在 Sonarqube 上获取 git blame 信息?

原文由 Amedee Van Gasse 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 2.9k
2 个回答

原因是 JGit 错误。 JGit 不支持 .gitattributes 。我有 ident 在我的 .gitattributes 。普通控制台 git 检查了源代码,应用了 ident$Id$ 宏,但是 JG不是一个。

SonarQube 邮件列表 上的友好人员帮助了我,并建议使用 [独立的 JGit 命令行分发](http://docs.sonarqube.org/display/PLUG/Git+Plugin#GitPlugin-Howtoinvestigateerrorduringblame(onlypossibleonUnix/Linux) 进行调试:

 chmod +x /where/is/org.eclipse.jgit.pgm-<version>-r.sh
/where/is/org.eclipse.jgit.pgm-<version>-r.sh blame -w /path/to/offending/file

这个特殊的 JGit 错误已经 5 年多没有解决了,我不希望它会很快解决,所以我从我所有的来源中删除了 $Id$ 宏。

这是我使用的 (Bash) 代码,用于删除所有 $Id$ 宏:

 find */src -name "*.java" | xargs -n 1 sed -i '/$Id.*$/d'
find */src -name "*.java" | xargs git add
git commit -m "Remove $Id$ macros"
git push

原文由 Amedee Van Gasse 发布,翻译遵循 CC BY-SA 3.0 许可协议

我在 Sonar 升级后停止工作的构建遇到了这个问题。

对我来说,问题是 Jenkins 作业被配置为在从 git 拉取时进行浅克隆。这并没有引入足够的历史记录,因此 Sonar 5.6.6 无法进行分析,因为浅拷贝中未包含责备信息。我在运行 Sonar 时使用了 -X 选项来查看它阻塞的实际提交号。

我是我的情况,我只是取消选中浅拷贝复选框 和 BAM,它再次工作(虽然更慢)! 在此处输入图像描述

原文由 neoscribe 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题