To exclude source files during autoscan and sonar scan

I am trying to run an analysis on a project that contains code in PHP, JS, CSS, HTML. The code is present in my local machine.
The command I use to run the scan is $sonar-scanner.bat -D"sonar.projectKey=Web" -D"sonar.organization=name" -D"sonar.sources=." -D"" -D"sonar.login=eb8…"
This always fails analysis as the number of lines is more than the limit for the organisation. I need to exclude some of the files so that the analysis can be done.

How do I run the scan by excluding a list of the source files?
How do I exclude these while running an autoscan of a branch in a github reporsitory?


You can know more about exclusions in this documentation : here and here for autoscan.

Let us know if you need more details then.


1 Like

Thanks for the reference. When we exclude a folder by adding this to the scan command: “-Dsonar.exclusions=Pods/*”, the files in the folder are still scanned.
Do we need to change the command to get this working?

can you explain more
how to exclude file, cause “Dsonar.exclusions” doesn’t work