Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would you measure code "quality" across a large project

I'm working on a quite large project, a few years in the making, at a pretty large company, and I'm taking on the task of driving toward better overall code quality.

I was wondering what kind of metrics you would use to measure quality and complexity in this context. I'm not looking for absolute measures, but a series of items which could be improved over time. Given that this is a bit of a macro-operation across hundreds of projects (I've seen some questions asked about much smaller projects), I'm looking for something more automatable and holistic.

So far, I have a list that looks like this:

  • Code coverage percentage during full-functional tests
  • Recurrance of BVT failures
  • Dependency graph/score, based on some tool like nDepend
  • Number of build warnings
  • Number of FxCop/StyleCop warnings found/supressed
  • Number of "catch" statements
  • Number of manual deployment steps
  • Number of projects
  • Percentage of code/projects that's "dead", as in, not referenced anywhere
  • Number of WTF's during code reviews
  • Total lines of code, maybe broken down by tier
like image 982
askheaves Avatar asked Aug 30 '09 03:08

askheaves


People also ask

How can we measure code quality?

You can measure your code's quality by reviewing its testability, which shows how well the code, program or software can support any testing efforts conducted on it. You may measure the code's testability by running tests on the code to see how many tests it takes to identify errors or faults present in the code.

When should you measure the code quality?

It is important and best to analyze code when it's written and before the code review. This helps save a lot of time and makes the process of resolving errors cheaper and easier. Code review is one of the top three ways to ensure code quality.

Which metrics are used to track code quality?

Quantitative Code Quality Metrics WMFP automatically measures the complexity of existing source code. The metrics used to determine the WMFP value include comments, code structure, arithmetic calculations, and flow control path.


2 Answers

You should organize your work around the six major software quality characteristics: functionality, reliability, usability, efficiency, maintainability, and portability. I've put a diagram online that describes these characteristics. Then, for each characteristic decide the most important metrics you want and are able to track. For example, some metrics, like those of Chidamber and Kemerer are suitable for object-oriented software, others, like cyclomatic complexity are more general-purpose.

like image 172
Diomidis Spinellis Avatar answered Oct 19 '22 23:10

Diomidis Spinellis


Cyclomatic complexity is a decent "quality" metric. I'm sure developers could find a way to "game" it if it were the only metric, though! :)

And then there's the C.R.A.P. metric...

P.S. NDepend has about ten billion metrics, so that might be worth looking at. See also CodeMetrics for Reflector.

D'oh! I just noticed that you already mentioned NDepend.

Number of reported bugs would be interesting to track, too...

like image 41
TrueWill Avatar answered Oct 19 '22 23:10

TrueWill