From 3c516d1062b0f344f2f4fbbcf53aed396da676bd Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 27 Jul 2023 11:45:41 +0100 Subject: [PATCH] Add documentation on overriding phpcs.xml --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 30bd80b9..77fc638d 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,31 @@ All the below static code analysis tests can be run with `task test:static` | PHPCS | task test:phpcs | Runs PHPCS with Drupal coding standards provided by [Coder module](https://www.drupal.org/project/coder | +#### Excluding Files from PHP_CodeSniffer + +`phpcs.xml` can be altered using Drupal's +[composer scaffold](https://www.drupal.org/docs/develop/using-composer/using-drupals-composer-scaffold#toc_4). + +- Edit `phpcs.xml` in the root of your project, e.g. to an exclude pattern: + ``` + + web/sites/sites.php + ``` +- Create a patch file + ``` + diff -urN vendor/lullabot/drainpipe-dev/scaffold/phpcs.xml phpcs.xml > patches/custom/phpcs.xml.patch + ``` +- Add the patch to `composer.json` + ``` + "scripts": { + "post-drupal-scaffold-cmd": [ + "patch phpcs.xml < patches/custom/phpcs.xml.patch" + ] + }, + ``` +- Delete the `vendor` directory and `phpcs.xml` and then run `composer install` + to verify everything works as expected + ### Functional Tests Functional tests require some mechanism of creating a functing Drupal site to