Different results for SonarLint 4.1.0 vs. SonarCFamily 6.1 plugin

After some time i wanted to try the current SonarLint again but so far it does not seem to work well for us:

  • SonarQube 7.6, SonarCFamily plugin 6.1, SonarLint 4.1.0.201901311043 Eclipse plugin

I updated all project bindings several times and have not changed the used Quality Profile. No errors in the SonarLint console.

Issues:

thx,
Peter

Hi @petermbauer,

is it a header file?

No, all these are implementations in .c files.

thx,
Peter

My best guess is that your project in Eclipse CDT is set in a way that it doesn’t pass properly the configuration to SonarLint making the analyzer behaving in a cascade of recovery/errors. Do you know the type of your project in Eclipse CDT?

Could you please enable SonarLint verbose log and provide me such log? Thank you.

I am using CMake and the cmake4eclipse plugin (https://github.com/15knots/cmake4eclipse) for the project.

This is the output in the SonarLint console. The mentioned build-wrapper-dump.json does not exist, not even the folder sonarlint6649437851434476700 is there.

Trigger: EDITOR_OPEN
Clear markers on 0 excluded files
SonarLint processing file /<project name>/sources/Common_Func/Com_Fl.c...
Wrote build info to: C:\Users\<username>\DS-5_Workspace_target\.metadata\.plugins\org.eclipse.core.resources\.projects\<project name>\org.sonarlint.eclipse.core\sonarlint6649437851434476700\build-wrapper-dump.json
Connected mode (using configuration of '<project name>' in server 'sonar-ee.<domain>')
Starting analysis with configuration:
[
  projectKey: <project name>
  baseDir: C:\Users\<username>\workspaces\<project>\<project name>
  workDir: C:\Users\<username>\DS-5_Workspace_target\.metadata\.plugins\org.eclipse.core.resources\.projects\<project name>\org.sonarlint.eclipse.core
  extraProperties: {sonar.cfamily.useCache=false, sonar.cfamily.build-wrapper-output=C:\Users\<username>\DS-5_Workspace_target\.metadata\.plugins\org.eclipse.core.resources\.projects\<project name>\org.sonarlint.eclipse.core\sonarlint6649437851434476700}
  inputFiles: [
    file:/C:/Users/<username>/workspaces/<project>/<project name>/sources/Common_Func/Com_Fl.c (UTF-8)
  ]
]

Available languages:
  * C => "c"
  * C++ => "cpp"
  * Objective-C => "objc"
  * Python => "py"
  * Kotlin => "kotlin"
  * RPG => "rpg"
  * PL/I => "pli"
  * T-SQL => "tsql"
  * Apex => "apex"
  * JavaScript => "js"
  * PL/SQL => "plsql"
  * Ruby => "ruby"
  * Scala => "scala"
  * Java => "java"
  * COBOL => "cobol"
  * HTML => "web"
  * JSP => "jsp"
  * XML => "xml"
  * PHP => "php"
  * TypeScript => "ts"
  * ABAP => "abap"
Start analysis
Declared extensions of language C were converted to c: **/*.disabled
Declared extensions of language C++ were converted to cpp: **/*.disabled
Declared extensions of language Objective-C were converted to objc: **/*.disabled
Declared extensions of language Python were converted to py: **/*.py
Declared extensions of language Kotlin were converted to kotlin: **/*.kt
Declared extensions of language RPG were converted to rpg: **/*.rpg,**/*.rpgle,**/*.rpg,**/*.rpgle
Declared extensions of language PL/I were converted to pli: **/*.pli
Declared extensions of language T-SQL were converted to tsql: **/*.tsql
Declared extensions of language Apex were converted to apex: **/*.cls,**/*.trigger
Declared extensions of language JavaScript were converted to js: **/*.js,**/*.jsx,**/*.vue
Declared extensions of language PL/SQL were converted to plsql: **/*.sql,**/*.pks,**/*.pkb
Declared extensions of language Ruby were converted to ruby: **/*.rb
Declared extensions of language Scala were converted to scala: **/*.scala
Declared extensions of language Java were converted to java: **/*.java,**/*.jav
Declared extensions of language COBOL were converted to cobol: 
Declared extensions of language HTML were converted to web: **/*.html,**/*.xhtml,**/*.cshtml,**/*.vbhtml,**/*.aspx,**/*.ascx,**/*.rhtml,**/*.erb,**/*.shtm,**/*.shtml
Declared extensions of language JSP were converted to jsp: **/*.jsp,**/*.jspf,**/*.jspx
Declared extensions of language XML were converted to xml: **/*.xml,**/*.xsd,**/*.xsl
Declared extensions of language PHP were converted to php: **/*.php,**/*.php3,**/*.php4,**/*.php5,**/*.phtml,**/*.inc
Declared extensions of language TypeScript were converted to ts: **/*.ts,**/*.tsx
Declared extensions of language ABAP were converted to abap: **/*.abap,**/*.ab4,**/*.flow,**/*.asprog
Index files
Language of file 'file:/C:/Users/<username>/workspaces/<project>/<project name>/sources/Common_Func/Com_Fl.c' is set to 'c'
1 files indexed
Quality profiles:
  * abap: 'Sonar way' (60 rules)
  * apex: 'Sonar way' (29 rules)
  * c: 'FW Sp 49 based on Sonar way' (110 rules)
  * cobol: 'Sonar way' (75 rules)
  * cpp: 'IFX' (313 rules)
  * java: 'Sonar way' (353 rules)
  * js: 'Sonar way' (89 rules)
  * jsp: 'FindBugs Security JSP' (0 rules)
  * kotlin: 'Sonar way' (30 rules)
  * objc: 'Sonar way' (127 rules)
  * php: 'Sonar way' (87 rules)
  * pli: 'Sonar way' (14 rules)
  * plsql: 'Sonar way' (119 rules)
  * py: 'Sonar way' (32 rules)
  * rpg: 'Sonar way' (31 rules)
  * ruby: 'Sonar way' (29 rules)
  * scala: 'Sonar way' (28 rules)
  * ts: 'Sonar way' (59 rules)
  * tsql: 'Sonar way' (54 rules)
  * web: 'Sonar way' (18 rules)
  * xml: 'Sonar way' (4 rules)
Setting filesystem encoding: UTF-8
'JavaSquidSensor' skipped because there is no related file in current project
'CobolSquidSensor' skipped because there is no related file in current project
Execute Sensor: CFamily
Using build-wrapper output: C:\Users\<username>\DS-5_Workspace_target\.metadata\.plugins\org.eclipse.core.resources\.projects\<project name>\org.sonarlint.eclipse.core\sonarlint6649437851434476700\build-wrapper-dump.json
Available processors: 4
Using 1 thread for analysis according to value of "sonar.cfamily.threads" property.
[pool-15-thread-1] C:\Users\<username>\workspaces\<project>\<project name>\sources\Common_Func\Com_Fl.c
Initializing metadata of file file:/C:/Users/<username>/workspaces/<project>/<project name>/sources/Common_Func/Com_Fl.c
[pool-15-thread-1] C:\Users\<username>\workspaces\<project>\<project name>\sources\Common_Func\Com_Fl.c:17 'Reg_flash.h' file not found
1 compilation units analyzed
'Python Squid Sensor' skipped because there is no related file in current project
'Kotlin Sensor' skipped because there is no related file in current project
'RPG sensor' skipped because there is no related file in current project
'PliSquidSensor' skipped because there is no related file in current project
'T-SQL Sensor' skipped because there is no related file in current project
'Apex Sensor' skipped because there is no related file in current project
'SonarJS' skipped because there is no related file in current project
'PL/SQL Sensor' skipped because there is no related file in current project
'Ruby Sensor' skipped because there is no related file in current project
'Scala Sensor' skipped because there is no related file in current project
Execute Sensor: JavaXmlSensor
Execute Sensor: HTML
'XML Sensor' skipped because there is no related file in current project
'PHP sensor' skipped because there is no related file in current project
'Analyzer for "php.ini" files' skipped because there is no related file in current project
'Contextual SonarTS' skipped because there is no related file in current project
'AbapSquidSensor' skipped because there is no related file in current project
Found 0 issue(s)
Done in 265 ms

You can see that Reg_flash.h is not found, that’s why you don’t get good results:

It means that eclipse is not passing the good configuration to SonarLint.
If you open Properties page for Com_Fl.c, do you see good configuration for Path and Symbols and Preprocessor Include Path?

Include dirs and so on are set in CMake only so Eclipse does not know about it (its not even a CDT Project). So it looks like this makes SonarLint useless for us.

thx,
Peter

Hi @petermbauer,

I am pretty sure that it is possible to generate Eclipse CDT project from cmake project with “good” configuration.

Hi @mpaladin,

i tried to manually add the include dirs to the Eclipse configuration, now the results are the same as in SonarQube :grinning:. I will check whether it is possible to somehow import the include directories from CMake with the cmake4eclipse plugin, otherwise these would have to be managed twice.

thank you for your help,
Peter

Hi @petermbauer,

good to know you made progress. I am not an Eclipse CDT user but I know there are multiple ways to import cmake projects, and unfortunately I don’t know what is the recommended options.

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