Skip to content

Commit

Permalink
Merge pull request #8 from gocodebox/upgrade-wpcs
Browse files Browse the repository at this point in the history
Upgrade WPCS to v3
  • Loading branch information
brianhogg authored Apr 5, 2024
2 parents e24a65f + 9bd85bd commit 210afd2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 30 deletions.
21 changes: 2 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,22 @@ LifterLMS Coding Standards (LifterLMS-CS) is a project with rulesets for code st

To include in a project require as a development dependency:

`composer require lifterlms/lifterlms-cs:dev-master --dev`

Note that Composer won't run configuration scripts in this scenario and the root project needs to take care of it.

After installing setup configurations:

+ `./vendor/bin/phpcs --config-set installed_paths ../../../vendor/wp-coding-standards/wpcs,../../../vendor/lifterlms/lifterlms-cs,../../../vendor/phpcompatibility/php-compatibility,../../../vendor/phpcompatibility/phpcompatibility-paragonie,../../../vendor/phpcompatibility/phpcompatibility-wp`
+ `./vendor/bin/phpcs --config-set default_standard LifterLMS"`
`composer require lifterlms/lifterlms-cs:dev-trunk --dev`

If you are upgrading from the old version, be sure to remove any references to manually setting the `installed_paths`as they are now automatically set by Composer.

## Using PHPCS & PHPCBF

Access the PHPCS execultable via: `./vendor/bin/phpcs`
Check for errors only: `./vendor/bin/phpcs --error-severity=1 --warning-severity=6`
Fix errors via PHPCBF: `./vendor/bin/phpcbf`


## Predefined scripts

The following scripts can be added to your `composer.json` file for easy access to thes scripts & to ensure configurations are automatically set during package installation and updates.

```json
"scripts": {
"config-cs": [
"\"vendor/bin/phpcs\" --config-set installed_paths ../../../vendor/wp-coding-standards/wpcs,../../../vendor/lifterlms/lifterlms-cs,../../../vendor/phpcompatibility/php-compatibility,../../../vendor/phpcompatibility/phpcompatibility-paragonie,../../../vendor/phpcompatibility/phpcompatibility-wp",
"\"vendor/bin/phpcs\" --config-set default_standard LifterLMS"
],
"check-cs": [
"\"vendor/bin/phpcs\" --colors"
],
Expand All @@ -43,12 +32,6 @@ The following scripts can be added to your `composer.json` file for easy access
],
"fix-cs": [
"\"vendor/bin/phpcbf\""
],
"post-install-cmd": [
"composer config-cs"
],
"post-update-cmd": [
"composer config-cs"
]
}
```
Expand Down
23 changes: 12 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@
}
],
"require": {
"php": ">=5.6",
"squizlabs/php_codesniffer": "^3.3.2",
"wp-coding-standards/wpcs": "^2.1.1",
"phpcompatibility/phpcompatibility-wp": "^2.0.0",
"phpmd/phpmd": "^2.6.0"
"php": ">=7.4",
"wp-coding-standards/wpcs": "^3.0.0",
"phpcompatibility/phpcompatibility-wp": "^2.1"
},
"require-dev": {
"phpcompatibility/php-compatibility": "^9.0.0",
"roave/security-advisories": "dev-master"
},
"scripts": {
"config-set" : [
"\"vendor/bin/phpcs\" --config-set installed_paths ../../..,../../../vendor/wp-coding-standards/wpcs,../../../vendor/phpcompatibility/php-compatibility,../../../vendor/phpcompatibility/phpcompatibility-wp",
"\"vendor/bin/phpcs\" --config-set default_standard LifterLMS"
"\"vendor/bin/phpcs\" --config-set default_standard LifterLMS"
],
"check-cs": [
"\"vendor/bin/phpcs\" --runtime-set testVersion 5.6-"
"\"vendor/bin/phpcs\" --runtime-set testVersion 7.4-"
],
"post-install-cmd": "composer config-set",
"post-update-cmd": "composer config-set"
"post-install-cmd": "@config-set",
"post-update-cmd": "@config-set"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}

0 comments on commit 210afd2

Please sign in to comment.