Static Code Analysis Tools in Visual Studio 2017 - visual-studio-2017

Good day
Requesting can you please let me know available Static Code Analysis Tools in Visual Studio 2017 and possible best practices etc.

For C#, Visual Studio includes "FXCop". See Microsoft Docs: Overview of code analysis for .NET in Visual Studio.
For C++, Visual Studio includes /analyze as well as C++ Core Guidelines checkers. See Microsoft Docs: Code analysis for C/C++ overview.
For third party solutions, there a number of options you can find with a quick Internet search.

Related

Does Visual Studio 2017 use the Language Server Protocol?

Language Server Protocol was created for VS-Code (not the Visual Studio IDE).
It is a rather sensible idea about providing language services like various linting and code-completion (intillisense).
It is by no means the first-time that idea has been had,
but it has seen rather rapid and wide-scale support from a large number of languages.
Is it used by Visual Studio 2017?
I can't seem to find the creating extensions docs for 2017.
eg the 2015 docs here.
If not, is there an official language server plugin that allows LSP resources to be used?
Update (Feb 2019): support for the Language Server Protocol is now built in to Visual Studio 2017.
This question was not able to answer, as only Microsoft holds the key. But luckily after half a year, Microsoft did announce the fact that Visual Studio would support LSP,
https://blogs.msdn.microsoft.com/visualstudio/2017/11/21/announcing-language-server-protocol-preview-release/
The extension only works for Visual Studio Preview builds right now, and also lacks many important features,
https://marketplace.visualstudio.com/items?itemName=vsext.LanguageServerClientPreview
We can see that there is still a long way to go.

Custom C++ code checker for Visual Studio 2017

Microsoft has now released the RC for Visual Studio 2017: https://www.visualstudio.com/vs/visual-studio-2017-rc/
This version of VS comes with some enhanced static code analysis, checking the code against the C++ core guidelines: https://blogs.msdn.microsoft.com/vcblog/2016/10/12/cppcorecheck/
Seems like these checks are implemented as some kind of extension to Visual Studio. Does anyone know if we are able to write our own code analyzers / implement checkers for our own guidelines with Visual Studio 2017? So far we had to use some external compiler (like clang) to generate the AST. I could only find documentation for VS2015, describing how to write custom checkers for managed languages like C#.

How do I set up code coverage in C++ googletest project in Visual Studio 2010

I have a C++ googletest project building in Visual Studio 2010 professional. This builds a console application which generates XML test result output. How can I set it up to get code coverage information?
I have tried instructions here to instrument the code but viewing the Code Coverage results seems to require Visual Studio Ultimate. Is there any converter for the .coverage files Visual Studio generates?
Bonus points for portable/free/open-source solutions!
You can try OpenCppCoverage: http://opencppcoverage.codeplex.com.
OpenCppCoverage is a code coverage tools for C++ under Windows. It is open-source and works well with google test / Visual Studio C++.
Disclaimer: I am the author of this tool.
Hope that help.
Edit to follow brasofilo advice:
To be more precise about your question, OpenCppCoverage should work with Visual Studio C++ 2010 professional. The only requirement is to support native Pdb files (http://msdn.microsoft.com/en-us/library/yd4f8bd1%28vs.71%29.aspx).
It is open source and free and you can find sources here: https://opencppcoverage.codeplex.com/SourceControl/latest.
What do you mean by portable?
If you mean "Multi platform" -> No, it works only on Windows
If you mean "Portable application" (http://en.wikipedia.org/wiki/Portable_application): OpenCppCoverage required only Redistributable for Visual Studio 2013 to be installed on host (http://www.microsoft.com/en-US/download/details.aspx?id=40784) but it does not write to registry and you can move the binaries where you want (usb key for example).
Hope that help.
I think you can use the VSTEST.Consol.exe for this purpose http://msdn.microsoft.com/en-us/library/vstudio/jj155796.aspx.
According to documentation, it would run tests written against any test framework. You may enable the
/Enablecodecoverage option, which Enables data diagnostic adapter CodeCoverage in the test run.
More information may be found here: http://blogs.msdn.com/b/bhuvaneshwari/archive/2012/06/16/vstest-console-exe-commandline-test-runner.aspx
There is also an open source code coverage tool called ggcov: http://ggcov.sourceforge.net/index.html
Hope that these helps.

Static-code analyzer: unmanaged C++ Visual Studio 2008

I develop commercial unmanaged C++ app on Visual Studio 2008, and I want to add a static-code analysis tool.
Any recommendations?
I think it would be real nice if the tool can be integrated into MSVC.
I'm thinking about PC-Lint + Visual Lint
However, I have been taking a hard look at Coverity, Understand, and Klockwork as well.
Price isnt really the issue. I want opinions from people who actually used the tool for unmanaged C++ on MSVC, and they just absolutely loved it.
Lastly, VSTS and Intel Parallel Studio now also offer static code analysis. Nice~
Note: related post suggest Coverity is the best (?) (see last 2 posts)
Beyond all those you mentioned, VS Team Developer edition comes bundled with a nice static analysis tool called prefast. Its (obviously..) well integrated into the IDE, and accessible via the menus.
Its in fact a public release of an MS internal tool - a thin version of a tool called Prefix they run on their builds. Personally, when I faced the same decision, prefast sufficed.
I work for RedLizard building Goanna, a C++ static analysis plugin for Visual Studio. Its focus is on desktop use by a programmer. You can run it on individual files, just as you do the compiler, and it can give you results quickly.
There is a trial available. Right-click a file, select Run Goanna, and the results appear in the Visual Studio warnings list.
You can try CppDepend, a pretty complete c and c++ static analyzer, well integrated with VS 2008, 2010, 2012, 2013 and 2015.
I just started using cppcheck which I like very much due to the low noise.
Although it does not integrate directly with Visual Studio 2008, VS can be customized and you should be able to integrate it directly into the IDE.
I use PVS-Studio static code analyzer.
This static code analyzer good integrated with Visual Studio 2005, 2008, 2010, 2012, 2013.
It has many additional features:
Verification of files which were recently modified several days ago;
Verification of files by their filenames from within the text file
list;
version control systems integration; ability to operate fro m command line
interface;
«False Alarms» marking; saving and loading of analysis
results;
utilizing all available cores and processors;
etc...

Profiling in Visual Studio 2008 PRO

How do I use the profiler in Visual Studio 2008?
I know theres a build option in Config Properties -> Linker -> Advanced -> Profile (/PROFILE), however I can't find anything about actauly using it, only articles I was able to find appear to only apply to older versions of Visual Studio (eg most say to goto Build->Profile to bring up the profile dialog box, yet in 2008 there is no such menu item).
Is this because Visual Studio 2008 does not include a profiler, and if it does where is it and where is the documentation for it?
Microsoft has released stand-alone Profiler for VS 2008 here
The profiler is only available in the Team System editions of Visual Studio 2008. The last version that I used that included a profiler was Visual C++ 6.0.
For Visual Studio 2005, you could try Compuware DevPartner Performance Analysis Community Edition.
There was also a list of .NET profilers in the What Are Some Good .NET Profilers question.
As I understood from reading a few sites, when you use VS 2008 stand alone profiler to create .vsp files, you will need either VS2008 Premium or Ultimate to view .vsp files.
By the way, I installed VS2012 Release candidate which is available for free (trial version?) and I can use its profiling engine.