This task runs phpmd, a Project Mess Detector (PMD) for PHP Code. You need an installed version of this software to use this task.
NB: if you have installed the
PHPMD Phar file, make sure you set the
pharLocation
attribute!
Table C.69: Attributes
Name | Type | Description | Default | Required |
---|---|---|---|---|
file | String | Path to source file or path | n/a | Only when there are no nested
fileset elements |
rulesets | String | Sets the rulesets used for analyzing the source code | codesize, unusedcode | No |
minimumPriority | Integer | The minimum priority for rules to load. | 5 | No |
allowedFileExtensions | String | Comma-separated list of valid file extensions (without dot) for analyzed files. | php | No |
ignorePatterns | String | Comma-separated list of directory patterns to ignore. | .git , .svn ,
CVS , .bzr ,
.hg | No |
format | String | The format for the report when no nested formatter is used. | text | No |
pharlocation | String | Location of the PHPMD Phar file. | n/a | No |
cachefile | String | If set, enables writing of last-modified times to
cachefile , to speed up processing of files that
rarely change | none | No |
<phpmd file="path/to/source.php"/>
Checking syntax of one particular source file. Sending Text-Report to STDOUT.
<phpmd file="path/to/source"> <formatter type="html" outfile="reports/pmd.html"/> </phpmd>
Checking syntax of source files in the given path.
<phpmd> <fileset dir="${builddir}"> <include name="apps/**/*.php" /> <include name="lib/de/**/*.php" /> </fileset> <formatter type="xml" outfile="reports/pmd.xml"/> </phpmd>
Checking syntax of source files in the fileset pathes.
This nested tag is required when the file
attribute is
not set.
formatter
The results of the analysis can be printed in different formats. Output
will always be sent to STDOUT, unless you set the usefile
attribute to true
and set an filename in the
outfile
attribute.
Table C.70: Attributes
Name | Type | Description | Default | Required |
---|---|---|---|---|
type | String | The output format. Accepts the same values as the
format attribute
(xml , html ,
text ). | n/a | Yes |
usefile | Boolean | Boolean that determines whether output should be sent to a file. | true | No |
outfile | String | Path to write output file to. | n/a | Yes |