How to check if SonarLint plugin is actually analyzing my code in Eclipse?

980 views Asked by At

I have installed a SonarLint plugin in my Eclipse, and now I am trying to test it on my toy C++ project. I see no errorrs/warnings/alerts about my code, even though I deliberately made it really broken. Is there a way to check or confirm that SonarLint actually attempted to verify my source code?

This is my test program source:

struct C
{
    bool x;
    bool y;
};

int f(C c)
{
    int * p = nullptr;
    *p = 3;
    if (c.x)
        if (c.x)
            return true;
    if (c.x)
            return false;

    return *p;
}

int main()
{
    C c;
    int i = f(c);
}

I am convinced that I have installed the SonarLint plugin, because whenever I start Eclipse, I get an error message "SonarLint - Rules not available": "Some rules are not available until some requirements are satisfied". When I click on "Details", I get "Some analyzers can not be loaded.".

The Console output is the following:

Starting SonarLint for Eclipse 5.6.0.25634
Trigger: STARTUP
Clear markers on 0 excluded files
SonarLint processing file /AK GCC Test/main.cpp...
Wrote build info to: /home/andrzej/workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/AK GCC Test/org.sonarlint.eclipse.core/sonarlint18042127755659198027/build-wrapper-dump.json
Standalone mode (project not bound)
Starting analysis with configuration:
[
  baseDir: /home/andrzej/workspace/AK GCC Test
  extraProperties: {sonar.cfamily.useCache=false, sonar.cfamily.build-wrapper-output=/home/andrzej/workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/AK GCC Test/org.sonarlint.eclipse.core/sonarlint18042127755659198027}
  excludedRules: []
  includedRules: []
  ruleParameters: {}
  inputFiles: [
    file:/home/andrzej/workspace/AK%20GCC%20Test/main.cpp (UTF-8) [cpp]
  ]
]

Starting standalone SonarLint engine 5.6.0.25634...
Loading embedded analyzers...
  - /plugins/sonar-html-plugin-3.3.0.2534.jar
  - /plugins/sonar-javascript-plugin-7.0.1.14561.jar
  - /plugins/sonar-python-plugin-3.1.0.7619.jar
  - /plugins/sonar-java-plugin-6.10.0.24201.jar
  - /plugins/sonar-php-plugin-3.13.0.6849.jar
Create : /home/andrzej/.sonarlint/plugins
Plugin cache: /home/andrzej/.sonarlint/plugins
Create : /home/andrzej/.sonarlint/plugins/_tmp
Load plugins
Plugin 'JavaScript/TypeScript Code Quality and Security' requires Node.js 8.0.0. Skip loading it.
Plugin 'Java Code Quality and Security' is excluded because language 'Java' is not enabled. Skip loading it.
Load plugins (done) | time=15ms
Plugins:
  * Python Code Quality and Security 3.1.0.7619 (python)
  * HTML Code Quality and Security 3.3.0.2534 (web)
  * PHP Code Quality and Security 3.13.0.6849 (php)
Start analysis
Index files
Language of file 'file:/home/andrzej/workspace/AK%20GCC%20Test/main.cpp' is set to 'C++'
1 file indexed
'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
'Python Sensor' skipped because there is no related file in current project
Execute Sensor: HTML
Found 0 issue(s)
0 entries removed from the store
Done in 1384 ms

Based on [this bug report][1] I gather that this should not affect the SolarLint's ability to analyze my C++ code.

But when I change my code and compile the above code, I do not get any warning from SonarLint. When I right-click my project name, I get "SonarLint" item in the context menu; when I expand it, I have item "Analyze"; when I select it, "SonarLint Report" window opens, but it contains zero messages. Surely at least one bug should have been found for my above code?

Is there a way to verify what is wrong? Or if my expectations are incorrect?



  [1]: https://community.sonarsource.com/t/sonarlint-eclipse-warning-at-startup/29150
1

There are 1 answers

0
Andrzej On

Ok, I know. SonarLint does not support C++. It is other SonarSource tools that work with C++.