Skip to content

Commit

Permalink
Merge pull request #9 from jimdelois/feature-continued-qa-tools
Browse files Browse the repository at this point in the history
Continued PHP QA Tooling
  • Loading branch information
jimdelois committed Sep 23, 2015
2 parents e1a3318 + b8c665e commit 5e3b7cc
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ install:
composer install --no-interaction

script:
php ./vendor/bin/phing test
php ./vendor/bin/phing static-analysis test

after_success:
php ./vendor/bin/coveralls -v
132 changes: 122 additions & 10 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@

<property name="exec.php" value="/usr/bin/php" override="true" />
<property name="dir.build" value="build" />
<property name="dir.build.reports" value="${dir.build}/reports" />

<includepath classpath="./vendor/bin" />

<tstamp>
<format property="timestamp" pattern="%Y-%m-%d %H:%M" />
</tstamp>



<target name="static-analysis" depends="loc,cpd,pdepend,phpmd" />

<target name="test" depends="prepare,sniff,test-unit" />

<target name="build" depends="test,documentapi" />
<target name="build" depends="static-analysis,test,documentapi" />



Expand Down Expand Up @@ -50,14 +55,12 @@

<target name="sniff" depends="lint">

<includepath classpath="./vendor/squizlabs/php_codesniffer/scripts" />

<mkdir dir="${dir.build}/reports" />
<mkdir dir="${dir.build.reports}" />

<phpcodesniffer
standard="PSR2"
docGenerator="HTML"
docFile="${dir.build}/reports/sniffs-guide.html"
docFile="${dir.build.reports}/sniffs-guide.html"
verbosity="0"
haltonerror="true"
haltonwarning="true"
Expand All @@ -66,9 +69,11 @@
showWarnings="true"
>

<formatter type="full" outfile="${dir.build}/reports/sniffs-full.txt"/>
<formatter type="summary" outfile="${dir.build}/reports/sniffs-summary.txt"/>
<formatter type="checkstyle" outfile="${dir.build}/reports/sniffs-checkstyle.xml"/>
<formatter type="full" outfile="${dir.build.reports}/sniffs-full.txt"/>
<formatter type="summary" outfile="${dir.build.reports}/sniffs-summary.txt"/>
<formatter type="checkstyle" outfile="${dir.build.reports}/sniffs-checkstyle.xml"/>

<formatter type="full" outfile="irrelevant-value" usefile="false"/>

<fileset dir="src">
<include name="**/*.php"/>
Expand All @@ -81,8 +86,115 @@
</target>


<target name="loc" depends="sniff">

<mkdir dir="${dir.build.reports}" />

<property name="path.reports.loc" value="${dir.build.reports}/phploc-report.txt" />

<delete file="${path.reports.loc}" verbose="true" />

<phploc reportType="txt" reportDirectory="${dir.build.reports}" reportName="phploc-report">
<fileset dir="src">
<include name="**/*.php"/>
</fileset>
</phploc>

<exec
executable="cat"
checkreturn="false"
passthru="true">
<arg path="${path.reports.loc}" />
</exec>

</target>

<target name="cpd" depends="sniff">

<mkdir dir="${dir.build.reports}" />

<property name="path.reports.phpcpd.xml" value="${dir.build.reports}/phpcpd-report.xml" />
<property name="path.reports.phpcpd.txt" value="${dir.build.reports}/phpcpd-report.txt" />

<delete file="${path.reports.phpcpd.xml}" verbose="true" />
<delete file="${path.reports.phpcpd.txt}" verbose="true" />

<phpcpd>
<fileset dir="src">
<include name="**/*.php"/>
</fileset>
<formatter type="pmd" outfile="${path.reports.phpcpd.xml}"/>
<formatter type="default" outfile="${path.reports.phpcpd.txt}"/>
<formatter type="default" useFile="false" outfile="${path.reports.phpcpd.txt}"/>
</phpcpd>

</target>

<target name="pdepend">

<mkdir dir="${dir.build.reports}" />

<delete file="${dir.build.reports}/pdepend-chart.svg" verbose="true" />
<delete file="${dir.build.reports}/pdepend.xml" verbose="true" />
<delete file="${dir.build.reports}/pdepend-overview-pyramid.svg" verbose="true" />
<delete file="${dir.build.reports}/pdepend-phpunit.xml " verbose="true" />
<delete file="${dir.build.reports}/pdepend-summary.xml" verbose="true" />

<phpdepend>
<fileset dir="src">
<include name="**/*.php"/>
</fileset>

<!-- <analyzer type="coderank-mode" value="method"/> -->

<logger type="jdepend-xml" outfile="reports/jdepend.xml"/>
<logger type="jdepend-chart" outfile="${dir.build.reports}/pdepend-chart.svg" />
<logger type="jdepend-xml" outfile="${dir.build.reports}/pdepend.xml" />
<logger type="overview-pyramid" outfile="${dir.build.reports}/pdepend-overview-pyramid.svg" />
<logger type="summary-xml" outfile="${dir.build.reports}/pdepend-summary.xml" />

</phpdepend>

</target>


<target name="phpmd">

<mkdir dir="${dir.build.reports}" />

<delete file="${dir.build.reports}/phpmd.html" verbose="true"/>
<delete file="${dir.build.reports}/phpmd.xml" verbose="true"/>
<delete file="${dir.build.reports}/phpmd.txt" verbose="true"/>

<property name="phpmd.rulesets" value="cleancode,codesize,design,naming,unusedcode" />

<!-- We run this task to generate all the right reports... -->
<phpmd rulesets="${phpmd.rulesets}" minimumPriority="0">

<fileset dir="src">
<include name="**/*.php"/>
</fileset>
<fileset dir="tests">
<include name="**/*.php"/>
</fileset>

<formatter type="html" outfile="${dir.build.reports}/phpmd.html"/>
<formatter type="xml" outfile="${dir.build.reports}/phpmd.xml"/>
<formatter type="text" outfile="${dir.build.reports}/phpmd.txt"/>

</phpmd>

<!-- This is the only way to get output to the screen and to FAIL the build -->
<exec executable="./vendor/bin/phpmd" checkreturn="true" logoutput="true" passthru="true">
<arg path="src,tests" />
<arg value="text" />
<arg value="${phpmd.rulesets}" />
</exec>

</target>


<target name="documentapi">
<includepath classpath="./vendor/phpdocumentor" />

<mkdir dir="${dir.build}/docs/api" />

Expand All @@ -102,7 +214,7 @@

<target name="test-unit" depends="lint">
<exec
executable="./vendor/bin/phpunit"
executable="./vendor/bin/phpunit-randomizer"
dir="."
checkreturn="true"
passthru="true"
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
"phpdocumentor/phpdocumentor": "~2.8.0",
"fiunchinho/phpunit-randomizer": "~2.0.0",
"squizlabs/php_codesniffer": "^2.3",
"satooshi/php-coveralls": "^0.6.1"
"satooshi/php-coveralls": "^0.6.1",
"phploc/phploc": "^2.1",
"sebastian/phpcpd": "^2.0",
"pdepend/pdepend": "^2.2",
"phpmd/phpmd": "^2.3"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/Request/MethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class MethodTest extends \PHPUnit_Framework_TestCase
* @dataProvider validMethodProvider
*
* @covers ::isValid
*
* @SuppressWarnings(PHPMD.StaticAccess)
*/
public function testIsValidMethod($code, $expected)
{
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/Response/CodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class CodeTest extends \PHPUnit_Framework_TestCase
* @dataProvider validCodeProvider
*
* @covers ::isValid
*
* @SuppressWarnings(PHPMD.StaticAccess)
*/
public function testIsValidCode($code, $expected)
{
Expand Down

0 comments on commit 5e3b7cc

Please sign in to comment.