Skip to content

Commit

Permalink
PHPCS: various improvements
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
jrfnl authored and grogy committed May 8, 2021
1 parent e0d333f commit cc91801
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.travis.yml export-ignore
build.xml export-ignore
phpunit.xml.dist export-ignore
phpcs.xml.dist export-ignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/composer.lock
phpunit.xml
.phpunit.result.cache
.phpcs.xml
phpcs.xml
6 changes: 2 additions & 4 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@
<target name="phpcs" depends="prepare" description="Check PHP code style">
<delete file="${basedir}/build/logs/checkstyle.xml" quiet="true" />

<exec executable="${phpcs}">
<arg line='--extensions=php' />
<arg line='--standard="${basedir}/vendor/php-parallel-lint/php-code-style/ruleset.xml"' />
<exec executable="${phpcs}" failonerror="true">
<arg line='--report-checkstyle="${basedir}/build/logs/checkstyle.xml"' />
<arg line='--report-full' />
<arg line='"${basedir}/src"' />
<arg line='--runtime-set ignore_warnings_on_exit 1' />
</exec>
</target>

Expand Down
21 changes: 21 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<ruleset name="Jakub Onderka Coding Standard">
<description>A coding standard for Jakub Onderka's projects.</description>

<file>./src/</file>

<!-- Only check PHP files. -->
<arg name="extensions" value="php"/>

<!-- Show progress, show the error codes for each message (source). -->
<arg value="ps"/>

<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>

<rule ref="./vendor/php-parallel-lint/php-code-style/ruleset.xml"/>

<rule ref="Generic.Metrics.CyclomaticComplexity.MaxExceeded">
<type>warning</type>
</rule>
</ruleset>

0 comments on commit cc91801

Please sign in to comment.