I installed SonarLint.VSIX-184.108.40.20632-2017 extension for my Visual studio2017 but no SonarQub installed, and when I open my C++ project and type code, there are no bugs reported, should I configure something to enable SonarLint scan for my project?
C++ files are analysed when you save the file. There is more information about when rules are executed and how to configure the rules on the wiki.
It looks like there’s been a problem initialising SonarLint, possibly because of a corrupt MEF cache.
There are a couple of things you can try:
- install and run the Clear MEF component Cache extension, then restart VS.
- uninstall then re-install the SonarLint extension.
I download the SonarLint from https://www.sonarlint.org/visualstudio/, and uninstall and reinstall again, but it doesn’t help, my work environment can not connect to internet, so I should download the extension and copy to my work computer then install it offline, does that cause the installation problem?
Downloading the VSIX then installing it should work.
Are you still getting the same error message in the output window saying there is an error initializing the SonarLint package?
If so, trying launching VS with activity logging turned on as described here to see if there is any more information in the activity log.
I suspect you might have to reset VS by running devenv.exe /setup to force all extensions to be re-initialised, although this will also reset any configuration options you have set in VS (i.e. changes you have made in Tools, Options).
Yes,it has the same error. and I attached the logfile, could you help to see it?
ActivityLog.txt (1.6 MB)
The log contains the following error, which probably explains why you are not seeing C++ issue:
Still unable to load MEF component DLL: Could not load file or assembly 'System.Net.Http, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. C:\USERS\N0045136\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_1F30A290\EXTENSIONS\DU4I13PF.BR0\SonarLint.VisualStudio.Integration.dll
Could you try installing the previous version (v4.13) of SonarLint for VS from this page to see if that works?
I re-install the V4.13, there are no install errors, but there are no reported issues too, when i save my file, the output windows show “Analyzing XXX”, but I can not see the issues. I suppose there is issue in line 111
A few more questions/checks:
- could you check that you don’t have
Automatically update this extensionchecked (sorry, I forgot to mention this before)?
do you see an issue if you add a
// TODOcomment and save?
which issue are you expecting to see on line 111 - S836 - Variables should be initialized before use? If so, there was a bug in the analyzer that was fixed recently that meant that rule did not report issues consistently. That bug has been fixed, but not in the version of the analyzer used by SonarLint.
Yes, I checked Automatically update this extension, but I said, my develop environment can not connect to internet, and I add //ToDo comment and save, there is no error.
I try another rules, after using this Sonarlint version, I can see the warnings, thanks for your help. it seems worked
Thanks for confirming. FYI the bug is being tracked by SLVS-1139. Thank you for reporting it!
FYI SLVS v4.14.1 has been released, which fixes the bug that could prevent C++ issues from appearing in Visual Studio 2015 and Visual Studio 2017.
Note that the version of the embedded C++ analyzer has not been updated, so SVLS v4.14.1 does not include the fix for CPP-2338.
For those who are interested, issue SLVS-1139 contains an explanation of the underlying issue, why we didn’t catch it during testing, and how we could catch such issues automatically in future.