4

Are there any tools out there for producing Code Metrics (Such as Cyclomatic Complexity, Lines of Code, Comment to Code Ratio, etc) for Visual C++ 2012/2013 or 2015?

We need to be able to run a command-line tool to generate these metrics (And output them to some kind of file) so that we can automatically run the analysis as per of our Continuous Integration process. Note that we don't need a complete static analysis tool, as we're already using (And happy with) the Static Code Analysis tool built into Visual C++ (However this doesn't include complexity checking).

Most of the "Visual Studio Code Metrics" tools out there only seem to support Managed code (C# etc) and not C++.

I've seen similar questions on here from a few years ago, but I was hoping there may be some more up to date options. I've not found much through Google.

Thanks in Advance. Ben

BenS1
  • 183
  • 2
  • 11
  • [CodeMaid](http://www.codemaid.net/documentation/#digging) can show the complexity inside visual studio. – David Ruhmann May 14 '15 at 20:29
  • Thanks for you suggestion. I should have been clearer though that in addition to seeing the complexity information in the IDE I also need to be able to generate it through a command-line tool and export it somehow, so that we can generate complexity reports and quality gates as part of our Continuous Integration process. – BenS1 May 15 '15 at 09:03
  • 1
    I have a possible answer, not ready for public release. Contact me offline, see bio. – Ira Baxter May 15 '15 at 10:00

3 Answers3

4

You can try CppDepend, a pretty complete C++ static analysis tool, it allow you to calculate the Cyclomatic complexity and many other metrics, it's well integrated to Visual studio 2012/2013 and can analyze the source code from command line

Dane
  • 161
  • 5
  • 1
    Thanks Dane. CppDepend looks very good, and it acutally has a plug-in for SonarQube which is what we use for our CI dashboard so even better. One question though, does it actually do normal Static Code Analysis? It seems to produce great metrics, but does it actually do things such as detect potential usage of uninitialised variables, and other potential programming logic errors like other static analysers? – BenS1 May 18 '15 at 09:23
  • CppDepend embed CppCheck which detect many potential programming logic errors, and also it report all Clang diagnostics errors, and you can also plug other static analysis results as described here: http://www.cppdepend.com/Doc_Custom_Plugin – Dane May 18 '15 at 12:55
0

Yes there are.

Coverity and Parasoft static analysis tools are two of them. You should also look at Klocwork.

Here's a search of static analysis plugin visual studio code metrics

Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154
  • Unfortunately that Google search lists tools that seem to only work for managed code (C# etc), not C++. The Coverity and Parasoft recommendations seem quite heavyweight for what I need. We already use Visual C++'s built in Static Code Analyser, but it doesn't produce metrics, so I'm looking for a lieghtweight tool that can produce just these metrics without performing full static analysis. – BenS1 May 15 '15 at 08:57
0

Our SourceMeter command line tool takes as input Visual C++ project files and calculates the code metrics you are looking for (Cyclomatic Complexity, Lines of Code, Comment to Code Ratio, etc) in CSV format.

Rudolf FERENC
  • 289
  • 1
  • 6