Monday, March 21. 2011PHPMD 1.1.0 released
Version 1.1.0 of PHPMD was released on March the 20th 2011. The key features
for this release were two new rules. The first one utilizes the Coupling
Between Objects (CBO) metric to detect strongly coupled classes. The second
one detects the usage of PHP's questionable FeaturesBugfixes
DownloadYou can download release 1.1.0 through PHPMD's PEAR Channel Server or you can download the release as a Phar archive Wednesday, May 12. 2010Artikel zum Thema SoftwaremetrikenThis blog post is in German as the mentioned article was published in German.
In der heute erschienenen Ausgabe 4.10 des PHP Magazins ist auch ein Artikel von mir enthalten, und wie sollte es wohl anders sein *Trommelwirbel*, beschäftigt der sich mit dem Thema Softwaremetriken Über Kommentare, Anregungen und Kritik rund um den Artikel würde ich mich sehr freuen. Und sollte euch der Artikel gefallen haben, empfehle ich die Internationale PHP Conference 2010, die vom 30. Mai bis 2. Juni in Berlin stattfindet, an der ich teilnehmen und zwei Vorträge halten werden.
Posted by Manuel Pichler
in php, php_depend, phpmd, phpugdo, phpundercontrol, projects, staticReflection
at
09:04
| Comments (0)
| Trackbacks (0)
PHP-Magazin Artikel zum Thema SoftwaremetrikenThis blog post is in German as the mentioned article was published in German.
In der heute erschienenen Ausgabe 4.10 des PHP Magazins ist auch ein Artikel von mir enthalten, und wie sollte es wohl anders sein *Trommelwirbel*, beschäftigt der sich mit dem Thema Softwaremetriken Über Kommentare, Anregungen und Kritik rund um den Artikel würde ich mich sehr freuen. Und sollte euch der Artikel gefallen haben, empfehle ich die Internationale PHP Conference 2010, die vom 30. Mai bis 2. Juni in Berlin stattfindet, an der ich teilnehmen und zwei Vorträge halten werden.
Posted by Manuel Pichler
in php, php_depend, phpmd, phpugdo, phpundercontrol, projects, staticReflection
at
09:04
| Comments (0)
| Trackbacks (0)
Thursday, April 29. 2010Goodbye CologneAs many of you may already have noticed, there will be a big change in my career as a professional software engineer and architect this summer. Together with Kore and Toby I am in the process of founding a company. The focus of this company will be on services all around the whole quality life cycle in PHP projects. Under the hood of our company we will also offer support, trainings and consulting for several quality assurance tools, like pdepend, phpmd and phpUnderControl. For you, this opens a great opportunity. You can use the tools and the documentation, as well as participate in the community, as usual. But from now on you can also purchase professional support, if you get stuck or need general assitance. And when you miss a feature or need an individual extension for one of these tools, don't hesitate to contact us. I am really excited what cool things will happen in the next couple of years and I am looking forward to cowork with professionals like Toby and Kore. To finalize the little marketing for the company and its services
Posted by Manuel Pichler
in php, php_depend, phpmd, phpugdo, phpundercontrol, planet-php
at
13:20
| Comments (3)
| Trackbacks (0)
Defined tags for this entry: changes, company, consulting, php, phpmd, phpundercontrol, php_depend, quality, support, training
Thursday, April 8. 2010Howto create custom rule sets for PHPMDIn this blog post I will describe a useful feature in PHPMD that will simplify your life when it comes to create custom rule sets for PHPMD. PHPMD can be seen as an one level down/low level equivalent to PHP_CodeSniffer. It is a simple command line tool that can be used to check your application's source code for possible bugs, suboptimal or overcomplicated code. The current release of PHPMD ships with three default rule sets. The first set of rules tests the codesize of class, methods and functions. The second rule set contains rules that check your code for unused variables, methods etc. and finally there is a rule set that tests the code against some naming conventions. Normally when you start using a quality assurance tool, you will not want to use it's default configuration. Sometimes you would like to use only a subset, because the full stack will produce too much noise, or you would like to customize some thresholds, because the factory defaults do not fit to your environment. In this blog post I give a short introduction into PHPMD's rule set syntax and howto to create your own rule set, by reusing parts of the existing default configuration. If you would like to only pick some of the rules that come with PHPMD and you want to customize some of the predefined thresholds, you can do this by creating your own rule set file that references a custom collection of rules with an individual configuration. Starting with an empty ruleset.xml fileThe simpliest way to start with a new rule set is to copy one of the
existing files and remove all the rule-tags from the document body.
Otherwise you can use the following example as a template for your own
rule set file. You should change the content of the
<?xml version="1.0"?>
<ruleset name="My first PHPMD rule set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="
http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
My custom rule set that checks my code...
</description>
</ruleset>
Adding rule references to the new ruleset.xml fileThe first thing we would like to do is to add all unused code rules
to the new rule set file. This can simply be done with a
<?xml version="1.0"?>
<ruleset name="My first PHPMD rule set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="
http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
My custom rule set that checks my code...
</description>
<!-- Import the entire unused code rule set -->
<rule ref="rulesets/unusedcode.xml" />
</ruleset>
That's it. Now the custom rule set applies all unused code rules against the analyzed source code. We would also like to use the cyclomatic complexity rule from the
existing codesize set in our custom rule set. To achieve this we can
reuse the same syntax with a
<?xml version="1.0"?>
<ruleset name="My first PHPMD rule set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="
http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
My custom rule set that checks my code...
</description>
<!-- Import the entire unused code rule set -->
<rule ref="rulesets/unusedcode.xml" />
<!-- Import the entire cyclomatic complexity rule -->
<rule ref="rulesets/codesize.xml/CyclomaticComplexity" />
</ruleset>
Now that the new rule set uses the cyclomatic complexity rule we would
also like to customize some of the rule's properties. First we will
increase the rule's priority to the highest possible priority value
<?xml version="1.0"?>
<ruleset name="My first PHPMD rule set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="
http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
My custom rule set that checks my code...
</description>
<!-- Import the entire unused code rule set -->
<rule ref="rulesets/unusedcode.xml" />
<!--
Import the entire cyclomatic complexity rule and
customize the rule configuration.
-->
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<priority>1</priority>
<properties>
<property name="reportLevel" value="5" />
</properties>
</rule>
</ruleset>
You should know that PHPMD handles all custom settings additive. This means that PHPMD keeps the original configuration for every setting that isn't customized in a rule reference. Excluding rules from a rule setFinally we would like to reuse the naming rule set of PHPMD. But we
don't like the two variable naming rules, so that we must exclude them
from out rule set file. This exclusion can be achieved by declaring an
<?xml version="1.0"?>
<ruleset name="My first PHPMD rule set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="
http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
My custom rule set that checks my code...
</description>
<!-- Import the entire unused code rule set -->
<rule ref="rulesets/unusedcode.xml" />
<!--
Import the entire cyclomatic complexity rule and
customize the rule configuration.
-->
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<priority>1</priority>
<properties>
<property name="reportLevel" value="5" />
</properties>
</rule>
<!-- Import entire naming rule set and exclude rules -->
<rule ref="rulesets/naming.xml">
<exclude name="ShortVariable" />
<exclude name="LongVariable" />
</rule>
</ruleset>
ConclusionWith PHPMD's rule set syntax it is possible to customize all aspects of rules for your own needs and you can reuse every existing rule set xml file in your own set. You should take a look at PHPMD's rule documentation if it happens that you don't know what rules exist or you don't know exactly, which settings are available for one rule, while you create your own set of rules. Another good source of information are the rule set files that are shipped with PHPMD. You can get the latest PHPMD version from its PEAR channel: pear.phpmd.org mapi@arwen ~ $ pear channel-discover pear.pdepend.org mapi@arwen ~ $ pear channel-discover pear.phpmd.org mapi@arwen ~ $ pear install --alldeps phpmd/PHP_PMD-alpha Or from our github repository: mapi@arwen ~ $ git clone git://github.com/manuelpichler/phpmd.git I would be glad if you file a ticket in PHPMD's issue tracker for all issues and/or enhancements you encounter while testing PHPMD.
Posted by Manuel Pichler
in php, phpmd, phpugdo, planet-php, projects
at
14:25
| Comments (0)
| Trackbacks (0)
Defined tags for this entry: annotations, customization, phpmd, quality assurance, rule set, static code analysis
Thursday, March 4. 2010PHPMD 0.2.3 released with @SuppressWarnings support and new rule set.We are proud to announce the 0.2.3 release of the PHP Mess Detector, a tool that takes source code and performs various tests to calculate various quality aspects from it. The measured values are a good starting point for future improvements. This release contains some new features, for example support for the @SuppressWarnings annotation, that allows you to exclude single methods or complete classes from PHPMD's analyzing process. This annotation can be used to suppress a single rule, a group of rules or PHPMD at all.
/**
* Suppress all PHPMD warnings for this class.
*
* @SuppressWarnings(PHPMD)
*/
class PHPMD_SuppressAll
{
}
class PHPMD_SuppressOnMethod
{
/**
* Do not warn about the unused parameter $bar.
*
* @SuppressWarnings(PHPMD.UnusedFormatParameter)
*/
public function foo($bar)
{
}
}
Beside several bugfixes this release comes with a new set of rules that check the naming of methods, variables etc. against common coding conventions and best practices.
You can get the latest PHPMD version from its PEAR channel: pear.phpmd.org mapi@arwen ~ $ pear channel-discover pear.pdepend.org mapi@arwen ~ $ pear channel-discover pear.phpmd.org mapi@arwen ~ $ pear install --alldeps phpmd/PHP_PMD-alpha Or from our github repository: mapi@arwen ~ $ git clone git://github.com/manuelpichler/phpmd.git
Posted by Manuel Pichler
in php, phpmd, phpugdo, projects
at
10:32
| Comments (0)
| Trackbacks (0)
Defined tags for this entry: annotations, phpmd, quality assurance, release announcement, static code analysis
Wednesday, January 20. 2010PHPMD wednesday... PHPMD 0.2.2, PHPMD Ant Task, PHPMD on GitHubToday I have released PHPMD 0.2.2, a minor bug fix release that solves some exit code issues in the previous version. Beside this, I am proud to announce the first release of the PHPMD Ant Task. It allows a seamless integration of PHPMD into your Ant build.xml file. So, please download the PHPMD Ant Task, test it and file bug reports or feature requests in PHPMD's issue tracker. You can get the latest PHPMD version from its PEAR channel: pear.phpmd.org mapi@arwen ~ $ pear channel-discover pear.pdepend.org mapi@arwen ~ $ pear channel-discover pear.phpmd.org mapi@arwen ~ $ pear install --alldeps phpmd/PHP_PMD-alpha Beside this two releases there is an additional news. From now on you can find an up-2-date mirror of PHPMD's subversion repository on github, so that you can fork PHPMD and participate on in development on these days social coding plattform. mapi@arwen ~ $ git clone git://github.com/manuelpichler/phpmd.git Tuesday, January 5. 2010PHP Mess Detector 0.2.1 releasedThis is just a small bugfix release of PHPMD. It introduces a small new feature that enables PHPMD's command line tool to handle multiple input files. This feature was required for some upcoming external features and extensions. Since version 0.2.1 you can call the command line tool of PHPMD with multiple input files and/or directories, separated by comma. mapi@arwen ~ $ phpmd phpmd,systemDaemon text unusedcode You can get the latest PHPMD version from its PEAR channel: pear.phpmd.org mapi@arwen ~ $ pear channel-discover pear.pdepend.org mapi@arwen ~ $ pear channel-discover pear.phpmd.org mapi@arwen ~ $ pear install --alldeps phpmd/PHP_PMD-alpha Tuesday, December 29. 2009PHP Mess Detector 0.2 released.Today I have released version 0.2.0 of the PHP Mess Detector or short PHPMD. PHPMD is a simple, customizable and user friendly frontend application for PHP_Depend. It takes the raw metrics measured by PHP_Depend, compares them with appropriate thresholds and generates a report that lists those software artifacts with potential problems. Such a report can be taken as a basis for human code audits or you can use it as input for an automated build/reporting tool. Most concepts behind PHPMD are based on those of the well known Java Tool PMD. It uses so called rule set files to organize different sets of rules. There are two purposes that are accomplished by these xml files. The first is to create custom sets of rules which fulfills the projects requirements. The second purpose is the configuration of each rule with thresholds, warning messages and other things. The format of these files is totally borrowed from PMD, so that the reuse existing rule sets in multi language environments should be easy. At the moment PHPMD has two build-in rule sets. One that detects software artifacts with high code size, and the second one detects unused code in your software.
Now lets start with a small How to use it. PHPMD can be called from the command line by typing mapi@arwen ~ $ phpmd Mandatory arguments: 1) A php source code filename or directory 2) A report format 3) A ruleset filename or a comma-separated string of ... Optional arguments that may be put after the mandato... --minimumpriority: rule priority threshold; rules with ... --reportfile: send report output to a file; default to ... --extensions: comma-separated string of valid source ... --ignore: comma-separated string of patterns that are ...
Now let's call PHPMD on its own source, with a simple text report on STDOUT and the mapi@arwen ~ $ phpmd ~/phpmd/source text codesize /home/mapi/phpmd/source/PHP/PMD/RuleSetFactory.php:66 \ This class has too many methods, consider refactoring it. /home/mapi/phpmd/source/PHP/PMD/RuleSetFactory.php:267 \ The method _parseSingleRuleNode() has a Cyclomatic \ Complexity of 11. /home/mapi/phpmd/source/PHP/PMD/RuleSetFactory.php:326 \ The method _parseRuleReferenceNode() has a Cyclomatic \ Complexity of 10.
The
mapi@arwen ~ $ phpmd ~/phpmd/source xml codesize,unusedcode \
--reportfile ~/pmd.xml
mapi@arwen ~ $ cat ~/pmd.xml
<?xml version="1.0" encoding="UTF-8" ?>
<pmd version="@package_version@" timestamp="...">
<file name=".../source/PHP/PMD/RuleSetFactory.php">
<violation beginline="66" endline="417" rule="TooManyMet ...>
This class has too many methods, consider refactoring it.
</violation>
<violation beginline="267" endline="315" rule="Cyclomati ...>
Method _parseSingleRule() has a Cyclomatic Complexity of 11.
</violation>
<violation beginline="326" endline="367" rule="Cyclomati ...>
Method _parseRuleReference() has a Cyclomatic Complexity of 10.
</violation>
</file>
</pmd>
This xml file is compatible with those files generated by PMD and PHPUnit's deprecated
Currently PHPMD supports the following three different report formats: Text, HTML and XML. And it has the build-in rule sets: You can get the latest PHPMD version from its PEAR channel: pear.phpmd.org mapi@arwen ~ $ pear channel-discover pear.pdepend.org mapi@arwen ~ $ pear channel-discover pear.phpmd.org mapi@arwen ~ $ pear install --alldeps phpmd/PHP_PMD-alpha
Posted by Manuel Pichler
in php, php_depend, phpmd, phpugdo, planet-php, projects
at
23:40
| Comments (2)
| Trackbacks (0)
(Page 1 of 1, totaling 9 entries)
|
ProjectsFurther stuffCategories |

