From a693b14fb20a644f0a6b697c467950390e9df3db Mon Sep 17 00:00:00 2001 From: Bec White Date: Thu, 10 Mar 2022 18:28:48 -0600 Subject: [PATCH 1/3] Move phpcs configuration from the-build into a phpcs.xml file. --- defaults.yml | 28 -------------------------- defaults/install/build.xml | 5 ++--- defaults/install/phpcs.xml | 40 ++++++++++++++++++++++++++++++++++++++ targets/install.xml | 11 +++++++++++ 4 files changed, 53 insertions(+), 31 deletions(-) create mode 100644 defaults/install/phpcs.xml diff --git a/defaults.yml b/defaults.yml index 00b3f969..b3744bfa 100644 --- a/defaults.yml +++ b/defaults.yml @@ -219,34 +219,6 @@ phplint: includesfile: "${build.thebuild.dir}/defaults/standard/phplint.txt" -# Configuration for using PHP_CodeSniffer to review code according to the Drupal coding -# standards. -# -# @see https://www.drupal.org/docs/develop/standards -# @see https://github.com/squizlabs/PHP_CodeSniffer -# @see https://www.drupal.org/project/coder -# -# These values are used in the defaults/build.xml template: -# $> phpcs --standard=${phpcs.standard} --ignore=${phpcs.ignore} ${phpcs.directories} -phpcs: - # Path to a PHP_CodeSniffer standard file. - standard: "${build.dir}/vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml" - - # Space-separated list of directories to review. - directories: "${drupal.root}/modules/custom ${drupal.root}/themes/custom" - - # Comma-separated list of patterns for files and directories to exclude from the - # PHP_CodeSniffer review. - # - # This is deprecated and will be removed in 3.0, and build.xml will need to be updated then to - # use the extensions option (below). This option should not be used with Coder >= 8.3.7, which only - # checks php, inc, css, and js by default. - ignore: "*.md" - - # Comma-separated list of extensions to check in the PHP_CodeSniffer review. - extensions: "php,module,inc,install,test,profile,theme,css,info,txt,yml,js" - - # Configuration for using PHP Mess Detector to check for general PHP best practices, # unused variables, and to analyze complexity. # diff --git a/defaults/install/build.xml b/defaults/install/build.xml index 026f1340..fd833ccc 100644 --- a/defaults/install/build.xml +++ b/defaults/install/build.xml @@ -117,9 +117,8 @@ - - - + + diff --git a/defaults/install/phpcs.xml b/defaults/install/phpcs.xml new file mode 100644 index 00000000..3da238a7 --- /dev/null +++ b/defaults/install/phpcs.xml @@ -0,0 +1,40 @@ + + + + + + PHP_CodeSniffer configuration. + + + + + + + + + + + + + + + + + + + + + docroot/modules/custom + docroot/themes/custom + + */behat + */node_modules + */vendor + + diff --git a/targets/install.xml b/targets/install.xml index 83fb62ca..e3c85a4c 100644 --- a/targets/install.xml +++ b/targets/install.xml @@ -186,6 +186,17 @@ + + + + + + + + + From f7cc3d507661469dc138b416a1ec8d7f475e1091 Mon Sep 17 00:00:00 2001 From: Bec White Date: Thu, 10 Mar 2022 18:50:32 -0600 Subject: [PATCH 2/3] Don't explicitly declare sniff paths, so that all installed sniffs are available. --- composer.json | 6 +++++- defaults/install/phpcs.xml | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 8b0355a5..82a6f694 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,11 @@ } }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "cweagans/composer-patches": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } }, "extra": { "patches": { diff --git a/defaults/install/phpcs.xml b/defaults/install/phpcs.xml index 3da238a7..1ec4b56c 100644 --- a/defaults/install/phpcs.xml +++ b/defaults/install/phpcs.xml @@ -14,7 +14,6 @@ - From 8499d85127e3cd615b821926d4fb5fe9f91eeee6 Mon Sep 17 00:00:00 2001 From: Bec White Date: Thu, 6 Oct 2022 14:44:37 -0500 Subject: [PATCH 3/3] Add phpcs config back to the defaults.yml so that this doesn't break existing installs. --- defaults.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/defaults.yml b/defaults.yml index b3744bfa..507c204c 100644 --- a/defaults.yml +++ b/defaults.yml @@ -219,6 +219,29 @@ phplint: includesfile: "${build.thebuild.dir}/defaults/standard/phplint.txt" +# Configuration for using PHP_CodeSniffer to review code according to the Drupal coding +# standards. +# +# DEPRECATED - to be removed in the-build 4.2 +# This configuration is replaced by defaults/install/phpcs.xml. +# +# @see https://www.drupal.org/docs/develop/standards +# @see https://github.com/squizlabs/PHP_CodeSniffer +# @see https://www.drupal.org/project/coder +# +# These values are used in the defaults/build.xml template: +# $> phpcs --standard=${phpcs.standard} --ignore=${phpcs.ignore} ${phpcs.directories} +phpcs: + # Path to a PHP_CodeSniffer standard file. + standard: "${build.dir}/vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml" + + # Space-separated list of directories to review. + directories: "${drupal.root}/modules/custom ${drupal.root}/themes/custom" + + # Comma-separated list of extensions to check in the PHP_CodeSniffer review. + extensions: "php,module,inc,install,test,profile,theme,css,info,txt,yml,js" + + # Configuration for using PHP Mess Detector to check for general PHP best practices, # unused variables, and to analyze complexity. #