Skip to content

Commit cc91801

Browse files
jrfnlgrogy
authored andcommitted
PHPCS: various improvements
* PHPCS: add a PHPCS configuration file containing all the common command-line parameters. This file will be automatically picked up by PHPCS and can be overruled locally by a `[.]phpcs.xml` file. Includes downgrading the cyclomatic complexity error to a warning. * Ant: remove the configuration CLI arguments which are now contained in the `phpcs.xml.dist` file from the `build.xml` task configuration. * Ant: add a CLI argument which will ignore CS warnings when determining the exit code, but will still _show_ warnings in the report. Using this will also allow for enabling `failonerror` for the build step. * Git: Add the `phpcs.xml.dist` file to the `.gitattributes` file to be ignored when packaging a release. * Git: Add the potential local overload files to the `.gitignore` file.
1 parent e0d333f commit cc91801

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
.travis.yml export-ignore
66
build.xml export-ignore
77
phpunit.xml.dist export-ignore
8+
phpcs.xml.dist export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
/composer.lock
55
phpunit.xml
66
.phpunit.result.cache
7+
.phpcs.xml
8+
phpcs.xml

build.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,10 @@
5252
<target name="phpcs" depends="prepare" description="Check PHP code style">
5353
<delete file="${basedir}/build/logs/checkstyle.xml" quiet="true" />
5454

55-
<exec executable="${phpcs}">
56-
<arg line='--extensions=php' />
57-
<arg line='--standard="${basedir}/vendor/php-parallel-lint/php-code-style/ruleset.xml"' />
55+
<exec executable="${phpcs}" failonerror="true">
5856
<arg line='--report-checkstyle="${basedir}/build/logs/checkstyle.xml"' />
5957
<arg line='--report-full' />
60-
<arg line='"${basedir}/src"' />
58+
<arg line='--runtime-set ignore_warnings_on_exit 1' />
6159
</exec>
6260
</target>
6361

phpcs.xml.dist

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Jakub Onderka Coding Standard">
3+
<description>A coding standard for Jakub Onderka's projects.</description>
4+
5+
<file>./src/</file>
6+
7+
<!-- Only check PHP files. -->
8+
<arg name="extensions" value="php"/>
9+
10+
<!-- Show progress, show the error codes for each message (source). -->
11+
<arg value="ps"/>
12+
13+
<!-- Strip the filepaths down to the relevant bit. -->
14+
<arg name="basepath" value="./"/>
15+
16+
<rule ref="./vendor/php-parallel-lint/php-code-style/ruleset.xml"/>
17+
18+
<rule ref="Generic.Metrics.CyclomaticComplexity.MaxExceeded">
19+
<type>warning</type>
20+
</rule>
21+
</ruleset>

0 commit comments

Comments
 (0)