Properties file exclude multiple paths

35.1k views Asked by At

I have a sonar-project.properties file, which specifies how sonar-runner inspects the the folder structure, which files to inspect, which files to ignore etc.

I cannot successfully determine however how to exclude multiple paths successfully.

Here is the sonar-project.properties file:

sonar.projectKey=C3S-web
sonar.projectName=C3S-sonar-web
sonar.projectVersion=0.0.1

sonar.sources=.
sonar.tests=test
sonar.language=js
sonar.profile=Sonar way
sonar.exclusions=test/*, node_modules/*
sonar.dynamicAnalysis=reuseReports

sonar.javascript.jstest.reportsPath=coverage
sonar.javascript.lcov.reportPath=coverage/lcov-report

the line I am having trouble with is:

sonar.exclusions

listing multiple paths does not work, with or without a comma, or in quotes either.

3

There are 3 answers

1
Pedro Penna On

You have to use the double asterisk pattern to recursively exclude all sub-folders and files:

sonar.exclusions=test/**, node_modules/**

A single asterisk matches only the files on that specific folder (no recursion).

0
Hamada On

If you are using Jenkinsfile

sonar: [ 

    sonarInstanceName: 'InstanceNameFolderProject', 
    sonarProperties: [
          'sonar.projectKey': 'C3S-web',
          'sonar.sources': 'yourFolderProject',
          'sonar.exclusions': 'yourFolderProject/**/*.fixture.ts, yourFolderProject/settings/_variables.ts' 
        ]],

In 'sonar.exclusions' you can exclude multiple paths.

0
Deepu Reghunath On

Following will exclude all the files in node_modules, test.ts, all modules , main.ts and the files comes under environment folder

sonar.exclusions=**/node_modules/**,**/test.ts,**/environments/**,**/**module.ts,**/main.ts