Inspired by Ohloh, and a need to start scoping migration of a large cluster of Drupal sites from Drupal 4.7 to Drupal 5.x/6.x, I've started some work on a static analysis / code metrics tool
specifically intended for PHP / Drupal.
Code is available from Bryght's public svn repository, with repo URL https://svn.bryght.com/dev/svn/scripts/metrics.
The metrics.php program is currently implemented as a command line
script, which is pointed at a directory containing code to be
analyzed:
% php metrics.php code_dir
Reports are generated on standard output.
History
This code started from the sloccount.php script written by Arto
Bendiken. I've tried to extend the script by making it more
comprehensive and precise, but also more flexible and general. The
architecture is intended to be pluggable, allowing users to easily
write analysis tools for new types of files.
Currently there are two supported file types: generic, and PHP.
The 'generic' code analysis supports 'C' style code, with in-line
comments initiated by '//' and comment blocks set of by '/*' and '*/'.
This gives rough metrics for javascript and CSS files.
The PHP analyzer uses PHP's tokenizer and a rudimentary parser to
obtain additional information about PHP code.
Analysis is completely separated from reporting: the analysis
phase builds an array of metrics per file, where each metric
can itself be structured.