No SonarLint C/C++ analysis in CLion

Please provide

  • Operating system: macOS 12.4 (on Apple Silicon)
  • SonarLint plugin version: 6.7.0.45926
  • CLion 2022.1.2 Build #CL-221.5787.29
  • Is connected mode used: Connected to SonarQube Developer Edition Version 9.2.4 (build 50792)

I have a fairly large legacy C codebase that I’ve loaded in CLion as a compile_comands.json project. If I open any .c file SonarLint says “No analysis done on the current opened file” with an additional warning that says “This file is not automatically analyzed - Some files are not automatically analyzed. Check the SonarLint debug logs for details.”

It’s not clear to me if the Log tab in the SonarLint panel is the “debug logs”, but it says:

Plugin 'secrets' embeds dependencies. This will be deprecated soon. Plugin should be updated.
Cannot start the SonarLint server on 64120
Server started on 64121
Sync quality profiles...
Downloaded plugin list in 31ms
[SYNC] Synchronizing analyzer configuration for project 'project-name'
Downloaded settings in 27ms
[SYNC] Active rules for 'c' are up-to-date
[SYNC] Active rules for 'cpp' are up-to-date
[SYNC] Synchronizing project branches for project 'project-name'

Pressing the green “play” button in the SonarLint tab does not appear to do anything.

I have the project bound to a SonarQube project, and the binding appears to work properly (it authenticates and gives me the expected list of projects to choose from). I do not get any SonarLint results whether the project is bound our not though.

If I create a toy (one source file) CMake project SonarLint does appear to work properly for the toy project.

FWIW I’m also able to use the SonarLint VS Code plugin in VS Code in my legacy C codebase as expected. I think that I’ve had SonarLint working in CLion with this codebase sometime in the last 6 months, but I can’t be certain as I’ve had to switch computers and IDE’s a couple times.

Hey there.

Welcome to our community! You can turn on verbose logging here.

Thanks for the reply, the verbose logging doesn’t tell me much more unfortunately, after turning it on and triggering an analysis again I get this:

Trigger: ACTION
[Action] 1 file(s) submitted
File 'theFile.c' excluded: OCFile:theFile.c not in project sources

AFAICT the project is working in CLion. Is it expecting a sonar-project.properties or do I need to explicitly point it at the compile_commands.json somehow?

Hello Nick,

This thread looks similar but was left unanswered.

Could you try to reload your CMake project? Is the source file part of the project and part of a target executable/library?

If it’s still not working, could you send us a small reproducer project so that we can have a closer look ?

Thanks

EDIT: and to answer your questions, SonarLint relies only on the CLion project to find files to analyze. It does not rely on sonar-project.properties or compilation database files.

It’s not a CMake project, it’s a large legacy project with a Makefile and a compile_commands.json generated using bear. The source file is part of the project. AFAICT SonarLint won’t analyze any file in the project, not just specific source files.

I tried deleting the .idea directory and reopening the project as a Compilation Database project. In the “sync” tab I see several messages like “Found several commands for file: …” and “Compilation database project successfully imported” however, CLion hung before fully opening the project.

I uninstalled SonarLint, deleted the .idea directory and again tried reopening the project as a Compilation Database project. The results were the same as above, including CLion hanging.

I reinstalled SonarLint, deleted the .idea directory and tried reopening the project as a Makefile project. This succeeded and SonarLint appears to be analyzing files again.

At this point, I do not believe the problem is with SonarLint, rather with CLion handling of Compilation Database projects. I think this case can be closed.

FWIW I’m not able to reproduce the problem with a small project.

1 Like

Thanks for the feedback, I appreciate :slight_smile:

I will close this thread, feel free to open another one if you need more help.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.