Sonarqube:缺少以下文件的责备信息
·
问题: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 信息?
解答
原因是JGit 错误。 JGit 不支持.gitattributes。我的.gitattributes中有ident。普通控制台git检查了源代码,在$Id$宏上应用了ident,但随后 JGit 忽略了这一点,并看到了一个未提交的差异,实际上并没有。
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$宏。
这是我用来删除所有$Id$宏的(Bash)代码:
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
更多推荐
所有评论(0)