C++ and cmake: Running sonar scanner on compile_commands.json

Hi,

We’re using both sonar scanner and cppcheck on C++ code. Sonar scanner requires the build-wrapper to wrap the build and listen to compiler commands which cppcheck can run based on compile_commands.json which CMake can generate without having to do a full build. This means that we can run cppcheck in parallel with the build while sonar scanner must wait for the build to complete.

We’re now wondering if it would be possible to have sonar scanner support reading compile_commands.json instead of needing to wait for the build to complete? This would bring it up to part with cppcheck in this respect.

Details on the compile_commands.json can be found here:
https://cmake.org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html

All help much appreciated.

Hi @tern-nils,

Running sonar scanner on compilation database is something we are considering.
We have a ticket for that:
https://jira.sonarsource.com/browse/CPP-1428
As of today, I cannot give you any timeline for this but at least, you can follow the progress.

In the meantime, the only thing I can suggest to minimize the overhead might be to use ccache to significantly speed up your build.

I hope this helps.

Hi @Geoffray,

Thanks for the response. We would be very happy to see this happen. It would allow parallelizing our jenkins pipelines and reducing build times quite a bit. We already use the cache fortunately - but not being able to parallelize is a real weakness in sonarqube compared to other tools we’ve used.

Cheers,
Nils