-
Notifications
You must be signed in to change notification settings - Fork 77
Home
SonarLint is an IDE extension that helps you detect and fix quality issues as you write code. Like a spell checker, SonarLint squiggles flaws so they can be fixed before committing code. You can get it directly from the VS Marketplace and it will then detect new bugs and quality issues as you code (for C#, VB.NET,JavaScript, and C++).
SonarLint is also available for VS Code, Eclipse and IntelliJ (the languages supported vary from IDE to IDE).
Simply open a project containing C#, VB, C++ or JS files.
For C# and VB.Net, new issues will be reported as you type. You do not have to select 'Run Code Analysis' from the 'Analyze' menu - the rules are run automatically. Note: by default, VS is configured to only run Roslyn analyzers on files that are currently open. You can choose to have the analysis run on the entire solution as described in the Microsoft docs, although this is obviously more processor-intensive.
For C++ and JavaScript, new issues will be reported when you save the file. Issues are highlighted in your code, and also listed in the 'Error List'.
You can access the detailed rule description directly from the issue in the Error List, using the Show Error help
option on the contextual menu.
Check the rules to see what SonarLint can do for you:
You will benefit from the following code analyzers: SonarC#, SonarVB, SonarCFamily for C/C++ and SonarJS.
For C#, VB.NET and C/C++ the only thing you need to install is the VSIX.
JavaScript analysis requires some additional binaries to be downloaded as a one-time operation. To enable JavaScript analysis, select Tools
, Options
, SonarLint
and click on the "Activate" button then clicking "OK". The additional files will be downloaded in the background, which the download progress being shown in the Visual Studio status bar.
Once the download has completed, JavaScript files will be analysed whenever you save them.
By default SonarLint runs in standalone mode i.e. completely independently of SonarQube/SonarCloud.
Note: configuring which C++ or JavaScript rules run is not currently supported.
The SonarC# and SonarVB rules are implemented as Roslyn VSIX analyzers, and you can configure which rules are executed using the normal ruleset mechanism in VS.
Note: Connected mode is currently only supported for C# and VB.NET projects.
You can connect SonarLint to SonarQube >= 6.7 or SonarCloud to benefit from the same rules and settings that are used to inspect your project on the server. SonarLint then hides in VS the issues that are marked as Won’t Fix or False Positive.
To configure the connection, have a look at SonarQube tab in the Team Explorer.
SonarLint will periodically check whether the quality profile on the server has changed and ask you whether you want to update the local configuration to match. Alternatively, you can manually trigger a refresh from the SonarQube tab in the Team Explorer window.
If you would like to see a new feature, please create a new thread in the forum "Suggest new features".
Please be aware that we are not actively looking for feature contributions. The truth is that it's extremely difficult for someone outside SonarSource to comply with our roadmap and expectations. Therefore, we typically only accept minor cosmetic changes and typo fixes.
With that in mind, if you would like to submit a code contribution, please create a pull request for this repository. Please explain your motives to contribute this change: what problem you are trying to fix, what improvement you are trying to make.
Make sure that you follow our code style and all tests are passing.
For SonarLint support questions ("How do I?", "I got this error, why?", ...), please first read the FAQ and then head to the SonarSource forum. There are chances that a question similar to yours has already been answered.
Be aware that this forum is a community, so the standard pleasantries ("Hi", "Thanks", ...) are expected. And if you don't get an answer to your thread, you should sit on your hands for at least three days before bumping it. Operators are not standing by. :-)
Copyright 2017-2019 SonarSource.
Licensed under the GNU Lesser General Public License, Version 3.0