In my SonarCloud project it looks like the file exclusion is not working and causing my “lines of code” to go through the roof. I set it to exclude all .SQL files, but it’s not working. Am I missing another settings? Screenshot displays how I set it to exclude wherever there is a .SQL file.
Keep scrolling until you find Source File Exclusions
Added and no change. So, I now have “**/*.sql” in both Coverage and Source File exlusions and no change. It still adds all the code lines from my SQL files. I even deleted the project, set the exclusions again, and did a fresh scan from Azure DevOps. No change.
Is the exclusion format correct? I’m using **/*.sql to find “all” instances of .sql files.
Looks like Azure DevOps ignores these settings. I modified the DevOps pipeline to add
extraProperties: 'sonar.exclusions=**/*.sql'
and it worked.
If you want to add more properties and/or make it more readable, you can use the pipe |
character to create a new line in the yaml file, e.g.:
- task: SonarQubePrepare@5
inputs:
SonarQube: 'sonarqubeinstancename'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: 'myproject'
extraProperties: |
sonar.verbose=true
sonar.exclusions=**/*.sql
See YAML spec for more info: 8.1.2. Literal Style.
Correct. That’s exactly what I did to get it working. It’s too bad the override can’t be used in the SonarCloud website.
That should work. Can you try a test to see if the failure is true?
- Remove the
sonar.exclusions
from the azure pipeline yaml file for this project - Go to sonarcloud.io
- Go to your project > Administration > General Settings > Analysis Scope
- Take a screenshot of the “Files” section showing the
**/*.sql
setting you have saved there - Run a scan of your project (make sure
sonar.verbose=true
is set in the azure pipeline yaml) - Attach your ADO build and azure pipeline yaml for me to review to confirm