Sonar is not excluding test files from analysis

Hi,
We are using Developer Editionv9.9.5 (build 90363)

We are scanning go projects from jenkins.

We are facing an issue with respect to ignoring the test files from analysis.

This is the command we are using while scanning.
sonar-scanner -Dsonar.projectKey=test-service -Dsonar.sources=. -Dsonar.exclusions=**/mocks/**,**/wire_gen.go,**/.github/**,**/tests/**,**/*_test.go,*.yml,*.yaml,*.proto,Dockerfile,*.md,*.yaml,**/*.pb.go,**/*.pb.*.go,*.mod,*.json,*.out,Makefile,LICENSE,.gitignore,*.html,*.xml,*.yml,*.yaml,*.json,*.out,*.py -Dsonar.projectVersion=latest -Dsonar.projectBaseDir=. -Dsonar.tests=. -Dsonar.test.inclusions=**/*_test*.go -Dsonar.go.coverage.reportPaths=sonar_coverage.out -Dsonar.go.tests.reportPaths=coverage.out -Dsonar.go.golangci-lint.reportPaths=golangci-report.xml -Dsonar.qualitygate.wait=true -Dsonar.qualitygate.timeout=600

We are using some dummy AWS keys as part of our test files.

We are still getting these issues in sonar as part of analysis as depicted in the screenshot in file internal/service/admin_service_test.go even the tests are excluded.

Let me know if anything is missing from our end.

Thanks

Hi,

Can you share your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Thx,
Ann

Hi Ann,

Please find the attached log file.

sonar-execution-logs.txt (11.1 KB)

Thanks

Hi,

Thanks for the log.

Your scanner version is pretty old at this point. You’re running 4.6.2 (from May 2021) and the current version is 6.1.

Can you upgrade just to eliminate that as a variable, and try again?

As a side note, I suggest streamlining your command a bit:

sonar-scanner -Dsonar.projectKey=test-and-assessment-service -Dsonar.sources=. -Dsonar.exclusions=**/mocks/**,**/wire_gen.go,**/tests/**,**/*_test.go,*.yml,*.yaml,*.proto,Dockerfile,*.md,**/*.pb.go,**/*.pb.*.go,*.mod,*.json,*.out,Makefile,LICENSE,*.html,*.xml,*.out,*.py -Dsonar.projectVersion=latest -Dsonar.tests=. -Dsonar.test.inclusions=**/*_test*.go -Dsonar.go.coverage.reportPaths=sonar_coverage.out -Dsonar.go.tests.reportPaths=coverage.out -Dsonar.go.golangci-lint.reportPaths=golangci-report.xml -Dsonar.qualitygate.wait=true -Dsonar.qualitygate.timeout=600

 
Ann