formula per determinare l'indice di mantenibilità di una base di codice

  • 0-9 = Red
  • 10-19 = Yellow
  • 20-100 = Green
Maintainability Index = MAX(0,(171 - 5.2 * ln(Halstead Volume) - 0.23 * (Cyclomatic Complexity) - 16.2 *
ln(Lines of Code))*100 / 171)

Metrica CRAP

vedi "CRAP for PHP" http://sebastian-bergmann.de/archives/877-CRAP-in-PHPUnit-3.5.html

As the CRAP acronym suggests, there are several possible patterns that make a piece of code CRAPpy, but we had to start somewhere. Here is the first version of the (in)famous formula to help detect CRAPpy Java methods. Let's call it CRAP1, to make clear that this covers just one of the many interesting anti-patterns and that there are more to come.

CRAP1(m) = comp(m)^2 * (1 – cov(m)/100)^3 + comp(m)

Where CRAP1(m) is the CRAP1 score for a method m, comp(m) is the cyclomatic complexity of m, and cov(m) is the basis path code coverage from automated tests for m.

If CRAP1(m) > 30, we consider the method to be CRAPpy.