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
703
votes
30 answers

What is a reasonable code coverage % for unit tests (and why)?

If you were to mandate a minimum percentage code-coverage for unit tests, perhaps even as a requirement for committing to a repository, what would it be? Please explain how you arrived at your answer (since if all you did was pick a number, then I…
sanity
  • 35,347
  • 40
  • 135
  • 226
405
votes
4 answers

How to use IntelliJ IDEA to find all unused code?

When I am in a .java file, the unused code is usually grayed out or has a green underline saying this code will probably (probably because of some weird JNI/Reflection corner cases) be unused. But I have this project with thousands of Java files and…
pathikrit
  • 32,469
  • 37
  • 142
  • 221
195
votes
15 answers

How to find out how many lines of code there are in an Xcode project?

Is there a way to determine how many lines of code an Xcode project contains? I promise not to use such information for managerial measurement or employee benchmarking purposes. ;)
Dave
  • 12,408
  • 12
  • 64
  • 67
155
votes
1 answer

What is meant by 'Assignment Branch Condition Size too high' and how to fix it?

In my Rails app, I use Rubocop to check for problems. Today it gave me an error like this : Assignment Branch Condition size for show is too high. Here's my code : def show @category = Category.friendly.find(params[:id]) @categories =…
THpubs
  • 7,804
  • 16
  • 68
  • 143
87
votes
18 answers

What is the fascination with code metrics?

I've seen a number of 'code metrics' related questions on SO lately, and have to wonder what the fascination is? Here are some recent examples: what code metrics convince you that provided code is crappy when if ever is number of lines of code a…
Steven A. Lowe
  • 60,273
  • 18
  • 132
  • 202
61
votes
6 answers

How many lines of code should a function/procedure/method have?

Possible Duplicate: When is a function too long? I've recently been given the unenviable task of reviewing poor code written by another developer and documenting the bad practices. (This is all for the purposes of getting out of paying for the…
Alex Angas
  • 59,219
  • 41
  • 137
  • 210
56
votes
15 answers

Do you find cyclomatic complexity a useful measure?

I've been playing around with measuring the cyclomatic complexity of a big code base. Cyclomatic complexity is the number of linearly independent paths through a program's source code and there are lots of free tools for your language of choice. The…
elasticrat
  • 7,060
  • 5
  • 36
  • 36
42
votes
2 answers

Code Metrics Calculation in Visual Studio

What is the prefered score range for the code metrics calculation for the following Maintainability Index Cyclomatic Complexity Depth of Inheritance class Coupling
37
votes
9 answers

Eclipse metrics plugin suggestion

I'm looking for a tool to give me some code metrics (total LOCs, LOC/Class, # of external references/class, etc...). Does anyone know a good eclipse plugin that could provide me some some code metrics?
Ben S
  • 68,394
  • 30
  • 171
  • 212
26
votes
13 answers

How bad is SLOC (source lines of code) as a metric?

We are documenting our software development process. For technical people, this is pretty easy: iterative development with internal milestones every four weeks, external every 3 months. However, the purpose of this exercise is to expose things…
Bob Cross
  • 22,116
  • 12
  • 58
  • 95
24
votes
5 answers

What is the difference between afferent couplings and efferent couplings of a class?

Code quality metric tool like Sonar does provide the ability to drill down to a class and find out the number of: Afferent (incoming) couplings Efferent (outgoing) couplings What are these two parameters? Can you please describe with a simple…
Geek
  • 26,489
  • 43
  • 149
  • 227
23
votes
2 answers

What is Abstractness vs. Instability Graph?

I recently used NDepend and it produced a good report on my .net assemblies and related pdbs. The most interesting thing I found in the report was abstractness vs. instability graph. I wanted to understand this in real detail, I read their docs and…
this. __curious_geek
  • 42,787
  • 22
  • 113
  • 137
22
votes
4 answers

How do I show how many lines of code my project contains in Visual Studio?

Possible Duplicate: How do you count the lines of code in a Visual Studio solution? How can I show the code metrics window in Visual Studio 2008 Professional SP1? I'm looking to see how many total lines of code my project is for school and I…
KingNestor
  • 65,976
  • 51
  • 121
  • 152
22
votes
2 answers

Basis for claim that the number of bugs per line of code is constant regardless of the language used

I've heard people say (although I can't recall who in particular) that the number of bugs per line of code is roughly constant regardless of what language is used. What is the research that backs this up? Edited to add: I don't have access to it,…
Matt R
  • 9,892
  • 10
  • 50
  • 83
21
votes
3 answers

Are there any good tools for static code analysis in typescript?

We have been searching for good tools for measuring the quality of our TypeScript code. Mainly, we are interested in measuring Cyclomatic Complexity, LCOM, Instability and similar metrics. A tool for visualizing dependencies between modules would…
1
2 3
18 19