16

I'm looking for extensions that can show code metrics (especially cyclomatic complexity) beside method bodies or in a tool window as I type (without additional interactions).

So far I know:

  • Code Metrices by Elisha: free and simple. I don't know what metric it calculates, but read somewhere that it's not cyclomatic complexity. It doesn't support any other metrics.

  • CodeMetricAdornment by Carpslayer: only supports lines of code, comments, and whitespaces within a code file.

  • CodeRush: Not free. Exactly what I want (metric is selectable), unfortunately I'm already using ReSharper, and I'm thinking that it would be an overkill to have / buy both.

Are there others? What metrics do they provide?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Matthias
  • 15,919
  • 5
  • 39
  • 84
  • 'List of' type questions also fall into the non constructive category. Over the years, we've found that they just don't fit well in the Q&A engine. I'll ask one of my fellow moderators to review this independently, however. – Tim Post Dec 22 '11 at 14:29
  • I understand, but my question doesn't ask "what is your favorite code metrics tool". I already made efforts to sum up the tools I already tried, but which doesn't meet my requirements. Many roads lead to Rom, and so do tools, methods, frameworks, etc.. The question is almost the same as "how can i do that and that", plus it provides my personal efforts. – Matthias Dec 22 '11 at 14:40
  • I've asked the other moderators to review my decision. Hang tight, one of them should chime in here shortly. I don't think it's a _bad_ question, I just could not think of an edit that would make it less open ended. While you have gone to lengths to keep the focus as narrow as you could, it still seems (from my experience) to be a bit too open ended. – Tim Post Dec 22 '11 at 14:43
  • I was torn when I first read this question, but the more I think on it, the more it seems that your primary requirement that the code should be shown beside method bodies narrows the list down enough that we can make it work. I'm reopening the question and I will be checking back to make sure the answers don't turn into a list of one-liner links to every plugin under the sun. – Adam Lear Dec 22 '11 at 16:19

2 Answers2

4

Installing CodeRush (and turning off all the options you don't need) is certainly the easiest. It is possible to get CodeRush and Resharper to work together, see some of the answers here. There's a free trial if you just want to give it a go.

(There is also a free lite version of CodeRush called CodeRush Xpress, but I just checked and it does NOT include code metrics.)

If you're really opposed to installing the whole of CodeRush, DevExpress also provides its Visual Studio plugin technology on which it's built, DXCore, for free. So, you could create your own plugin (without installing CodeRush). There is a tutorial here which continues here and there are some (work in progress) docs here and another tutorial here.

Those tutorials are about creating your own metric, but you should be able to just replace the custom code with:

public partial class PlugIn1 : StandardPlugIn
{
    private void codeMetricProvider1_GetMetricValue(object sender, GetMetricValueEventArgs e)
    {
        e.Value = e.LanguageElement.GetCyclomaticComplexity();
    }
}

However, I don't think the display of the resulting value (e.g., next to the method) is covered by the tutorial so you might have to dig further (but DXCore can handle that too).

Community
  • 1
  • 1
shamp00
  • 11,106
  • 4
  • 38
  • 81
0

Here is the tool which can meets your requirements i.e. implementing code metrics using api while coding an application. This helps you generate or suggest the code metrics programmatically and instantly. And it generates the metrics far more than you have specified here.

Here is the link for the tool. http://www.ndepend.com/ConstraintsExtractedFromCode.aspx

Jayprakash S T
  • 243
  • 1
  • 2
  • 7