Skip to content

Commit

Permalink
Merge branch 'docs/cleanup-readme' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegrunwell committed May 28, 2017
2 parents 7cf6f1f + cdbb4b4 commit ece61ce
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

* Allow any version of [wp-coding-standards/wpcs](https://github.com/wp-coding-standards/wpcs), avoiding conflicts with packages that use older versions.
* Allow any version of [wp-coding-standards/wpcs](https://github.com/wp-coding-standards/wpcs), avoiding conflicts with packages that use older versions ([#37]).
* Clarify placement of scripts within `composer.json` ([#41]).
* Exclude `phpcs.xml` from being checked by PHP_CodeSniffer ([#27]).


## [0.4.2] - 2017-01-04
Expand Down Expand Up @@ -61,4 +63,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
[#11]: https://github.com/stevegrunwell/wp-enforcer/issues/11
[#12]: https://github.com/stevegrunwell/wp-enforcer/issues/12
[#19]: https://github.com/stevegrunwell/wp-enforcer/issues/19
[#27]: https://github.com/stevegrunwell/wp-enforcer/issues/27
[#29]: https://github.com/stevegrunwell/wp-enforcer/issues/29
[#37]: https://github.com/stevegrunwell/wp-enforcer/issues/37
[#41]: https://github.com/stevegrunwell/wp-enforcer/issues/41
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,33 @@ WP Enforcer uses [Git Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-
The easiest way to install WP Enforcer is via Composer:

```bash
$ composer require stevegrunwell/wp-enforcer --dev
$ composer require --dev stevegrunwell/wp-enforcer
```

This will add WP Enforcer to your composer.json file and install the WP Enforcer package.
This will add WP Enforcer to your `composer.json` file and install the WP Enforcer package.

Next, you'll need to run the WP Enforcer installation script to copy the Git hooks into your local repository:

```bash
$ ./vendor/bin/wp-enforcer
```

If you'd like to require WP Enforcer for all developers on your project, you can add the following commands to your composer.json file to have WP Enforcer automatically set up Git hooks on `composer install` and `composer update`:
If you'd like to require WP Enforcer for all developers on your project, you can add the following scripts to your `composer.json` file to have WP Enforcer automatically set up Git hooks on `composer install` and `composer update` (for more information, please see [Composer Scripts](https://getcomposer.org/doc/articles/scripts.md)):

```json
"post-install-cmd": [
"wp-enforcer"
],
"post-update-cmd": [
"wp-enforcer"
]
{
"scripts": {
"post-install-cmd": [
"wp-enforcer"
],
"post-update-cmd": [
"wp-enforcer"
]
}
}
```


### Writing for WordPress.com VIP

WP Enforcer includes built-in support for the [WordPress.com VIP coding standards](https://vip.wordpress.com/documentation/developers-guide-to-wordpress-com-vip/), simply add `--vip` when you run the `wp-enforcer` command (including in the post-install and post-update commands).
Expand All @@ -52,9 +57,11 @@ If you need to switch an existing project to the WordPress.com VIP coding standa
<rule ref="WordPress-VIP" />
```


### Using a custom ruleset

If you want to use a custom XML configuration file with PHPCS, add `--ruleset=[FILE]` when you run the `wp-enforcer` command.
If you want to use a custom XML configuration file with PHP_CodeSniffer, add `--ruleset=[FILE]` when you run the `wp-enforcer` command.


## Configuration

Expand All @@ -79,11 +86,12 @@ This leaves you with a copy of PHP_CodeSniffer, a phpcs.xml file, and the WordPr
```bash
$ ./vendor/bin/phpcs
```

You may also run PHP Code Beautifier and Fixer, which can fix many common indentation and formatting issues automatically, using the PHP Code Beautifier and Fixer (phpcbf) command:

```bash
$ ./vendor/bin/phpcbf
``
```

Once CodeSniffer comes back clean, re-run the WP Enforcer installation script to restore the Git hook, forcing all future commits to be clean:

Expand All @@ -92,3 +100,10 @@ $ ./vendor/bin/wp-enforcer
```

Finally, merge your clean-up branch into master, kicking your project's coding standards compliance into high gear.


## Bypassing WP Enforcer

If it's necessary to bypass WP Enforcer's sniffs for a particular commit (for instance, you're committing small chunks of a file that has older, non-compliant code) you may do so by using [`git commit --no-verify`](https://git-scm.com/docs/git-commit#git-commit--n).

It's recommended that WP Enforcer is only bypassed when making changes in legacy files that simply haven't been cleaned up yet. For more on integrating WP Enforcer with legacy projects, please see [Adding to an Existing Project](#adding-to-an-existing-project).
2 changes: 1 addition & 1 deletion phpcs-vip.xml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<description>Coding standards from WP Enforcer.</description>

<!-- FILES -->

<exclude-pattern>phpcs.xml</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>

Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<description>Coding standards from WP Enforcer.</description>

<!-- FILES -->

<exclude-pattern>phpcs.xml</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>

Expand Down

0 comments on commit ece61ce

Please sign in to comment.