Questions tagged [code-metrics]

Software metrics are quantitative data pertaining to source code, e.g. number of lines of code (LOC) for a file.

Questions with this tag will often be about which metrics are most useful for certain purposes or which tools are available to provide certain metrics.

276 questions
8
votes
3 answers

Good code measuring tools?

Are there any good code measuring tools available? I found code measure pretty useful and interesting, but I don't think I can pay $1K/year for just using the measuring tool. I imagine there might be a tool that is/can open source software…
prosseek
  • 182,215
  • 215
  • 566
  • 871
8
votes
2 answers

Source of parsers for programming languages?

I'm dusting off an old project of mine which calculates a number of simple metrics about large software projects. One of the metrics is the length of files/classes/methods. Currently my code "guesses" where class/method boundaries are based on a…
Arkaaito
  • 7,347
  • 3
  • 39
  • 56
8
votes
2 answers

How to capture code metrics in Xcode?

I want to write my code more cleaner. For this purpose I'm looking for a tool to generate code metrics in Xcode. I'd like to have a statistic showing me how many tests, classes etc. were added. And the main goal is retrieving cyclomatic complexity…
Igor
  • 4,235
  • 3
  • 34
  • 32
8
votes
3 answers

How can the cyclomatic complexity be 27 in a method with 13 event handler subscriptions?

We have this code, sortof: private void InitializeEvents() { this.Event1 += (s,e) => { }; this.Event2 += (s,e) => { }; this.Event3 += (s,e) => { }; this.Event4 += (s,e) => { }; this.Event5 += (s,e) => { }; this.Event6 +=…
Johann Gerell
  • 24,991
  • 10
  • 72
  • 122
7
votes
3 answers

Code Metrics in Visual Studio 2010

I was wondering what options were available with regards to code metrics in Visual Studio 2010. I know there are manual metrics that can be run on your code from within the IDE, but are there any other options? What I'm trying to do is this: My…
7
votes
3 answers

How can I visualize changes in a large code base quality?

One of the things I’ve been thinking about a lot off and on is how we can use metrics of some kind to measure change, are we going backwards or not? This is in the context of a large, legacy code base which we are improving. Most of the code is C++…
Andy Dent
  • 17,578
  • 6
  • 88
  • 115
7
votes
2 answers

Is branch coverage as useful as line coverage?

My organization is emphasizing a line and branch coverage of 80%. I have absolutely no problem with the line coverage requirement, but the branch coverage has given me an issue. Let's take the following case in point: if(decisionA && decisionB) { …
arviman
  • 5,087
  • 41
  • 48
7
votes
5 answers

What is the best way to reduce cyclomatic complexity when validating data?

Right now I'm working on a web application that receives a significant amount of data from a database that has a potential to return null results. When going through the cyclomatic complexity for the application a number of functions are weighing in…
rjzii
  • 14,236
  • 12
  • 79
  • 119
7
votes
1 answer

How to measure C++ or Java file complexity?

I want to start measuring what Michael Feathers has referred to as the turbulence of code, namely churn vs. complexity. To do this, I need to measure the complexity of a C++ or Java file. So I found a couple tools that measure cyclomatic complexity…
7
votes
3 answers

Visual Studio code metrics misreporting lines of code

The code metrics analyser in Visual Studio, as well as the code metrics power tool, report the number of lines of code in the TestMethod method of the following code as 8. At the most, I would expect it to report lines of code as…
Ian Newson
  • 7,679
  • 2
  • 47
  • 80
6
votes
1 answer

What does NCSS stand for?

I've been looking for ways to measure the complexity of my projects's source code, and have frequently come across the acronym "NCSS". There doesn't seem to be any clear, easy-to-find definition of what it stands for. As far as I can infer, it has…
Johan
  • 1,940
  • 1
  • 13
  • 18
6
votes
1 answer

Cyclomatic Complexity in Visual Studio

I do some tests with Visual Studio Code Metrics. As I can calculate the Cyclomatic Complexity, each if, while, for - operators increase the complexity with 1. I have the next simple method: static bool ContainsNegative(int a, int b, int c, int d) …
Pepo
  • 135
  • 1
  • 10
6
votes
1 answer

Getting the functionality of the outdated metrics powertool in VS2017?

In recent earlier versions of Visual Studio (i.e.: earlier than VS2017), Microsoft released a separate code metrics powertool that could be run through the command line and generate an XML containing certain code metrics (such as lines of code,…
NickH
  • 61
  • 3
6
votes
2 answers

What is an easy way to calculate the CRAP metric in my Javascript build process?

I'm a fan of the CRAP metric, and use it to monitor code quality for my C# and Java projects. I'd like to do the same for my growing Javascript codebase. Is there an existing process that makes this easy to integrate into my Javascript build…
David Laing
  • 7,605
  • 10
  • 33
  • 44
6
votes
1 answer

Why does Class Coupling jump when I use LINQ?

I have a method that takes three parameters: List source, List
Kelly Cline
  • 2,206
  • 2
  • 33
  • 57