I have a variety of applications using a common code framework. The framework is compiled based on the top level Makefile configuration of the application, so not all of the code is compiled depending on the application (e.g. platform specific code). I would like to perform static code analysis on the common code framework independent of any application (its own project in SonarQube) so code clean up can be done separately.
Directory Structure
common
Makefile.inc
code
…
application
Makefile.top
code
…
Actions taken
I set up two projects in SonarQube (one for common one for application). I compile using make -f Makefile.top clean all with the build wrapper. I then have a sonar-project.properties.common and a sonar-project.properties.app configuration in the application directory from above. Once the build is done. I run the sonar scanner twice, one for each project. So only the code from the common framework that was compiled for the application will have any analysis.
Hi Ann, thank you for your response. I should have explicitly stated my question!
How would I achieve analysis on the entire common code framework independent from the applications that use it? Since the code that is compiled is configured by the application.
Analysis is based (essentially) on compilation. But assuming that across all your variants, all the code is hit at least once, then what you’re looking for is variant analysis.