How exclude files from analysis and include on the same folder?

Hey guys. It is my first time using SonarQube and I am running it from prompt and Azure DevOps (VSTS Build). Both works fine and the results are great. Our project is based on C# .Net Framework. Our front-end project, which is an mvc project, we have a following structure for javascript files:

  • Content
    • js
      • jquery (some js files inside this folder)
      • jquery.validation (some js files inside this folder)
      • kendo.ui (some js files inside this folder)
      • jquery (some js files inside this folder)
      • … (other components folders here)
      • widgets (some js files inside this folder)
      • site.js
      • app.js
      • main.js

And for css we have a similar structure.

I want to analysis with SonarQube just the folder widgets and root files on the js folder (the bold ones). We want to ignore these components folders (jquery, kendo, etc…) and evaluate just our code. To do this, I know we have sonar.exclusions and sonar.inclusions arguments we can use but I don’t know how configure them.


But it does not work. It just ignore all files inside js folder. How can I ignore the components and how can I scan the bold ones? I was thinking to add folder by folder on the sonar.exclusions but is there any easy way to do this?

I have the same structure for css files and the same solution here will be applied to the css files as well.


  • SonarQube 7.5 Community Edition
  • SonarC# Plugin
  • Scanner for MSBuild
1 Like


Generally you don’t use exclusions and inclusions together. You might want to review the “Ignoring Files” section of this doc, but if all you want to analyze in this entire project are the files in widgets plus site.js, app.js, and main.js then set only inclusions, like so:




Thank you @ganncamp, you’re great.

Just a last question. If I keep the sonar.inclusions argument like this, will it analyse just theses files on inclusions and ignore all the rest of files like .css, .cs, .html, etc?

Maybe in this case I think I have to use sonar.exclusions to remove files (folder by folder).


It looks like you’re getting the hang of this! :wink:

If you did actually want to include all those other languages, then exclusions might be easier after all.


1 Like

A post was split to a new topic: Setting sonar scanner