This task runs phpcpd, a Copy/Paste Detector (CPD) for PHP Code. You need an installed version of this software to use this task.
NB: if you have installed the
PHPCPD PHAR, 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 |
minTokens | Integer | Sets the minimum number of identical tokens (default: 70) | 70 | No |
minLines | Integer | Sets the minimum number of identical lines (default: 5) | 5 | No |
format | String | The format for the report when no nested formatter is used. | default | No |
fuzzy | Boolean | If fuzzy is set to true, the task will perform a fuzzy match. | false | No |
pharlocation | String | Location of the PHPCPD PHAR package. | n/a | No |
<phpcpd file="path/to/source.php"/>
Checking for copy/paste code in one particular source file. Sending Default-Report to STDOUT.
<phpcpd file="path/to/source"> <formatter type="pmd" outfile="reports/pmd-cpd.xml"/> </phpcpd>
Checking for copy/paste code in files of the given path.
<phpcpd> <fileset dir="${builddir}" id="filestocpd"> <include name="apps/**/*.php" /> <include name="lib/de/**/*.php" /> <include name="lib/task/**/*.php" /> <include name="lib/services/**/*.php" /> <include name="lib/form/**/*.php" /> <include name="lib/model/**/*.php" /> </fileset> <formatter type="pmd" outfile="reports/pmd-cpd.xml"/> </phpcpd>
This nested tag is required when the file
attribute is
not set.
formatter
The results of the copy/paste scan can be printed in different formats.
Output will always be sent to a file, unless you set the
usefile
attribute to false
.
Table C.70: Attributes
Name | Type | Description | Default | Required |
---|---|---|---|---|
type | String | The output format. Accepts the same values as the
format attribute
(default ,
pmd ). | n/a | Yes |
useFile | Boolean | Flag that determines whether output should be sent to a file or not. | true | No |
outfile | String | Path to write output file to. | n/a | Yes |