How to exclude files with spaces in the path in Sonar?

I am trying to exclude some auto generated code (Service References) from Sonars static code and unit test coverage analysis. The project is C# .Net and Sonar is running via Jenkins on a Windows server.

Within my sonar-project.properties file I am able to exclude various other files and directories by using the sonar.exclusions property, but this is not working for files that have a space in the path.

  • How to fetch change from Git using LibGit2Sharp?
  • Gitflow and testing / deployment
  • Where should you store 3rd party assemblies?
  • Linking Tortoise SVN revision number to assembly version
  • Windows Phone 8 app doesn't run on emulator when is under git control
  • Setting up Continuous integration and continuous deployment for Microsoft Applications
  • sonar.exclusions=**/Global.asax.cs, **/MyProject/Service References/*
    

    Given the above example the Global.asax.cs files are excluded in all projects within the solution, but the Service References are not.

    I have tried enclosing the path in single and double quotes.
    I have tried using a backslash to escape the space.
    I have tried putting the path as **/MyProject/Service*/* to take advantage of the wildcard (could be risky) but that didn’t work either.

    Does anyone have a solution for this?

  • What is the advantage of committing to the Git object database?
  • Netbeans ignoring files
  • How to retrieve all object IDs?
  • buildbot vs hudson/jenkins for C++ continuous integration
  • Code publish through jenkins for .net MVC solution in Ubuntu machine
  • Dotnet Restore Failed on Build Server
  • One Solution collect form web for “How to exclude files with spaces in the path in Sonar?”

    I just ran into the same problem. I needed to exclude javascript files in a Project, “My Project”, in a folder Scripts. I tried this first:

    **/Scripts/**/*.js
    

    And that worked fine, but I realized it would exclude a “Scripts” folder in other projects too. So I changed it to this:

    **/My Project/Scripts/**/*.js
    

    And it stopped working. My first instinct was that the space in the project name was to blame. So i tried the same things you did:

    "**/My Project/Scripts/**/*.js"
    '**/My Project/Scripts/**/*.js'
    **/My\ Project/Scripts/**/*.js
    

    but none of it worked.

    Then I stumbled upon this forum: sonarqube-archive.15.x6.nabble.com/Project-exclusions-for-Code-Coverage-not-working-C-td5023058.html

    Particularly this line provided the answer: Modules (.Net projects) are not part of the fully qualified name. You must define exclusions at module (.Net project) level.

    It means that my mistake wasn’t having a space in the project name, but including the project name at all! I changed the filter to this:

    Scripts/**/*.js
    

    and voila, the files were correctly excluded. No quotes or escaping necessary.

    Of course, this still leaves the problem that a “Scripts” folder in another project wil also be excluded. The information provided here: docs.sonarqube.org/display/SCAN/Excluding+Artifacts+from+the+Analysis may prove useful for that.

    I use the web interface, and not the configuration file directly, but this would also suggest that if you have multiple filters, that the comma-separated list should not contain spaces (other than the ones actually in the path) because they are interpreted quite literally.

    Git Baby is a git and github fan, let's start git clone.