Sonarqube for C/Cpp and java src files

cpp

(Nitish Goel) #1

I have a project which has source files of java, c and cpp.
I have set up a jenkins job which does analysis but it is only doing java files.
How to make it enable for c and cpp files also? I have set the below properties

sonar.projectKey=xxx:ddi-destiny
sonar.projectName=xxx
sonar.projectVersion=1.0
sonar.branch=1.0
#sonar.verbose=true
sonar.sourceencoding=UTF-8


sonar.projectBaseDir=sonar/ddi-ng/

# path to source directories (required)
sonar.sources= xxx

thanks,
Nitish Goel


(G Ann Campbell) #2

Hi Nitish,

All files recognized by your SonarQube instance will automatically be included in analysis. The fact that C/C++ files aren’t being recognized means that you don’t have an analyzer for C/C++ loaded. SonarCFamily (which allows you to analyze C/C++ and Objective-C) is available with Developer Edition($) and above.

Ann


(Nitish Goel) #3

Thanks Campbell.

Is there any other way instead of having “SonarCFamily” ?
Any properties like “sonar.lang.patterns.c=” not sure how to use it?
Or any plugin which can help in analyzing all 3 src files together?


(Loïc Joly) #4

I’m not sure what you mean there. To analyze C++ code, you need to have access to the C++ analyzer plugin, which is called SonarCFamily. There is no way around that.

Now, assuming you have access to this plugin, you need some additional information if you want a meaningful analysis. C and C++ are languages that greatly depend on configuration (mostly include path & macros), so we need this configuration to correctly analyze it.

In order to provide us this information, you should use the build wrapper tool. For more information, you can go on this page and especially in step 2, follow the link related to your environment, where the use of the build wrapper is explained.