Skip to content

Commit cde635b

Browse files
jrfnlgrogy
authored andcommitted
PHPCS: tweak ruleset
* Rename the ruleset to one which PHPCS will recognize automatically. This means you no longer need to pass the `--standard` on the command-line. * Use the `dist` extension to allow for devs to overload the ruleset file locally and gitignore the typical overload file names which are recognized by PHPCS by default. * Ruleset/Travis: move command-line arguments to the project ruleset. ... and scan all PHP files, not just the files in `src`. * Ruleset: also scan the `phpt` test files. * Ruleset: enable parallel scanning. * Ruleset: set the basepath for a cleaner output report. * Ruleset: add the PHPCS XML scheme. * Ruleset: selectively exclude the `skip-linting.php` file for the `Generic.PHP.NoSilencedErrors` rule.
1 parent 6d18571 commit cde635b

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

.gitattributes

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
/box.json export-ignore
1313
/doc export-ignore
1414
/phpcs.xml.dist export-ignore
15-
/phpcs-ruleset.xml export-ignore
1615
/tests export-ignore
1716

1817
#

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
/vendor
22
composer.lock
3+
.phpcs.xml
4+
phpcs.xml

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ script:
2828
- ./vendor/bin/tester -p php tests
2929
- ./parallel-lint --exclude vendor --exclude tests/examples --no-colors .
3030
- ./parallel-lint --exclude vendor --exclude tests/examples .
31-
- if [[ "$SNIFF" == "1" ]]; then ./vendor/bin/phpcs --standard=phpcs-ruleset.xml -s src;fi
31+
- if [[ "$SNIFF" == "1" ]]; then ./vendor/bin/phpcs;fi

phpcs-ruleset.xml renamed to phpcs.xml.dist

+35-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
11
<?xml version="1.0"?>
2-
<ruleset name="PHP-Parallel-Lint">
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP-Parallel-Lint" xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
33
<description>PHP Parallel Lint coding standard.</description>
44

5+
<!--
6+
#############################################################################
7+
COMMAND LINE ARGUMENTS
8+
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
9+
#############################################################################
10+
-->
11+
12+
<file>.</file>
13+
14+
<!-- Exclude the Examples directory and the Composer vendor directory. -->
15+
<exclude-pattern>*/tests/examples/*</exclude-pattern>
16+
<exclude-pattern>*/vendor/*</exclude-pattern>
17+
18+
<!-- Only check PHP files. -->
19+
<arg name="extensions" value="php,phpt/php"/>
20+
21+
<!-- Show progress, show the error codes for each message (source). -->
22+
<arg value="ps"/>
23+
24+
<!-- Strip the filepaths down to the relevant bit. -->
25+
<arg name="basepath" value="./"/>
26+
27+
<!-- Check up to 8 files simultaneously. -->
28+
<arg name="parallel" value="8"/>
29+
30+
<!--
31+
#############################################################################
32+
RULES
33+
#############################################################################
34+
-->
35+
536
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
637
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
738
<rule ref="PEAR.Functions.FunctionDeclaration"/>
@@ -20,7 +51,9 @@
2051

2152
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
2253
<rule ref="Generic.PHP.LowerCaseConstant"/>
23-
<rule ref="Generic.PHP.NoSilencedErrors"/>
54+
<rule ref="Generic.PHP.NoSilencedErrors">
55+
<exclude-pattern>/bin/skip-linting\.php$</exclude-pattern>
56+
</rule>
2457
<rule ref="Squiz.PHP.GlobalKeyword"/>
2558
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
2659
<rule ref="Squiz.PHP.NonExecutableCode"/>

0 commit comments

Comments
 (0)