Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/php-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ jobs:
with:
composer-options: --prefer-dist --no-progress

- name: Run PHPCS
run: composer run cs

- name: Setup wp-env
run: wp-env start
env:
Expand Down
110 changes: 110 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="wp-parsely" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Custom ruleset for Edit Flow plugin.</description>

<!-- For help in understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- For help in using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->

<!-- What to scan -->
<file>.</file>
<!-- Ignoring Files and Folders:
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->
<exclude-pattern>/node_modules/</exclude-pattern>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/tests/</exclude-pattern>

<!-- How to scan -->
<!-- Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
<!-- Annotated ruleset: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- Show sniff and progress -->
<arg value="sp"/>
<!-- Strip the file paths down to the relevant bit -->
<arg name="basepath" value="./"/>
<!-- Show results with colors -->
<arg name="colors"/>
<!-- Limit to PHP files -->
<arg name="extensions" value="php"/>
<!-- Enables parallel processing when available for faster results. -->
<arg name="parallel" value="8"/>

<!-- Rules: Check PHP version compatibility - see
https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<rule ref="PHPCompatibilityWP"/>
<!-- For help in understanding this testVersion:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="8.0-"/>

<!-- Rules: WordPress Coding Standards - see
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<!-- WordPress-Extra includes WordPress-Core -->
<rule ref="WordPress-Extra"/>
<rule ref="WordPress-Docs"/>
<!-- For help in understanding these custom sniff properties:
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
<config name="minimum_supported_wp_version" value="6.4"/>

<!-- Rules: WordPress VIP - see
https://github.com/Automattic/VIP-Coding-Standards -->
<rule ref="WordPress-VIP-Go">
<!-- These disallow anonymous functions as action callbacks -->
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" />
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments" />
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" />

<!-- Allow short array syntax -->
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />

<!-- Do not enforce 'class-' prefix -->
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />

<!-- Allow short ternaries -->
<exclude name="WordPress.PHP.DisallowShortTernary.Found" />

<!-- Generates too many false positives -->
<exclude name="WordPress.WP.CapitalPDangit.Misspelled" />

<!-- We use trigger_error extensively -->
<exclude name="WordPress.PHP.DevelopmentFunctions.error_log_trigger_error" />

<!-- ToDo: Remove these exceptions over time -->
<!-- These are for legacy reasons, as EditFlow's main file cannot be altered -->
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
<exclude name="Universal.Files.SeparateFunctionsFromOO.Mixed" />
<exclude name="PEAR.NamingConventions.ValidClassName.StartWithCapital" />
<exclude name="PEAR.NamingConventions.ValidClassName.Invalid" />
<!-- Allow not returning after the setup theme filter for now -->
<exclude name="WordPressVIPMinimum.Hooks.AlwaysReturnInFilter.MissingReturnStatement" />
<!-- Localization is done in a legacy manner in some places, and its been left as is for now -->
<exclude name="WordPress.WP.I18n.InterpolatedVariableSingular" />
<exclude name="WordPress.WP.I18n.InterpolatedVariablePlural" />
<exclude name="WordPress.WP.I18n.MissingSingularPlaceholder" />
<exclude name="WordPress.WP.I18n.NonSingularStringLiteralText" />
<!-- This rule is hard to solve given the heavy use of JS in the PHP code right now -->
<exclude name="Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure" />
<exclude name="WordPress.DateTime.RestrictedFunctions.date_date" />
</rule>

<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="ef"/>
<element value="Edit_Flow"/>
</property>
</properties>
</rule>

<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="edit-flow"/>
</property>
</properties>
</rule>

<rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
<properties>
<property name="blank_line_check" value="true"/>
</properties>
</rule>

</ruleset>
2 changes: 1 addition & 1 deletion bin/phpcs-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ git remote set-branches --add origin master
git fetch origin master
git diff origin/master > $DIFF_FILE

$DIR/../vendor/bin/phpcs --extensions=php --standard=phpcs.xml.dist --report=json > $PHPCS_FILE || true
$DIR/../vendor/bin/phpcs --extensions=php --standard=.phpcs.xml.dist --report=json > $PHPCS_FILE || true

$DIR/../vendor/bin/diffFilter --phpcs $DIFF_FILE $PHPCS_FILE 100
9 changes: 3 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@
"require-dev": {
"automattic/vipwpcs": "^3.0",
"exussum12/coverage-checker": "^1.0.0",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpunit/phpunit": "^9.0",
"yoast/phpunit-polyfills": "^2.0"
},
"scripts": {
"cs": [
"@php ./vendor/bin/phpcs -p -s -v -n . --standard=\"phpcs.xml.dist\" --extensions=php --ignore=\"/vendor/*,/node_modules/*,/tests/*\""
],
"cbf": [
"@php ./vendor/bin/phpcbf -p -s -v -n . --standard=\"phpcs.xml.dist\" --extensions=php --ignore=\"/vendor/*,/node_modules/*,/tests/*\""
],
"cs": "@php ./vendor/bin/phpcs",
"cs-fix": "@php ./vendor/bin/phpcbf",
"integration": "wp-env run tests-cli --env-cwd=wp-content/plugins/Edit-Flow ./vendor/bin/phpunit",
"integration-ms": "wp-env run tests-cli --env-cwd=wp-content/plugins/Edit-Flow /bin/bash -c 'WP_MULTISITE=1 ./vendor/bin/phpunit'"
},
Expand Down
51 changes: 0 additions & 51 deletions phpcs.xml.dist

This file was deleted.

Loading