Sonar not finding sources

I’m using sonar qube 8.9.10 ce.

When we run the scanner over the project (golang) we got this:

17:43:00.486 INFO: Load coverage report from '/tmp/build/4129938/project-namespace/project-name/.cover/cover.out'
17:43:00.513 DEBUG: Resolving file git.myhost.com/project-namespace/project-name/file.go using relative path
17:43:00.526 WARN: File 'git.myhost.com/project-namespace/project-name/file.go' is not included in the project, ignoring coverage

Inside the container image job, there is not path: “git.myhost.com/project-namespace/project-name/
Only: “project-namespace/project-name/”

When I checkout my sources, the CI/CD job doesn’t appends the “host” on path.

Reading this sonar source code, this looks like it should work (this code tries to resolve the real path removing the path segments until find one real path):

How can I solve this?

Hi,

Welcome to the community!

When you look at your coverage report, what do the paths look like. Do they start with git.myhost.com?

Because what I get from the warning is that they do.

:warning: Also, make sure you upgrade to SonarQube v9.9 LTS soon, not only to benefit from our Best LTS Ever™, but because soon we will systematically ask users to upgrade when they ask questions about earlier versions of SonarQube, which are now considered unsupported. :smiley:

 
Ann

Hi G, thanks for helping me…

Yes, inside the coverage report it is pointing to the complete path:

git.myhost.com/project-namespace/project-name/file.go

But my project root dir cloned is (without the host):

/tmp/build/4129938/project-namespace/project-name

Hi,

Analysis needs paths in the reports you feed it that track with the files it sees in a way it can understand. You’ll need to either make your coverage engine spit out paths that are relative to the directory you’re analyzing from (or possibly correctly absolute, altho it’s not clear to me whether absolute paths are supported in Go coverage reports) or you’ll need to pre-process the report to rectify the paths.

 
HTH,
Ann

G, I changed my “.cover/cover.out” (coverage report), to maintain the path to the sources relative to my current directory. So I removed the prefix “git. myhost.com/project-namespace/project-name/” from the coverate report file.

But I continue to get the same error:

17:43:00.486 INFO: Load coverage report from '/tmp/build/4129938/project-namespace/project-name/.cover/cover.out'
17:43:00.513 DEBUG: Resolving file file.go using relative path
17:43:00.526 WARN: File 'file.go' is not included in the project, ignoring coverage

Hi,

Starting from the directory analysis runs in, does file.go exist? I’m guessing not. I’m guessing that dir/dir/file.go exists, for some number of dirs.

The reports you feed into analysis need to have paths that analysis can understand. Analysis can’t just match file.go to any file with that name because you might have two different files named file.go in two different directories. E.G. src/client/file.go and src/server/file.go or some such.

 
HTH,
Ann

Sorry, was my fault.

My shell script was passing a wrong argument -Dsonar.inclusions=**/.*go", note the end .*go, the correct is *.go.