SonarLint for IntelliJ CLion header files excluded: compiler kind not found

When using Analyze All Project Files using Sonar Lint, many of my header files are not included in the analysis due to compiler kind not found error. The associated .cpp files on the other hand are correctly included in the analysis.

All my files are C++ code. One way for SonarLint to be able to include them is to open the file in the IDE. For example, opening the dg_base.hpp will lead to it being correctly included in the analysis. There are maybe 200 header files distributed amongst many folder, so opening all of them is not exactly feasible. (Note, you may notice both .h and .hpp in the files, the codebase is inconsistent with file naming, they are all C++).

I have tried resetting the IDE through all the steps of “Repair IDE” as well with no success.

When I Ctrl+Shift+S on a directory, the same header files will not be included unless I have them open in my IDE. However, opening a single file, and Ctrl+Shift+S-ing will lead to the successful analysis of this file.

Another thing worth noting is that SonarCloud correctly detects all the relevant header files.

I am looking for a solution to include all project files.

Environment:

  • Java: JetBrains s.r.o. 17.0.8
  • OS: Linux amd64
  • IDE: CLion 2023.2.2
  • SonarLint: 9.0.0.75308
Trigger: ALL
[ALL] 500 file(s) submitted
File 'drdx.cpp' excluded: OCFile:drdx.cpp not in project sources
com.jetbrains.cidr.lang.preprocessor.OCInclusionContextUtil$getResolveRootAndActiveConfiguration not found
File 'dg_base.hpp' excluded: compiler kind not found
File 'weak_dg.hpp' excluded: compiler kind not found
File 'strong_dg.hpp' excluded: compiler kind not found
File 'dg_factory.hpp' excluded: compiler kind not found
File 'dg_base_state.hpp' excluded: compiler kind not found
File 'artificial_dissipation.h' excluded: compiler kind not found
File 'artificial_dissipation_factory.h' excluded: compiler kind not found
File 'gaussian_bump.h' excluded: compiler kind not found
File 'spline_channel.h' excluded: compiler kind not found
File 'naca_airfoil_grid.hpp' excluded: compiler kind not found
File 'wavy_periodic_grid.hpp' excluded: compiler kind not found
File 'curved_periodic_grid.hpp' excluded: compiler kind not found
File 'straight_periodic_cube.hpp' excluded: compiler kind not found
...
File 'convective_numerical_flux.hpp' excluded: compiler kind not found
File 'physics_post_processor.h' excluded: compiler kind not found
File 'field.h' excluded: compiler kind not found
File 'gnu_out.h' excluded: compiler kind not found
File 'msh_out.h' excluded: compiler kind not found
File 'gmsh_out.h' excluded: compiler kind not found
File 'size_field.h' excluded: compiler kind not found
File 'grid_refinement.h' excluded: compiler kind not found
File 'reconstruct_poly.h' excluded: compiler kind not found
File 'grid_refinement_uniform.h' excluded: compiler kind not found
File 'grid_refinement_continuous.h' excluded: compiler kind not found
File 'grid_refinement_fixed_fraction.h' excluded: compiler kind not found
File 'global_counter.hpp' excluded: compiler kind not found
File 'codi_DirectionVar.hpp' excluded: OCFile:codi_DirectionVar.hpp not in project sources
File 'Makefile' excluded: file is ignored in VCS
File 'airfoil.msh' excluded: file is ignored in VCS
File '2D_square.msh' excluded: file is ignored in VCS
File '3D_square.msh' excluded: file is ignored in VCS
File '3D_CUBE_2ndOrder.msh' excluded: file is ignored in VCS
File '3d_cube_periodic.msh' excluded: file is ignored in VCS
File '3d_gaussian_bump.msh' excluded: file is ignored in VCS
File 'channel_structured.msh' excluded: file is ignored in VCS
File 'naca0012_hopw_ref2.msh' excluded: file is ignored in VCS
File 'SD7003_1_cell_spanwise.msh' excluded: file is ignored in VCS
File 'SD7003_4_cell_spanwise.msh' excluded: file is ignored in VCS
File 'SD7003_12_cell_spanwise.msh' excluded: file is ignored in VCS
File 'explicit_ode_solver.cpp' excluded: OCFile:explicit_ode_solver.cpp not in project sources
File 'advection_explicit_periodic.cpp' excluded: OCFile:advection_explicit_periodic.cpp not in project sources
File '4_point_flux.cpp' excluded: OCFile:4_point_flux.cpp not in project sources
File 'chain_rule_test.cpp' excluded: OCFile:chain_rule_test.cpp not in project sources
File 'weighted_int_by_parts.cpp' excluded: OCFile:weighted_int_by_parts.cpp not in project sources
File 'metric_split_form_gradient.cpp' excluded: OCFile:metric_split_form_gradient.cpp not in project sources
File 'weight_adjusted_mass_inverse_test.cpp' excluded: OCFile:weight_adjusted_mass_inverse_test.cpp not in project sources
File 'assert_compare_array.h' excluded: compiler kind not found
File 'assert_compare_array.h' excluded: compiler kind not found
File 'LastTest.log' excluded: file is ignored in VCS
Found plugin: sonar-text-plugin-2.3.0.1632.jar
Found plugin: sonar-iac-plugin-1.20.0.5654.jar
Found plugin: sonar-go-plugin-1.14.0.4481.jar
Found plugin: sonar-python-plugin-4.7.0.12181.jar
Found plugin: sonar-html-plugin-3.9.0.3600.jar
Found plugin: sonar-javascript-plugin-10.5.1.22382.jar
Found plugin: sonar-xml-plugin-2.10.0.4108.jar
Found plugin: sonar-java-plugin-7.24.0.32100.jar
Found plugin: sonarlint-omnisharp-plugin-1.13.0.76953.jar
Found plugin: sonar-kotlin-plugin-2.17.0.2902.jar
Found plugin: sonar-php-plugin-3.32.0.10180.jar
Found plugin: sonar-cfamily-plugin-6.48.0.62520.jar
Found plugin: sonar-ruby-plugin-1.14.0.4481.jar
Plugin 'Kotlin Code Quality and Security' is excluded because language 'Kotlin' is not enabled. Skip loading it.
Plugin 'Go Code Quality and Security' is excluded because language 'Go' is not enabled. Skip loading it.
Plugin 'JavaScript/TypeScript/CSS Code Quality and Security' is excluded because none of languages 'CSS,JavaScript,TypeScript,YAML' are enabled. Skip loading it.
Plugin 'Python Code Quality and Security' is excluded because none of languages 'IPython Notebooks,Python' are enabled. Skip loading it.
Plugin 'C# Code Quality and Security (Omnisharp)' is excluded because language 'C#' is not enabled. Skip loading it.
Plugin 'XML Code Quality and Security' is excluded because language 'XML' is not enabled. Skip loading it.
Plugin 'Java Code Quality and Security' is excluded because language 'Java' is not enabled. Skip loading it.
Plugin 'IaC Code Quality and Security' is excluded because none of languages 'CloudFormation,Docker,Kubernetes,Terraform' are enabled. Skip loading it.
Plugin 'Ruby Code Quality and Security' is excluded because language 'Ruby' is not enabled. Skip loading it.
Plugin 'HTML Code Quality and Security' is excluded because none of languages 'HTML,JSP' are enabled. Skip loading it.
Plugin 'PHP Code Quality and Security' is excluded because language 'PHP' is not enabled. Skip loading it.
Loaded 2 plugins
  * CFamily Code Quality and Security 6.48.0.62520 (cpp)
  * Text Code Quality and Security 2.3.0.1632 (text)
Skipping section 'introduction' for rule 'S6336', content is empty
Skipping section 'introduction' for rule 'S6290', content is empty
Skipping section 'introduction' for rule 'S6334', content is empty
Skipping section 'introduction' for rule 'S6335', content is empty
Skipping section 'introduction' for rule 'S6337', content is empty
Skipping section 'introduction' for rule 'S6292', content is empty
Creating container for module 'Module: 'PHiLiP''
Configuring analysis with org.sonarlint.intellij.clion.CFamilyAnalysisConfigurator
Analysing 299 files...

Hi @Doug1 ,

what is the CLion project type? Are you importing the project through CMake, Makefile, or the Compilation Database?

As you can see in https://github.com/SonarSource/sonarlint-intellij/blob/bf0ec162dc2619ddcbc03589bd1701db8200bf2f/clion/src/main/java/org/sonarlint/intellij/clion/AnalyzerConfiguration.java#L96-L100 we rely on CLion to provide us files configuration. It is indeed strange that when you open a file you get a configuration and that when you try to analyze the full project you are not able to get a configuration.

Would you be able to craft a little hello world project to reproduce the issue you are facing?