Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate software metrics for PHP projects

I would like to calculate some code metrics for my PHP OOP projects. I try to use some of the tools mentioned in here. But except trail version of Understand, which presents only

  • number of code, comment, blank lines
  • number of classes number of file
  • number of functions number of
  • declarative/executable statements

I couldn't find any working for PHP.

Plugin for Eclipse by State of Flow is not working with my (not so new) Galileo Eclipse v3.5.

I'm interested in measures such as

  • depth of inheritance tree,
  • avg function length,
  • weighted methods per class,
  • duplications,
  • ...

Are there any tools?

like image 921
Magda Avatar asked Dec 06 '22 22:12

Magda


2 Answers

There are some tools, in PHP -- and for PHP code.

Here are those I can think about :

  • phpcpd -- copy-paste detector
  • phploc -- to do many kind of counts (lines, classes, ...)
  • PHP_CodeSniffer -- to check if your code respects your coding standards.
  • phpmd -- mess detector
  • phpDocumentor / DocBlox to generate documentation (and detect what is not properly documented)


In PHP, those tools are generally not used from Eclipse, but integrated in some Continuous Integration Platform.

About those, you can take a look at :

  • phpUnderControl -- was used a lot a couple of years ago -- it has less success now
  • Jenkins (More or less a fork of Hudson)
    • And, for that one, see Template for Jenkins Jobs for PHP Projects

Still, if you want to integrate some of those tools with Eclipse PDT, you might want to take a look at PHP Tool Integration.

like image 113
Pascal MARTIN Avatar answered Dec 10 '22 11:12

Pascal MARTIN


See our PHP CloneDR for a tool that computes the amount and the precise location of duplicated code. It will find duplicates in spite of reformatting the text, modification of comments, and modifications (up to a degree of [dis]similarity.

There's an example of Joomla processed by the PHP CloneDR at the link.

like image 30
Ira Baxter Avatar answered Dec 10 '22 13:12

Ira Baxter