Mess detector


A mess detector can be used to find find complex pieces of code and make them more simple. It’s also a great tool to ensure a certain level of quality and make the library easier to maintain. This template uses phpmd which is a mess detector library for php that contains a set of rules which are used on your source code.

Getting started

Composer has been configured to run phpmd by running the command:

composer run mess-detector
> vendor/bin/phpmd ./src text cleancode,unusedcode,codesize,design,naming
./src/TFarla/ComposerTemplate/Example.php:11        Avoid unused private fields such as '$a'.
.//src/TFarla/ComposerTemplate/Example.php:11       Avoid variables with short names like $a. Configured minimum length is 3.
Script vendor/bin/phpmd ./src text cleancode,unusedcode,codesize,design,naming handling the mess-detector event returned with error code 2

The mess-detector script uses the default configuration for the following rules:

It’s also possible to create your own ruleset to have more control over the rules. This will allow you to create exceptions for specific violations when desired.