Missing blame information for the following files

12,014 views
Skip to first unread message

Amedee Van Gasse

unread,
May 25, 2016, 4:51:10 AM5/25/16
to SonarQube
I am getting "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

I am using SonarQube 5.5, analysis is done by Maven in a Jenkins job, on a multi-module Java project.
Git plugin 1.2 is installed.

Manually running git blame in a bash shell, on any of the offending files, gives an expected output.

Julien HENRY

unread,
May 25, 2016, 8:18:48 AM5/25/16
to SonarQube
Hi,

Can you please test with JGit command line tool so that we know if this is a JGit issue:

++

Julien

Amedee Van Gasse

unread,
May 25, 2016, 9:19:35 AM5/25/16
to SonarQube
There are multiple JGit versions listed on https://repo.eclipse.org/content/groups/releases/org/eclipse/jgit/org.eclipse.jgit.pgm/. Git Plugin 1.2 corresponds with JGit 4.2.0:

4.2.0.201511101648-m1/Tue Nov 10 17:35:59 EST 2015 
4.2.0.201512141825-rc1/Mon Dec 14 19:48:49 EST 2015 
4.2.0.201601211800-r/Thu Jan 21 18:07:35 EST 2016

I used 4.2.0.201601211800-r, guessing that "r" would stand for "release".

Executing this in the Jenkins workspace:
    ~/org.eclipse.jgit.pgm-4.2.0.201601211800-r.sh blame -w /path/to/offending/file
gives me an expected outcome, ie blame information.

Amedee Van Gasse

unread,
May 25, 2016, 9:39:16 AM5/25/16
to SonarQube
I also tried with JGit 4.4.0.201605041135-m1, that also worked.

Is there any option or switch I can give to SonarQube, to enable extra debugging information?

Julien HENRY

unread,
May 26, 2016, 2:53:17 AM5/26/16
to SonarQube
You can try to enable debug logs (-X with Maven) to see the precise command that is executed for each file.

Amedee Van Gasse

unread,
May 26, 2016, 5:06:40 AM5/26/16
to SonarQube
What I found:

[WARN] [10:32:46.014] Missing blame information for the following files:
[DEBUG] [10:35:23.477] Unable to blame file src/main/java/com/********.java. No blame info at line 2. Is file committed? [Author: PersonIdent[Not Committed Yet, , Thu May 26 10:35:23 2016 +0200] Source commit: null]

When I look at that file at line 2, I see this:

    $Id: f66aa1b4aa410cb3ad9e93166ddb2addeb026505 $

While on GitLab, it has this:

    $Id$

During checkout, $Id$ gets transformed to a hash by the magic of the .gitattributes file:
*.java text eol=lf ident

and when a .java file is committed, any line with $Id: <hash> $ gets transformed back into $Id$.

I consider it a bug in Jgit blame that it does not respect .gitattributes. When running the plain console "git blame -w", line 2 is shown as the original $Id$.

My question now is, how do I move forward? Apparently it's not a SonarQube bug but a JGit bug. Will SonarQube report this bug or do I need to do it myself, and if so, where do I do that?

Julien HENRY

unread,
May 26, 2016, 5:21:58 AM5/26/16
to SonarQube
Hi,

Problem already reported but it seems to be stuck:

Is there a way to tell Git to not process ident during checkout on your job doing the SonarQube analysis so that files are not marked as dirty?

I have created a ticket to track progress on this topic:

++

Julien

Amedee Van Gasse

unread,
May 26, 2016, 5:33:02 AM5/26/16
to SonarQube


On Thursday, May 26, 2016 at 11:21:58 AM UTC+2, Julien HENRY wrote:
Hi,

Problem already reported but it seems to be stuck:

Is there a way to tell Git to not process ident during checkout on your job doing the SonarQube analysis so that files are not marked as dirty?

I wouldn't know. I'm going to ask it on StackOverflow but I don't have high hopes.

I think I'd be better off just dropping all the $Id$ lines and get rid of the ident macro. It's legacy cruft from SVN anyway.

I have created a ticket to track progress on this topic:

Thank you 

Amedee Van Gasse

unread,
May 26, 2016, 5:54:17 AM5/26/16
to SonarQube


On Thursday, May 26, 2016 at 11:33:02 AM UTC+2, Amedee Van Gasse wrote:


On Thursday, May 26, 2016 at 11:21:58 AM UTC+2, Julien HENRY wrote:
Hi,

Problem already reported but it seems to be stuck:

Is there a way to tell Git to not process ident during checkout on your job doing the SonarQube analysis so that files are not marked as dirty?

I wouldn't know. I'm going to ask it on StackOverflow but I don't have high hopes.

Julien HENRY

unread,
May 26, 2016, 7:43:06 AM5/26/16
to SonarQube
See my crazy suggestion on SO ;)

Amedee Van Gasse

unread,
May 26, 2016, 8:33:21 AM5/26/16
to SonarQube
I bit the bullet and did this:

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

Not looking back. No regrets. Git blame info is now visible in SQ.

ben.c...@gmail.com

unread,
Oct 19, 2016, 10:48:11 AM10/19/16
to SonarQube
If it's a jgit issue what can be done? For some reason I'm getting this issue on one project but not the other. Both projects use git.

This is the jgit output.
$ /c/org.eclipse.jgit.pgm-4.2.0.201601211800-r.sh blame -w GRP2App/GRP2App.EF/So                                                                                                                                                                                               rItem.cs
java.lang.NullPointerException
        at org.eclipse.jgit.blame.BlameGenerator.getSourceStart(BlameGenerator.j                                                                                                                                                                                               ava:870)
        at org.eclipse.jgit.blame.BlameResult.loadFrom(BlameResult.java:338)
        at org.eclipse.jgit.blame.BlameResult.computeAll(BlameResult.java:240)
        at org.eclipse.jgit.blame.BlameResult.computeRange(BlameResult.java:294)
        at org.eclipse.jgit.pgm.Blame.run(Blame.java:195)
        at org.eclipse.jgit.pgm.TextBuiltin.execute(TextBuiltin.java:199)
        at org.eclipse.jgit.pgm.Main.execute(Main.java:246)
        at org.eclipse.jgit.pgm.Main.run(Main.java:138)
        at org.eclipse.jgit.pgm.Main.main(Main.java:110)

Can the blame plugin be disabled for one project and not the other?

It seems to be something specific with this file. jgit blame works correctly files in the same project, even the same folder. 

ben.c...@gmail.com

unread,
Oct 19, 2016, 11:48:36 AM10/19/16
to SonarQube
Just to add to the frustration jgit blame for the offending file works fine on my local machine, it only fails on the build server.

matad...@googlemail.com

unread,
Oct 20, 2016, 4:50:47 AM10/20/16
to SonarQube, ben.c...@gmail.com
That seems strange. If you're sure they are using the exact same version of JGit perhaps you could try attaching to the remote runner on the server to debug? e.g. if you are using the maven runner use mvndebug then connect to this host / port

Ben Crinion

unread,
Oct 20, 2016, 5:10:35 AM10/20/16
to matad...@googlemail.com, SonarQube
The build is a Microsoft TFS build agent. I can probably increase the log level of the sonarqube instance.

pennyf...@gmail.com

unread,
Sep 19, 2017, 4:16:00 AM9/19/17
to SonarQube
Can the blame plugin be disabled for one project and not the other?


Yes, that is possible. Just set

sonar.scm.disabled=true

within your SonarQube project or the sonar-project.properties file.
Reply all
Reply to author
Forward
0 new messages