PHPMD configuration

PHPMD requires configuration via a codesize.xml configuration file as detailed in PHPMD's documentation.

If you don't specify your custom configuration file we use our default below. We suggest to add your own configuration file into your repository root directory to be able to specify your coding and quality standards.


<ruleset name="phpmd"
    <description>PHPMD Rules</description>

    <rule ref="rulesets/cleancode.xml" />
    <rule ref="rulesets/codesize.xml" />
    <rule ref="rulesets/design.xml" />
    <rule ref="rulesets/controversial.xml" />
    <rule ref="rulesets/unusedcode.xml" />
    <rule ref="rulesets/naming.xml" />

Ignoring files

Storing generated or third party code in your repository is in general not a good idea. However, sometimes you really need to do this and Codeac got you covered. Usually you don't want to analyze those files so you can place .codesizeignore file to the root folder of your repository. This file can contain regular expressions that are matched with paths in your project and excluded from the analysis. The syntax is identical with popular gitignore format.

Take a look on this simple example with Composer and Protocol Buffers:


# 3rd party libraries

# Protocol Buffers

If you are dealing with any special type of project structure, please, let us know. We are happy to help you.

Cyclomatic Complexity Example

In its simplest form, Cyclomatic Complexity in PHP is a count of the number of decisions in the source code. The higher the count, the more complex the code.

PHP Cyclomatic complexity