Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate code metrics [closed]

Tags:

metrics

Are there any tools available that will calculate code metrics (for example number of code lines, cyclomatic complexity, coupling, cohesion) for your project and over time produce a graph showing the trends?

like image 499
Bjorn Reppen Avatar asked Sep 13 '08 07:09

Bjorn Reppen


People also ask

How do you find code metrics?

You can generate code metrics results for an entire solution in any of the following ways: From the menu bar, select Analyze > Calculate Code Metrics > For Solution.

What is calculate code metrics in Visual Studio?

Developers can use Visual Studio to generate code metrics data that measure the complexity and maintainability of their managed code. Code metrics data can be generated for an entire solution or a single project.

How do you calculate code complexity?

You compute it by using the control flow graph of the program. Cyclomatic complexity measures the number of nested conditions within the code, such as those created by for, if/else, switch, while, and until. The greater the number of conditions (as in example b from above), the greater the complexity.

How is code maintainability measured?

When investigating the maintainability of your code base, make sure to examine the number of code anomalies per thousand lines of code, i.e. the Findings Density. This gives you a measure for how often developers are confronted and hindered by code anomalies.


1 Answers

On my latest project I used SourceMonitor. It's a nice free tool for code metrics analysis.
Here is an excerpt from SourceMonitor official site:

  • Collects metrics in a fast, single pass through source files.
  • Measures metrics for source code written in C++, C, C#, VB.NET, Java, Delphi, Visual Basic (VB6) or HTML.
  • Includes method and function level metrics for C++, C, C#, VB.NET, Java, and Delphi.
  • Saves metrics in checkpoints for comparison during software development projects.
  • Displays and prints metrics in tables and charts.
  • Operates within a standard Windows GUI or inside your scripts using XML command files.
  • Exports metrics to XML or CSV (comma-separated-value) files for further processing with other tools.

For .NET beside NDepend which is simply the best tool, I can recommend vil.

Following tools can perform trend analysis:

  • CAST
  • Klocwork Insight
like image 176
aku Avatar answered Sep 28 '22 13:09

aku