■phpcpd
重複コードチェック
■Plugin
phcpdで絞り込み
追加します
■設定
重複コード分析の集計
を選択
reports/phpcpd.xml
■結果
重複コードのメニューが追加になります
jenkinsへpluginを追加してみます
<?xml version="1.0" encoding="utf-8" ?>
<project name= "BuildTest" basedir= "." default= "main">
<target name="main" depends= "init,phpmd,phpcs,phpcpd,phpunit,phpdoc"></target>
<!-- init -->
<target name="init" >
<delete dir= "./reports" includeemptydirs= "true" />
<mkdir dir= "./reports" />
</target>
<!-- phpmd -->
<target name="phpcs">
<exec executable= "phpcs" output= "reports/phpcs.xml">
<arg line= "--report=checkstyle C:\\xampp\\htdocs\\test" />
</exec>
</target>
<target name="phpmd">
<phpmd rulesets="codesize,unusedcode,design,naming">
<fileset dir="C:\\xampp\\htdocs\\test">
<include name="*.php"/>
<exclude name="*Test.php"/>
</fileset>
<formatter type="xml" outfile="reports/pmd.xml"/>
</phpmd>
</target>
<!-- phpcpd -->
<target name="phpcpd">
<phpcpd>
<fileset dir="C:\\xampp\\htdocs\\test">
<include name="*.php"/>
</fileset>
<formatter type= "pmd" outfile= "reports/phpcpd.xml" />
</phpcpd>
</target>
<target name="phpunit">
<coverage-setup database="coverage/coverage.db">
<fileset dir="C:\\xampp\\htdocs\\test">
<exclude name="*Test.php"/>
</fileset>
</coverage-setup>
<phpunit codecoverage="true">
<formatter type="xml" outfile="reports/phpunit.xml"/>
<formatter type="clover" outfile="coverage/clover.xml"/>
<batchtest>
<fileset dir="C:\\xampp\\htdocs\\test">
<include name="*Test.php"/>
</fileset>
</batchtest>
</phpunit>
<coverage-report outfile="clover.xml">
<report todir="clover" />
</coverage-report>
</target>
<target name="phpdoc">
<exec command="phpdoc -d C:\\xampp\\htdocs\\test -t phpdoc"/>
</target>
</project>
■phpmd
バグの可能性をチェックします
■phpcs
コーディング規約違反をチェックします
■phpcpd
ソースに重複コード(コピペ)があるか調べます
■phpunit
単体テストを行います
■phpdoc
ドキュメントを作成します
となっています