From a13d51742a83fef8fba05cb487f19a8dd5391a9d Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Tue, 7 Aug 2018 10:12:23 -0700 Subject: [PATCH] Better PHPCS --- .gitignore | 1 - .gitlab-ci.yml | 10 +++++----- phpcs.xml | 39 +++++++++++++++++++++++++++++++++++++++ phpcs.xml.dist | 17 ----------------- 4 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 phpcs.xml delete mode 100644 phpcs.xml.dist diff --git a/.gitignore b/.gitignore index 6f68bc7..63bb990 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .DS_Store -phpcs.xml phpunit.xml Thumbs.db wp-cli.local.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3df83ff..a33e503 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,7 +49,7 @@ PHPunit:PHP5.3:MySQL: services: - mysql:5.6 script: - - phpcs + - phpcs -n - phpunit allow_failure: true @@ -58,7 +58,7 @@ PHPunit:PHP5.6:MySQL: services: - mysql:5.6 script: - - phpcs + - phpcs -n - phpunit PHPunit:PHP7.0:MySQL: @@ -66,7 +66,7 @@ PHPunit:PHP7.0:MySQL: services: - mysql:5.6 script: - - phpcs + - phpcs -n - phpunit PHPunit:PHP7.1:MySQL: @@ -74,7 +74,7 @@ PHPunit:PHP7.1:MySQL: services: - mysql:5.6 script: - - phpcs + - phpcs -n - phpunit PHPunit:PHP7.2:MySQL: @@ -82,5 +82,5 @@ PHPunit:PHP7.2:MySQL: services: - mysql:5.6 script: - - phpcs + - phpcs -n - phpunit diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..4e25cc5 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<ruleset name="WordPress Coding Standards for Plugins"> + <description>Generally-applicable sniffs for WordPress plugins</description> + + <!-- + Pass some flags to PHPCS: + p flag: Show progress of the run. + s flag: Show sniff codes in all reports. + --> + <arg value="ps" /> + + <!-- Strip the filepaths down to the relevant bit. --> + <arg name="basepath" value="./" /> + + <!-- Check up to 8 files simultaneously. --> + <arg name="parallel" value="8" /> + + <!-- Only check the PHP files. --> + <arg name="extensions" value="php" /> + + <!-- Check all files in this directory and the directories below it. --> + <file>.</file> + + <!-- Exclude a few directories and autogenerated files. --> + <exclude-pattern>*/node_modules/*</exclude-pattern> + <exclude-pattern>*/vendor/</exclude-pattern> + + <rule ref="WordPress" /> + <rule ref="WordPressVIPMinimum" /> + <!--<rule ref="WordPress-VIP-Go" />--> + + <config name="minimum_supported_wp_version" value="4.9" /> + + <rule ref="WordPress.NamingConventions.PrefixAllGlobals"> + <properties> + <property name="prefixes" type="array" value="camo" /> + </properties> + </rule> +</ruleset> diff --git a/phpcs.xml.dist b/phpcs.xml.dist deleted file mode 100644 index 4f1d0e5..0000000 --- a/phpcs.xml.dist +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0"?> -<ruleset name="WordPress Coding Standards for Plugins"> - <description>Generally-applicable sniffs for WordPress plugins</description> - - <rule ref="WordPress-Core" /> - <rule ref="WordPress-Docs" /> - - <!-- Check all PHP files in directory tree by default. --> - <arg name="extensions" value="php"/> - <file>.</file> - - <!-- Show progress and sniff codes in all reports --> - <arg value="ps"/> - - <exclude-pattern>*/node_modules/*</exclude-pattern> - <exclude-pattern>*/vendor/*</exclude-pattern> -</ruleset> -- GitLab