下面的重複代碼存在於兩個不同的控制器文件中,但build.xml中的複製粘貼檢測器在運行phing時不會拾取它。它生成的報告文件只是空的塊,如下所示。有人能告訴我我錯過了什麼嗎?build.xml複製+粘貼檢測器不會拾取重複的代碼
在此先感謝
探測器的報告:
<?xml version="1.0" encoding="UTF-8"?>
<pmd-cpd/>
[email protected]:$ bin/phpcpd src/Foo/TeBundle/Controller/Create/LeController.php
phpcpd 2.0.1-5-ga7488a0 by Sebastian Bergmann.
0.00% duplicated lines out of 134 total lines of code.
Time: 25 ms, Memory: 3.00Mb
- 控制器1: 的src /足球/ TeamBundle /控制器/新建/ CountryController.php
- 控制器2: SRC /Football/TeamBundle/Controller/Create/CityController.php
複製的代碼:
public function indexAction()
{
$form = $this->getForm();
if (is_null($form)) {
echo 'form empty';
} else {
echo 'not empty';
}
}
public function indexAction()
{
$form = $this->getForm();
if (is_null($form)) {
echo 'form empty';
} else {
echo 'not empty';
}
}
的build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="Sport" default="detect-copy-paste" basedir=".">
<!-- GLOBAL VARIABLES -->
<property name="dir-source" value="${project.basedir}/src" />
<property name="dir-report" value="test/report/phing" />
<!-- END -->
<!-- FILESET -->
<fileset id="sourcecode" dir="${dir-source}">
<include name="**/*.php" />
</fileset>
<!-- END -->
<!-- COPY and PASTE DETECTOR -->
<target name="detect-copy-paste" description="Checks similar code blocks.">
<echo msg="Checking similar code blocks ..." />
<phpcpd>
<fileset refid="sourcecode" />
<formatter type="pmd" outfile="${dir-report}/copypaste.xml" />
</phpcpd>
</target>
<!-- END -->
</project>
COMPOSER.JSON
{
"autoload": {
"psr-0": {
"": "src/",
"SymfonyStandard": "app/"
}
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.5.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0",
"sensio/framework-extra-bundle": "~3.0",
"incenteev/composer-parameter-handler": "~2.0",
"behat/behat": "2.5.*@stable",
"behat/behat-bundle": "1.0.0",
"behat/symfony2-extension": "1.1.2",
"behat/mink": "1.5.0",
"behat/mink-extension": "~1.3",
"behat/mink-selenium2-driver": "1.1.1",
"behat/mink-goutte-driver": "1.0.9",
"phing/phing": "2.8.2",
"squizlabs/php_codesniffer": "1.5.1",
"doctrine/doctrine-fixtures-bundle": "2.2.*",
"pdepend/pdepend": "2.0.*",
"phpmd/phpmd" : "2.0.*",
"sebastian/phpcpd": "@dev",
"sebastian/finder-facade": "~1.1",
"sebastian/version": "~1.0.3",
"symfony/console": "~2.2",
"phpunit/php-timer": "~1.0.4",
"theseer/fdomdocument": "~1.4"
}
}
你有相同手動運行phpmd命令時的結果? – COil 2014-09-21 17:37:52
「總共134行代碼中有0.00%重複的行」。 – BentCoder 2014-09-21 17:49:12
這很奇怪,因爲一切似乎進展順利沒有任何錯誤,但由於某種原因它不承認重複。 – BentCoder 2014-09-21 18:00:01