PHP Code metrics statistics

I believe doing statistics about the quality of the code it can be a good incentive for developers to improve their application and for new coming developers in the project to see a well structured program and put easily their hands on.

Sometime ago I started to verify the quality of the code of Drupal using PHPdepend in Jenkins a bit for fun, so every time there was a new commit pdepend was launched to analyze the code.

I noticed in the code that the threshold to identify max and min limits were based on Java threshold (these threshold have been published in the book “Object Oriented Metrics in Practice” which you can find also in slideshare (slide 12)) which of course cannot be a good comparison since PHP and Java are 2 different programming languages, so I started to analyze other software in order to calculate an average and defining new thresholds.

The comparison was done with pdepend 0.10.7 (I am aware of the version 1.0.0) on 60 php projects which I selected in different environments.

You can find the file at the link Comparison of php application to determine thresholds in pdepend.

Even though you can find a degree among all the applications, it could be more interesting doing  it between similar application (CMS, etc.) .

The summary is:
MIN – AVG – MAX
cyclo-loc:    0.16 – 0.20 – 0.24 (not changed)
loc-nom:        13 –    20 –    27 (doubled)
nom-noc:         5 –   12 –    18
noc-nop:          1 –   14 –    27
calls-nom:   2.66 – 3.68 – 4.69
fanout-calls: 0.01 – 0.06 – 0.11 (much lower)
andc:          0.27 – 0.52 – 0.76
ahh:            0.17 – 0.37 – 0.58

What it is interesting to see is that the line of code for each method is doubled and the fanout-calls is much lower (then the next question would be: why ?), it would be even more interesting to see how the new versions of each application change or with the new version of pdepend, If I had more time I would like to work on it but at least I shared this thought with you :-)

I hope this result can be of inspiration somebody else :-)

Advertisements

3 thoughts on “PHP Code metrics statistics

    • Hi Tomas,

      well I hope you can find it useful. It would be nice to repeat the same analysis with the time (as the projects got updated) and with the new version pdepend

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s