File exclusion not working

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.

1 Like

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
    SonarQube: 'sonarqubeinstancename'
    scannerMode: 'CLI'
    configMode: 'manual'
    cliProjectKey: 'myproject'
    extraProperties: |

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?

  1. Remove the sonar.exclusions from the azure pipeline yaml file for this project
  2. Go to
  3. Go to your project > Administration > General Settings > Analysis Scope
  4. Take a screenshot of the “Files” section showing the **/*.sql setting you have saved there
  5. Run a scan of your project (make sure sonar.verbose=true is set in the azure pipeline yaml)
  6. Attach your ADO build and azure pipeline yaml for me to review to confirm