I’m trying to work around some issues that prevent sonarqube from scanning mynewt projects.
Forum post: Scanner skips child processes of newt project
Bug report: https://jira.sonarsource.com/browse/CPP-2372
I’ve manually copied my build commands into a bash script, and I’m at least able to run and get results from the build wrapper. If my sonar.sources is just like, ‘./apps’, then it scans everything in there. The problem is that the ‘./repos’ folder (contains mynewt kernel and some other dependencies) exceeds 1M LOC, which makes sonarqube fail due to licensing issues.
Most of the packages in the repos directory are not enabled in my build though, so the actual LOC in my project is far less.
apps/blinky <— included in build
apps/blah <— not included in build
repos/apache-mynewt-core/encoding/json/ <— included
repos/apache-mynewt-core/encoding/json/extra-stuff <— not included in build
repos/apache-mynewt-core/encoding/base64/ <— not included in build
Is it possible to get sonarqube to either only scan the files picked up by the build wrapper, or, alternatively, can I specify an exact set of source folders to be read non-recursively?
Whatever directory(ies) you’ll point at will systematically be recursively searched for sources files to analyze BUT among those files you can define some that you want to exclude (black list) or include (white list) from the scan.
This is all explained in the narrowing the focus documentation page.
From the few directories examples you gave, as an example, you would set:
There’s some more sophisticated capabilities described on the above doc link, although in your case you should be able to do what you want solely with
Hey Oliver, Glad to have your help.
I was trying the exclusions approach earlier, but it the actual mynewt-core repository is a bit too large to do that manually on a daily basis.
So, suppose I’m using that stm32f4disco BSP above. That would mean I need to exclude every folder except for that, in mynewt-core/hw/bsp, which is 63 items, and more added every month. There’s a bunch of similar situations in the drivers, compilers, etc… It’s possible to do by hand to prove it works, but not practical to do daily.
There’s also cases where I might want to include …/hal/uart, and …/hal/uart/stm32f4_uart, but not …/hal/uart/nordic_pca20020.
The mynewt RTOS uses packages. Each package has a src and include folder. When a package is added to the project, it makes it so that it will compile anything in the <pkg_dir>/src folder, and adds anything in <pkg_dir>/include to the include path.
Would I just need to add <pkg_name>/src and <pkg_name>/include to the source path if I didn’t use blacklist or whitelist?
I also tried the whitelist approach, but I was going over the 1M LOC limit. Do the files in sonar.sources that are not in the whitelist still count against the LOC limit?