Only Analyze Files from Build Wrapper Output

Hello,

Sonar analyzes all files in the project directory. However, I only want to analyze the files from the Build Wrapper Output (and the files included from those files). All other files are not relevant to the project and must not be analyzed.
If I set
sonar.exclusions=**
no file is analyzed.

How can I configure the Scanner to only analyze the files from the Build Wrapper Output?

Hi,

Welcome to the community!

You’re right; by default, every recognized file in the project is analyzed.

And yes, setting a global exclusion (i.e. **) will exclude… everything. Globally in the project.

To exclude the files you don’t want analyzed, you have multiple options:

  • narrow sonar.sources to only the paths with files of interest
  • if the ‘extra’ files are scattered throughout, then you’ll need to either
    • exclude them by file extension, e.g. sonar.exclusions=**/*.js, **/*.html
    • make them ‘unrecognized’ by overriding the file extensions, e.g. sonar.javascript.file.suffixes=.foo, `sonar.html.file.suffixes=.bar’

 
HTH,
Ann