Fairly new to sonar and have a question concerning the sonar.sources and sonar.exclusions in the sonar-project.properties file.
This is for a c++ project and this is the issue I am trying to resolve:
The directory structure is like the following: aLibName/db //which contains .cpp and .h files aLibName/cache // which contains .cpp and .h files and so on with the same structure
When the jenkins we have runs to build it places a /target directory under each of the directories above and copies the .cpp and .h files to it. So I end up with aLibName/db/target //which contains a DUPLICATE of the .cpp and .h files aLibName/cache/target // which contains a DUPLICATE of the .cpp and .h files and so on with the same structure
So what I end up with is a duplicate copy of the .cpp and .h files. Then my sonar scan runs and everything is duplicated with the results, like lines of code, vulnerabilities, …
I am currently getting around it as a test by doing: sonar.sources=mlib/cache,mlib/code sonar.exclusions=mlib/cache/target,mlib/code/target
which is not good… If it was just a couple directories then fine, but I dozens.
So, is there any way to do something like: sonar.sources=mlib sonar.exclusions=“any directory with the name of target”
Fairly new to sonar and have a question concerning the sonar.sources and sonar.exclusions in the sonar-project.properties file.
This is for a c++ project and this is the issue I am trying to resolve:
The directory structure is like the following: aLibName/db //which contains .cpp and .h files
aLibName/cache // which contains .cpp and .h files and so on with the same structure
When the jenkins we have runs to build it places a /target directory under each of the directories above and copies the .cpp and .h files to it. So I end up with
aLibName/db/target //which contains a DUPLICATE of the .cpp and .h files
aLibName/cache/target // which contains a DUPLICATE of the .cpp and .h files
and so on with the same structure
So what I end up with is a duplicate copy of the .cpp and .h files. Then my sonar scan runs and everything is duplicated with the results, like lines of code, vulnerabilities, …
I am currently getting around it as a test by doing:
sonar.sources=mlib/cache,mlib/code sonar.exclusions=mlib/cache/target,mlib/code/target
which is not good… If it was just a couple directories then fine, but I dozens.
So, is there any way to do something like: sonar.sources=mlib sonar.exclusions=“any directory with the name of target”
I’ll give it a try. I have had some limited success with:
sonar.exclusions=mlb//DownloadTest,mlib//target
The “target” subdirectories are excluded but it appears the “DownloadTest” ones are not. I have tried reversing the order without success. Not sure if I just comma delimit them or have multiple exclusion lines or what. I don’t get the double asterisk syntax though…
Is the mlib folder at the same level of where your scanner is launched ? Paths are relative, if mlib is one or 2 level deeper, then you should as well put 2 asterisks before. And, to correctly match the pattern, i would suggest also to add a “/*” after each directory exclusion, like,