Questions tagged [code-metrics]

28 questions
350
votes
6 answers

What is negative code?

I was reading the Wikipedia article on Douglas McIlroy and found a quote that mentions "The real hero of programming is the one who writes negative code." What does that mean?
Anonymous
72
votes
12 answers

How can I quantify the amount of technical debt that exists in a project?

Does anyone know if there is some kind of tool to put a number on technical debt of a code base, as a kind of code metric? If not, is anyone aware of an algorithm or set of heuristics for it? If neither of those things exists so far, I'd be…
Erik Dietrich
  • 5,605
  • 4
  • 30
  • 34
36
votes
2 answers

Are There Metrics For Cohesion And Coupling?

Is there a metric analogous to the McCabe Complexity measure to measure how cohesive a routine is and also how loosely (or tightly) coupled the routine is to other code in the same code base?
Onorio Catenacci
  • 2,937
  • 3
  • 26
  • 37
19
votes
4 answers

Experiments correlating code metrics to bug density

I'm wondering if someone has done some experiments correlating code metrics (SLOC, Cyclomatic Complexity, etc) with bug density in Object Oriented applications. I'm not looking for experiments that only prove or disprove a correlation, but on both.…
Augusto
  • 992
  • 9
  • 16
18
votes
4 answers

Source code metrics for measuring code stability?

Considering how software is developed during a release cycle (implementation, testing, bug fixing, release) I was thinking that one should be able to see some pattern in the lines of code that are changed in the code base; e.g. towards the end of a…
Giorgio
  • 19,486
  • 16
  • 84
  • 135
17
votes
3 answers

Is there a correlation between complexity and reachability?

I've been studying cyclomatic complexity (McCabe) and reachability of software at uni recently. Today my lecturer said that there's no correlation between the two metrics, but is this really the case? I'd think there would definitely be some…
Saladin Akara
  • 341
  • 1
  • 4
10
votes
4 answers

Does it make sense to compute cyclomatic complexity/lines of code ratio?

In general, maintainability index relies on many factors. For example, in Visual Studio, it rely on cyclomatic complexity, depth of inheritance, class coupling and lines of code; those four values must be as low as possible. At the same time, I've…
Arseni Mourzenko
  • 134,780
  • 31
  • 343
  • 513
9
votes
2 answers

How is technical debt best measured? What metric(s) are most useful?

Possible Duplicate: How can I quantify the amount of technical debt that exists in a project? If I wanted to help a customer understand the degree of technical debt in his application, what would be the best metric to use? I've stumbled across…
6
votes
3 answers

How to calculate Cyclomatic Complexity exactly?

My question is more about the transformation from programming code to control flow graph. Say, I have a piece of code: public class Contractor { // other member fields... private bool isVerified; private int noOfA; private int…
VincentZHANG
  • 171
  • 1
  • 5
6
votes
5 answers

Is measuring the binary size of a c++ program a good indication of code complexity? Or something else?

In my company we have this obligatory practice before a review to be send the binary size impact of the code change to be measured and provided. We must use -Os for this metric to avoid unpredictable inlining. There is no customer or product driven…
gsf
  • 264
  • 3
  • 8
5
votes
1 answer

What does the "4" in LCOM4 mean?

I know that methods in a class should have high cohesion which roughly translates to having all the methods use all the instance variables directly or indirectly. I know that LCOM4 (Lack of cohesion)metric is useful for having a quantitative figure…
Geek
  • 5,107
  • 8
  • 40
  • 58
4
votes
2 answers

Summing cyclomatic complexity of function or files

Is the sum of the cyclomatic complexity of all section in a file the total cyclomatic complexity for this file? If it is, is the sum of a set of related files the total cyclomatic complexity for this set? This is confusing for me because most of the…
4
votes
2 answers

Strategies for using a code metric evaluation tool

Should code quality metric evaluation tools like Sonar be integrated with IDE for running local analysis or should they be a part of the build process (like integrated with maven) for continuous inspection or should it be a combination of both? How…
Geek
  • 5,107
  • 8
  • 40
  • 58
3
votes
2 answers

Why in cyclomatic complexity we add 1 for operators within a condition?

I know that basically, CC can be computed as number of decision + 1. In addition, every logical operator in the condition causes CC to increase by 1. But why? Having the code if(A || B || C) else... the control flow graph would simply be a node with…
user144171
  • 523
  • 5
  • 14
2
votes
1 answer

how to measure defects per KLOC

I have been reading on the internet about the metric "number of bugs per 1000 lines of code" and what would be a good number. However, I wonder how someone would compute such a metric? The reason a bug is in there is that nobody has found it. And…
icehawk
  • 183
  • 1
  • 4
1
2