Sonar.exclusions is only excluding typescript and javascript files for me

SonarQube - * Version 8.9 (build 43852)
Scanner used from Azure DevOps extension in cli mode

Error: Your project contains .java files, please provide compiled classes with property, or exclude them from the analysis with sonar.exclusions property.

These files are being picked up from my node_modules folder. However I had added node_modules to my exclusions as shown at the bottom of this.

Only typescript and javascript files seem to be ignored if they are in node_modules:

File newProject/node_modules/aws-cdk/lib/api/util/display.js was excluded by sonar.javascript.exclusions or sonar.typescript.exclusions

Other files are indexed:
newProject/node_modules/aws-cdk/lib/init-templates/v1/sample-app/java/src/main/java/com/myorg/' indexed with language 'java'

My intention is to exclude all of the node_modules folder, but I cannot figure out why this is so.

I have the following configuration in the azure devops extension, i had to add
sonar.javascript.node.maxspace as node was running out of memory during the scan.

- task: SonarQubePrepare@4


    SonarQube: Shell Energy Sonarqube
    scannerMode: CLI
    configMode: manual
    cliProjectKey: '${{ parameters.ProjectKey }}'
    cliProjectName: $(Build.DefinitionName)
    cliProjectVersion: $(Build.BuildID)
    cliSources: .
    extraProperties: |

      sonar.exclusions="**/node_modules/**/*","**/coverage/**/*", "**/coveragereport/**/*" , "dts-tooling-templates/**/*", "**/dist/**/*", "**/out/**/*"


      sonar.javascript.node.maxspace: 8192


Welcome to the community!

When you use sonar.exclusions as an analysis parameter (I recommend setting it through the UI) the value is expected to be a comma-delimited list. And on the face of it, that’s what you’ve provided. But the values in the list are expected to be paths or path strings - not quoted paths. I would eliminate extraneous quotes and spaces and try again.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.