I need to analyze C# sources using SonarLint for CommandLine tool (sonarlint-cli-2.1-RC1).
I am expecting a set of issues to be captured as same as from SonarScanner (sonar-scanner-3.0.3.778-windows & sonarqube-6.5), it logged as: No issues to display (26 files analyzed)
When I invoked the SonarLint with -u, it logged as: Plugin csharp is not compatible with SonarLint. Skip it.
But in SonarLint for CommandLine official web site displays: Which languages are supported? - Out of the box, SonarLint CLI will analyze Java, Javascript, PHP and Python source files. If you bind SonarLint CLI to a SonarQube server, other SonarSource analyzer installed in the server will be downloaded and executed, as well as your custom rules. http://www.sonarlint.org/commandline/#FAQ
Please advise on this.
The error message is correct, SonarC# and SonarVB.NET are not supported by SonarLint CLI. To analyze .NET projects you need to either use SonarLint for Visual Studio, or the Scanner for MsBuild.
The .NET (C# and VB.NET) projects need to be compiled using the C#/VB.NET compiler (Roslyn), that executes our code analyzers. We basically hook into Roslyn and analyze code using its APIs. This is the reason the MsBuild analysis is a multi-step process, where you execute several commands to analyze your project.
The analyzers for non-.NET languages, such as Java, C++, Python, etc. have their own parsers and do not require additional steps, and are easily supported by SonarLint CLI.
Both approaches have their pros and cons. To write a Roslyn analyzer you don't have to create a language parser, you just use the existing infrastructure (which is really good), however, you need to execute the compiler. The non-.NET analyzers are standalone and have no compiler dependency, but some features are much harder to implement - such as analysis of classes that are not declared in one file.