SonarOpenCommunity / sonar-cxx

SonarQube C++ Community plugin (cxx plugin): This plugin adds C++ support to SonarQube with the focus on integration of existing C++ tools.
GNU Lesser General Public License v3.0
1k stars 365 forks source link

How to scan C language code through this plugin #2300

Closed preddymm closed 2 years ago

preddymm commented 2 years ago

Hello,

I am not able to scan the C language code. Can someone help me in how to scan it? I followed every instruction as shown and I am able to do it for C++ but not for C. Can someone walk through me how to do it?. I really appreciate your help here.

Thanks

guwirth commented 2 years ago

Hello @preddymm,

what exactly is not working?

  1. Please turn debug info on to get more information in the LOG file: https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Get-Debug-Information
  2. First step is to read (index) source code files: https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Scan-Source-Code. Important is to define the right file suffixes: https://github.com/SonarOpenCommunity/sonar-cxx/wiki/sonar.cxx.file.suffixes. At the end of page Scan Source Code you get help how to read the LOG file.
  3. Next step is then https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Scan-Report-Files

Hope this helps!

Regards,

preddymm commented 2 years ago

Hello @guwirth,

Thanks for your quick response. I am trying to integrate the SonarQube with Jenkins server. When I try using this plugin for C++ code it was bale to identify the C++ code and able to scan. When I follow the same steps to scan the C code, it is not able to identify the C code. I tried using this extensions as well in sonar.properties file "sonar.cxx.file.suffixes=.c,.h" and I made the File changes in SonarQube server as well. I am not sure is there any specific things to do to scan the C code. Please help me out.

Thanks

guwirth commented 2 years ago

Hello @preddymm,

I’m sorry can’t help you without getting more information. Please create LOG files and provide the error messages.

Regards,

preddymm commented 2 years ago

Could you provide me some documentation on what steps do I need to follow only on targeting the C language?

Thanks,

preddymm commented 2 years ago

Hi,

This plugin was not bale to identify the C and C++ code.

I have included this sonar properties as well sonar.sources=/var/jenkins_home/jobs/bbu-sonar-2/workspace sonar.sourceEncoding=UTF-8 sonar.cxx.file.suffixes=.cxx,.cpp,.cc,.c,.hxx,.hpp,.hh,.h sonar.verbose=true

I also enabled the file suffixes in SonarQube UI for all the langauges by following this wiki page https://github-wiki-see.page/m/SonarOpenCommunity/sonar-cxx/wiki/sonar.cxx.file.suffixes

Sample debug file.txt

I also attached the sample debug file as per your suggestion. Could you please get back to me ASAP.

Thanks