Reports not read during Go analysis

We are using the Sonar PR Scanner on branch builds within our Jenkin’s setup, but with certain Go-Lang based repositories, we are not getting any scan results to be reported.

I have mirrored my project’s scanner configuration after a coworkers other go-lang project similar to ours configurations. The errors that have been giving me issue are the following:

  • ERROR: Coverage report can’t be loaded, report file not found, ignoring this file reports/coverage.out.

  • ERROR: GoMetaLinterReportSensor: No issues information will be saved as the report file ‘/home/jenkins/workspace/aqa/integration/sonar-pr-scans/go/master/reports/lint.txt’ can’t be read.

  • WARN: GoMetaLinterReportSensor: No input file found for src/controllers/runController_test.go. No GoMetaLinter issues will be imported on this file. java.nio.file.NoSuchFileException: /home/jenkins/workspace/aqa/integration/sonar-pr-scans/go/master/reports/lint.txt

I have been thinking it has to do with the location of the reports files, but my attempts to fix this issue have not been successful.

Below are some points of info I think should give more context:

Sonar-Project.Properties:
sonar.go.gometalinter.reportPaths=reports/lint.txt
sonar.go.coverage.reportPaths=/home/jenkins/workspace/aqa/integration/sonar-pr-scans/go/master/reports/coverage.out
sonar.sources=src
sonar.coverage.exclusions=** / * .json, ** / * .js,** / * .xml

Report Generation Scripts:

…to generate the report directory…

rm -rf “$reportDir”
mkdir -p “$reportDir”

…later followed by…

junitReport=“go-junit-report > $reportDir/report.xml”
goCov=“gocov convert $reportDir/coverage.out”
goCovXml=“gocov-xml > $reportDir/coverage.xml”
goHtml=“go tool cover -html=$reportDir/coverage.out -o $reportDir/coverage.html”
chmodVol=“chmod -R a+rwx $reportDir”
genReports=“cat $reportDir/report.txt | $junitReport && $goCov | $goCovXml && $goHtml && $chmodVol”

We then later run genReports after we run our unit tests.

Hi,

Your title doesn’t seem to match the post. Is the problem that you don’t have write permissions on the directory after analysis, or that coverage isn’t being picked up by analysis?

 
Ann

Hi Ann,

I do not know if it is either of those scenarios. All I know is I do not see coverage metrics being reported, followed by the error messages I see in the console output, listed in the original post.

I have not fully considered the lack of permissions to maybe write to those files - I will investigate this today. That seems plausible, since it seems the files for the reports are found, just ignored for whatever reason.

I also have attached the reports folder containing the files used, in case that is of any help.

reports (3).zip (945.0 KB)

Hi,

I’ve updated the title.

At this point, it would be helpful to have your analysis log. E.G. the log from the Jenkins job.

 
Ann

Thank you for updating! Upload of the analysis log here

compliance_branchScan.txt (93.6 KB)

Hi,

Thanks for your log. Your original report was this:

For GoLint, I’m not sure what’s going on, but for GoMetaLinter, I find this in your log:

WARN [runner] Can't run linter goanalysis_metalinter: S1036: failed prerequisites: [inspect@_/home/jenkins/workspace/aqa/integration/sonar-pr-scans/go/branch/src/adapter: analysis skipped: errors in package: [/home/jenkins/workspace/aqa/integration/sonar-pr-scans/go/branch/src/adapter/S3Adapter.go:16:2: could not import github.com/aws/aws-sdk-go/aws (src/adapter/S3Adapter.go:16:2: cannot find package "github.com/aws/aws-sdk-go/aws" in any of:...

For coverage, I don’t see that error in this log, so I guess the problem got taken care of…?

Anyway, all 3 of the errors in your OP relate to not being able to read the reports in question. From what I’m seeing in the log, it’s a question of the reports not existing. So you need to look to the step(s) before SonarQube analysis and make sure those reports get generated.

 
HTH,
Ann