SonarScanner is not importing GolangCI-linter report.xml file

I am using:

  • SonarQube version 9.9.1 - Community Edition
  • SonarScanner version 4.8
  • golangCI-lint version 1.53.1

SonarQube is deployed locally through Docker

PS! I have tried this with Alpine Linux Docker container and with M1 Macbook with macOS Ventura version 13.1 + I have followed the whole documentation about the process and tried every solution provided by the community posts

I am trying to import report.xml file that is created by GolangCI-linter with --out-format checkstyle flag.
Here is Makefile for it:

tests:
	@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.53.1 && cd bin/ && \
        ./golangci-lint run ../app --issues-exit-code 0 --out-format checkstyle > report.xml
	@/Users/krister.riska/Desktop/programming/repos/test_repo/sonar-scanner-4.8.0.2856/bin/sonar-scanner

Here is the sonar-project.properties:

sonar.login=test
sonar.projectKey=test
sonar.go.golangci-lint.reportPaths=bin/report.xml
sonar.host.url=http://localhost:9000
sonar.go.exclusions=**/vendor/**
sonar.sources=.

Here is the report.xml file:

<?xml version="1.0" encoding="UTF-8"?>

<checkstyle version="5.0">
  <file name="../app/main.go">
    <error column="13" line="14" message="unusedresult: result of fmt.Sprintf call not used" severity="error" source="govet"></error>
  </file>
</checkstyle>

And here is the sonar-scanner log about the error:

INFO: Importing /Users/krister.riska/Desktop/programming/repos/test_repo/bin/report.xml
ERROR: No issue information will be saved as the report file '/Users/krister.riska/Desktop/programming/repos/test_repo/bin/report.xml' can't be read.
java.lang.NullPointerException: null
        at org.sonar.api.batch.fs.internal.predicates.AbsolutePathPredicate.apply(AbsolutePathPredicate.java:46)
        at org.sonar.api.batch.fs.internal.predicates.OrPredicate.apply(OrPredicate.java:60)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
        at java.base/java.util.HashMap$ValueSpliterator.tryAdvance(Unknown Source)
        at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.lambda$initPartialTraversalState$0(Unknown Source)
        at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(Unknown Source)
        at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(Unknown Source)
        at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(Unknown Source)
        at java.base/java.util.Spliterators$1Adapter.hasNext(Unknown Source)
        at org.sonar.api.batch.fs.internal.DefaultFileSystem.inputFile(DefaultFileSystem.java:112)
        at org.sonar.scanner.scan.filesystem.MutableFileSystem.inputFile(MutableFileSystem.java:53)
        at org.sonarsource.slang.externalreport.CheckstyleFormatImporter.onFileElement(CheckstyleFormatImporter.java:120)
        at org.sonarsource.slang.externalreport.CheckstyleFormatImporter.onElement(CheckstyleFormatImporter.java:107)
        at org.sonarsource.slang.externalreport.CheckstyleFormatImporter.importFile(CheckstyleFormatImporter.java:93)
        at org.sonarsource.slang.plugin.AbstractPropertyHandlerSensor.lambda$executeOnFiles$1(AbstractPropertyHandlerSensor.java:84)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
        at org.sonarsource.slang.plugin.AbstractPropertyHandlerSensor.executeOnFiles(AbstractPropertyHandlerSensor.java:82)
        at org.sonarsource.slang.plugin.AbstractPropertyHandlerSensor.execute(AbstractPropertyHandlerSensor.java:74)
        at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
        at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
        at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:403)
        at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:399)
        at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:368)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
        at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at com.sun.proxy.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Let me know if I can provide any more information or if I can try anything :slight_smile:

When I removed cd /bin/ it started importing.

1 Like

Hi @riskakrister,

I am glad you could find a solution to this path mismatch issue. To increase the reach of the fix you proposed, did you follow these initial instructions from a tutorial that would benefit from this information? It might be worth it to let other people know.

Cheers,

Dorian

I think the best place to mention would be the Importing third-party issues section, where Golangci-linter is(just a notification that Golangci-linter should be run in the root of the repository)

In the link it is 9.7 version SonarQube, but I tested it with 10.0 too

1 Like

Thank you @riskakrister , I will make sure we update the documentation with this information.

Cheers,

Dorian

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.