Skip to content

Commit

Permalink
PHPCS: document run parameters in project ruleset (#107)
Browse files Browse the repository at this point in the history
* PHPCS: document run parameters in project ruleset

This makes it easier to run the PHPCS command for the project.

Includes:
* Adding the `Tests` directory to the run - excluding the test case files in `fixtures`.
* Cleaning up the result report by using the `basepath` configuration.
* Making the run faster by using `parallel` scanning if available,

* Composer: remove `lint-self` and add ruleset to the PHPCS config instead
  • Loading branch information
jrfnl authored and sirbrillig committed Jan 17, 2020
1 parent 06dda92 commit 51fe610
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jobs:
- run: COMPOSER=composer.json composer test
- run: COMPOSER=composer.json composer phpstan
- run: COMPOSER=composer.json composer lint
- run: COMPOSER=composer.json composer lint-self
build_php5:
docker:
- image: circleci/php:5.6.40-zts-stretch-node-browsers-legacy
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
"prefer-stable": true,
"scripts": {
"test": "./vendor/bin/phpunit",
"lint": "./vendor/bin/phpcs -s -p VariableAnalysis/Sniffs VariableAnalysis/Lib",
"lint-self": "./vendor/bin/phpcs --standard=./VariableAnalysis -s -p VariableAnalysis/Sniffs VariableAnalysis/Lib",
"lint": "./vendor/bin/phpcs",
"phpstan": "./vendor/bin/phpstan analyse -l 7 VariableAnalysis"
},
"require" : {
Expand Down
18 changes: 18 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
- bracers on end of line instead new line
- two space indentation
</description>

<file>./VariableAnalysis/</file>
<exclude-pattern>./VariableAnalysis/Tests/CodeAnalysis/fixtures/</exclude-pattern>

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

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

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

<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8"/>

<!-- Rules -->
<rule ref="PSR2">
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
<exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine" />
Expand All @@ -31,4 +48,5 @@
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
<rule ref="Generic.Classes.OpeningBraceSameLine"/>
<rule ref="ImportDetection" />
<rule ref="VariableAnalysis"/>
</ruleset>

0 comments on commit 51fe610

Please sign in to comment.