PHPMD is an analysis tool focused on detecting code smells and possible errors in source code.
To start using PHPMD, enable it in Repository Settings.
You can use
sider.yml to configure PHPMD.
PHPMD sometimes raises analysis timeout with a larger codebase.
To mitigate this, Sider deletes files that are not changed in the pull request. This behavior is automatically done and cannot be disabled.
If PHPMD still raises timeout, you can reduce target files of PHPMD analysis by using the
linter: phpmd: target: - index.php - wp-content/
Here is are some example settings for PHPMD in
linter: phpmd: target: - index.php - wp-content rule: codesize,unusedcode minimumpriority: 3 suffixes: php,phtml exclude: app/Vendor/ strict: true custom_rule_path: - Custom_PHPMD_Rule.php - custom/phpmd/rules/**/*.php
You can use several options to fine-tune PHPMD to your project:
|-||A root directory.|
|Set target files or directories to analyze.|
|-||Specify rulesets or your own ruleset file.|
|-||Set the priority threshold which PHPMD ignores.|
|Set extensions of filenames for analysis.|
|-||Set files or directories to exclude from analysis.|
|File path(s) writing your custom rule(s).|
This option controls target paths to inspect. This is an optional setting that you do not need to specify if you don't have any performance issues.
This option controls ruleset(s) that is passed to
phpmd. You can specify a comma-separated list of ruleset names:
linter: phpmd: rule: cleancode,design,unusedcode
The valid names are:
You can also specify a ruleset file:
linter: phpmd: rule: path/to/your-ruleset.xml
If you omit this option, Sider analyzes by using the default configuration.
For more information about PHPMD rulesets, see the PHPMD rule documentation.
This option controls the rule priority threshold. Rules below the priority you declare will be ignored.
This option controls valid file extensions. Use a comma-separated list to inspect multiple file extensions, e.g.
This option controls directories to exclude from analysis objects.
Use a comma-separated list to ignore multiple directories, e.g.
This option controls whether to report nodes that have the
To learn more about
@SuppressWarnings, see the PHPMD documentation.
This option controls file path(s) where you write your own custom rule(s). You can use also glob format.
You will need to use it along with the
rule option. For example:
linter: phpmd: rule: custom_ruleset.xml custom_rule_path: - Custom_PHPMD_Rule.php - custom/phpmd/rules/**/*.php
<ruleset name="Your Custom Ruleset"> <rule name="SomeYourCustomRule" message="Please do not this." class="Custom_PHPMD_Rule" externalInfoUrl="https://example.com/phpmd/rules/custom-rule"> <priority>1</priority> </rule> </ruleset>
To learn about writing a custom rule, see the PHPMD documentation.