Difficulty Excluding Specific Folder and Contents in Go Project Sonar Analysis

SonarQube version: [Community Edition Version 9.9.3 (build 79811)]
Scanner: Sonar Scanner Container Image (sonarsource/sonar-scanner-cli:latest)
Deployment: SonarQube deployed via zip.
Goal: I want to exclude the /ent/** directory and its contents, but keep the /ent/schema/** directory included in the analysis.

Description:
I’m encountering an issue while performing Sonar analysis on a Go project.
I need to exclude the entire /ent/** directory except for /ent/schema/**.

I’ve tried the following configurations in my Sonar properties file, but neither has worked as expected:
This configuration excludes the entire /ent directory.

sonar.coverage.exclusions="ent/**/*", "!ent/schema/**/*"

This configuration excludes all code coverage analysis.

sonar.exclusions="ent/**/*"
sonar.inclusions="ent/schema/**/*"

Am I using the correct configuration methods to exclude the specified folder and its contents while preserving the included directory? Or are there any additional factors or configurations I should consider?

Hi,

Welcome to the community!

It’s flattering that you think we’ve implemented something so sophisticated. :sweat_smile:

In fact, we only recognize simple glob patterns here. Which means that there’s not a slick way to accomplish what you’re after.

So your best choice is probably to be more specific in what you provide to sonar.sources to include ent’s sister directories, and ent/schema.

 
HTH,
Ann

1 Like

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