9

I am trying to use SonarQube to scan the UI modules I have. The UI modules are lot in number. They have a common structure. Each module has its own JS files.

I need to specify the sonar.sources value to match all JS files in my project. Is it possible to do something like this?

sonar.sources=\*/*/script
sonar.language=js

I used these. But, I got an error saying something like "unable to resolve path". Can someone help?

Mig82
  • 4,856
  • 4
  • 40
  • 63
IamSan
  • 165
  • 1
  • 1
  • 6
  • 1
    check the last section here - http://docs.sonarqube.org/display/SONAR/Narrowing+the+Focus it has some examples – Techtwaddle Jun 19 '15 at 09:12

3 Answers3

13

Try to use wildcard :

*   Match zero or more characters
**  Match zero or more directories
?   Match a single character

Like this:

sonar.sources=**/script

Update

As of 2019, the sonar.sources parameter doesn't support such glob patterns. The common practice is to set this value to a list of directories that contain source code. The scanner will find traverse the directory trees and run applicable analyzers (JavaScript analyzers will consume .js files, Python analyzers will consume .py files, and so on.)

janos
  • 120,954
  • 29
  • 226
  • 236
Dams
  • 997
  • 12
  • 28
  • Is there a source/link for the updated info there about sonar.sources no longer supporting wildcard globs? I'm working in a monorepo and reeeeally trying to avoid having to specify the list of source code directories... – Aislinn Hayes Dec 05 '19 at 11:03
  • @AislinnHayes, Sorry, I no longer use sonar and I can't answer... – Dams Dec 10 '19 at 10:45
  • @AislinnHayes If you're using a monorepo I would recommend you run the scan for each different project's subdirectory in the repo, rather than once for the whole repo. You can do this by using the `sonar.projectBaseDir` property. This way you can have a different properties file for each project, each listing its own source directories. – Mig82 May 19 '20 at 14:46
  • 4
    I also searched for mention of `sonar.source` not accepting wildcards. It was confirmed by someone who works at SonarSource here: https://community.sonarsource.com/t/sonarscanner-are-wildcards-in-sonar-java-binaries-possible/154/3 But that was 1.5 years ago and their documentation still suggests that you CAN use wildcards- annoying. – Bampfer Jun 18 '20 at 15:18
0

Thanks all. I used sonar.sources=. in my properties file. This properties file is sitting next to my modules. So, now SonarQube takes into account all the folders next to this file, and scans for the specified file extensions. It works now.

Mig82
  • 4,856
  • 4
  • 40
  • 63
IamSan
  • 165
  • 1
  • 1
  • 6
0

sonar.sources does not currently support wildcard at all. This cannot be done.

Rb C
  • 21
  • 4