0

In my sonar-project.properties file I have the following settings:

...
sonar.sources=src
sonar.exclusions=src/**/*.test.js
sonar.javascript.file.suffixes=js,jsx

However my build is failing with the following error:

ERROR: Caused by: Line 346 of report refers to a file which is not configured as a test file: /tmp/app/src/components/__tests__/filters.test.jsx

My jenkins logs report accurately that 58 files ignored because of inclusion/exclusion patterns, verified by using find . -name "*.test.js" | wc -l = 58

the same command with jsx gives me 10 results find . -name "*.test.jsx" | wc -l meaning the sonar.javascript.file.suffixes=js,jsx is not applied to the exclusions property.

How do I exclude files in my source with both .js and .jsx extensions?

agabrys
  • 8,728
  • 3
  • 35
  • 73
rakitin
  • 1,943
  • 6
  • 25
  • 51

1 Answers1

3

You did it partially correct. To exclude files you have to set sonar.exclusions. You did it, but only for js files, so the answer to your problem is:

...
sonar.sources=src
sonar.exclusions=src/**/*.test.js,src/**/*.test.jsx
sonar.javascript.file.suffixes=js,jsx

sonar.javascript.file.suffixes informs JavaScript analyzer which files contain JavaScript code. It does not influence sonar.exclusions, so you have to define all patterns by yourself.

agabrys
  • 8,728
  • 3
  • 35
  • 73