- Operating system: Linux Debian 9
- SonarLint plugin version: V3.10.0
- Programming language you’re coding in: Language C
- Is connected mode used:
- Connected to SonarCloud or SonarQube (and which version):
SonarQube connected mode
Version: I don’t know but it is very recent release (installed in my company this year)
And a thorough description of the problem / question:
Hi everyone, I have a project written in language C with the following attributes
. the source code is saved in a GIT environment
. it is compiled using a GCC compiler with a private tool chain NOT integrated to VScode
. I use VS code for editing, get and commit the C files in the GIT repository of the company
. we have a GITLab environment which is synchrosided with a SonarQube server in order to analyse the source codeand provide report of Quality code
. ===> means each time I push a C file modification in GIT, the GITlab (via a pipeline) triggers a SonarQube analysis
What I would like to do : instead of waiting for the report of sonarqube following a push in GIT, I would like to have the analysis “on the fly” of ly source code using the rules of the Sonaqube server.
For that in my Vscode (Linux-debian 9, VScode : 1.71.2)
. I installed Sonarlinte extension (V3.10.0)
. I follow the instruction for connecting to Sonarqube server : all has been done
connected mode OK (using URL of sonarqube server + token)
I specified my local folder to bind with the remote project in sonarqube server
I provided a compile_commands.json
I launch (CTRL+SHIFT+P) : Sonarlint : bind all workspace folders to SonarQube or Sonarcloud ==> VSCODE told me "my workspace was bound to the SonarQube server "
So all looks like to done properly, but nothing happens : I have no notifications in the source code (and not in the tab “problem” either) related to sonarqube report
What is missing ???
Important information the C project is not compiled inside the IDE but outside
SonarLint checks the file you’re in as you’re coding. It’s not designed to give you a full project analysis.
Hello @Laurent.78 and welcome to the Sonar community!
As Ann said above, SonarLint is designed to analyze on-the-fly the file(s) you’re currently editing in VSCode. Do you manage to visualize issues for the currently opened file?
Hello Marco and Ann.
First of all, thanks a lot for for answers
This is exactly I would like to do : analyze on-the-fly the file(s) I am editing in VScode , independently of the full project analysis performed by the sonarqube server.
The idea woud be to have an
. "on-the-fly- analysis of the source code modified based on the Sonarqube rules (ideally)
. in order to avoid to push in my GIT repository each time a make a modification of a file, for triggering a full project analysis in my remote Sonarqube server, to get just a report of my file modified …
“Do you manage to visualize issues for the currently opened file?” ==> Unfortunately not Marco, I can not visualize anything in Vscode related to Sonarlint checking
Reminder : Very important : my project is written in langage C
Hello @Laurent.78 and thanks for the details.
on-the-fly- analysis of the source code modified based on the Sonarqube rules (ideally)
This is exactly what SonarLint should provide in connected mode with SonarQube. And yes, SonarLint supports C analysis in VSCode, as long as you provide the compile_commands.json.
In order for our teams to investigate, could you please capture the full logs that SonarLint generates when you open a C file in your project and send them to us (you can see here our to do it).
Hello Marco, this is Laurent again
please find the log in the file attached
SonarLint_log.txt (5 KB)
Hope I followed the right process for providing to you consistent informations.
Thanks a lot for the precious time you spent for me.
I am touched
Thanks for the detailed log.
It looks like you are trying to analyze
home/user/workspace/integ_offline_backup/voice/src/voice/voip/iwf/sip/sip_multiport.c that doesn’t have a compilation database entry. Right? How are you generating the compilation database? Does the analysis work for files that has a compilation database entry?
Can you share the compilation database that you are using for your project? Do you confirm that it’s have entries that describe how to compile your project? for more details have a look at “Make Sure that the Compilation Database is Credible”.
Wahouuuuuu. It is working !!! The analysis on the Fly is incredible
Abbas, Marco, Ann thanks a lot for your precious and efficient help. The pb was very simple and related to the path of The Gcc compiler which was not complete in the compile.commands.json
For fixing that I followed The advice regarding the fact The Line spécified for the « commands« folder Must be exécuted successfully MANUALLY
THE ACTIVATION of The sonarlint Log suggested by Marco is really super usefull !!!
The fact I can now see in real Time The report of sonarqube and fix immédiately The bugs is a incrédible and allows me to working much faster
Thanks a lot to all of you
I am happy to hear you problem is solved! We would also appreciate if you have two minutes to review SonarLint on the VSCode Marketplace. Enjoy coding with SonarLint!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.