phploc
A tool for quickly measuring the size of a PHP project.
I use Jenkins and its Plot Plugin to generate statistics.
Example:
For every Build I plot the line of codes. Lets say I have like 500.000 lines and it changes about +-100 lines per build.
Since the plot y-axis always starts with 0 the whole plot is meaningless. It looks like 1 straight line.
Same goes for other metrics, if the value is too high.
Question: is there any configuration to set minimum y-axes to the minimum value?
Source: (StackOverflow)
I am trying to install phploc on my ubuntu 13.04 and it doesn't seem to work here are the steps I followed.
$ sudo pear config-set auto_discover 1
$ sudo pear install phpunit/phploc
phpunit/phploc can optionally use PHP extension "bytekit"
downloading phploc-1.7.4.tgz ...
Starting to download phploc-1.7.4.tgz (10,134 bytes) .....
done: 10,134 bytes
install ok: channel://pear.phpunit.de/phploc-1.7.4 .de/phploc
Then when i type phploc it givies this error
$ phploc
PHP Warning:
require_once(SebastianBergmann/FinderFacade/autoload.php): failed to
open stream: No such file or directory in
/usr/share/php/SebastianBergmann/PHPLOC/autoload.php on line 44 PHP
Stack trace: PHP 1. {main}() /usr/bin/phploc:0 PHP 2. require()
/usr/bin/phploc:48 PHP Fatal error: require_once(): Failed opening
required 'SebastianBergmann/FinderFacade/autoload.php'
(include_path='.:/usr/share/php.;/usr/bin/pear.:/usr/share/php/SebastianBergmann/PHPLOC/')
in /usr/share/php/SebastianBergmann/PHPLOC/autoload.php on line 44 PHP
Stack trace: PHP 1. {main}() /usr/bin/phploc:0 PHP 2. require()
/usr/bin/phploc:48
Here is my php include path
$ php -i | grep include <br>
allow_url_include => Off => Off
include_path => .:/usr/share/php.:/usr/bin/pear.:/usr/share/php/SebastianBergmann/PHPLOC/ => .:/usr/share/php.:/usr/bin/pear.:/usr/share/php/SebastianBergmann/PHPLOC/
MYSQL_INCLUDE => -I/usr/include/mysql
xdebug.collect_includes => On => On
and included in the distribution in the file: LICENSE
Source: (StackOverflow)
If I run phploc
against one of my PHP project (open source) I see this output.
phploc 1.6.4 by Sebastian Bergmann.
Directories: 3
Files: 33
Lines of Code (LOC): 2358
Cyclomatic Complexity / Lines of Code: 0.08
Comment Lines of Code (CLOC): 903
Non-Comment Lines of Code (NCLOC): 1455
Namespaces: 0
Interfaces: 3
Classes: 28
Abstract: 1 (3.57%)
Concrete: 27 (96.43%)
Average Class Length (NCLOC): 49
Methods: 149
Scope:
Non-Static: 128 (85.91%)
Static: 21 (14.09%)
Visibility:
Public: 103 (69.13%)
Non-Public: 46 (30.87%)
Average Method Length (NCLOC): 9
Cyclomatic Complexity / Number of Methods: 1.69
Anonymous Functions: 0
Functions: 3
Constants: 9
Global constants: 0
Class constants: 9
With this static analysis how do tell if this code-base is good or bad? Or how well or badly written?
- Is cyclomatic complexity good if its too low or high ?
- Having
3.57%
abstract class is good or bad ?
14.09%
static methods. Should it be lower on OOP code-base?
- There is no namespace used, is it good or bad ?
The final question How do you analyse a code-base with phploc's output?
Source: (StackOverflow)
in my buildfile I use phploc as described in jenkins-php.org but it just won't ignore folders.
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg value="--log-csv" />
<arg value="${basedir}/build/logs/phploc.csv" />
<arg value="--exclude"/>
<arg value="${basedir}/include/library" />
<arg path="${basedir}"/>
</exec>
</target>
It works with this command on console in the project directory:
phploc --log-csv build/logs/phploc.csv --exclude include/library .
But why not in my buildfile? It always runs through the whole Zend library under library.
Oh and phpcpd is the same issue. In the console it's right, running it with ant not...
Source: (StackOverflow)
I've looked at both these posts.. they don't help:
If I run phploc at a shell prompt, it works just fine. So it must be something with my build.xml
file... but I don't know what.
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg path="${basedir}/../src" />
<arg value="--log-csv" />
<arg value="${basedir}/build/logs/phploc.csv" />
</exec>
</target>
This works fine:
C:\projects\project1\build>phploc ../src
phploc 2.0.6 by Sebastian Bergmann.
My folder structure is
c:\projects\project1
build
...
vendor
bin
...
src
tests
c:\projects\project1\build>ant
phploc:
BUILD FAILED
C:\projects\project1\build\build.xml:55: Execute failed: java.io.IOException:
Cannot run program "phploc": CreateProcess error=2, The system cannot find the
file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Jav
UPDATE
C:\>where phploc
INFO: Could not find files for the given pattern(s).
What am I missing?
Source: (StackOverflow)