Skip to content

Commit

Permalink
chore: implement WPGraphQL Coding Standards ruleset (PHPCS) (#369)
Browse files Browse the repository at this point in the history
* chore: lint with WPGraphQL-Minimum

* chore: lint for WPGraphQL-Strict

* chore: lint for WPGraphQL Coding Standards (phpcbf only)

* chore: update deps and relint

* chore: handle `severity=1` errors

* chore: update changelog
  • Loading branch information
justlevine committed Jun 7, 2023
1 parent a7b5d98 commit fae94d4
Show file tree
Hide file tree
Showing 307 changed files with 1,640 additions and 1,597 deletions.
84 changes: 35 additions & 49 deletions .phpcs.xml.dist
@@ -1,9 +1,10 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WPGraphQL_GF" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>Coding Standards for WPGraphQL for Gravity Forms</description>
<ruleset name="WordPress Coding Standards for WPGraphQL for Gravity Forms" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>Sniffs for the WPGraphQL plugin ecosystem.</description>

<!-- What to scan -->
<file>.</file>
<!-- What to scan: include any root-level PHP files, and the /src folder -->
<file>./src/</file>
<file>./wp-graphql-gravity-forms.php</file>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/node_modules/</exclude-pattern>
<exclude-pattern>/phpstan/</exclude-pattern>
Expand All @@ -13,29 +14,49 @@
<!-- Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
<!-- Annotated ruleset: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->

<arg value="sp"/>
<!-- Show sniff and progress -->
<arg name="basepath" value="./"/>
<arg value="sp"/>
<!-- Strip the file paths down to the relevant bit -->
<arg name="basepath" value="./"/>
<!-- Enable colors in report -->
<arg name="colors"/>
<!-- Only lint php files by default -->
<arg name="extensions" value="php"/>
<!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
<arg name="cache" value="tests/_output/cache.json" />
<!-- Enables parallel processing when available for faster results. -->
<arg name="parallel" value="8"/>
<arg name="parallel" value="20"/>
<!-- Set severity to 1 to see everything that isn't effectively turned off. -->
<arg name="severity" value="1"/>

<!-- Ruleset Config: set these to match your project constraints-->

<!-- Tests for PHP version compatibility -->
<!--
Tests for PHP version compatibility.
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#Recomended-additional-rulesets
-->
<config name="testVersion" value="7.4-"/>
<rule ref="PHPCompatibilityWP">
<include-pattern>*\.php$</include-pattern>
</rule>

<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
<!--
Tests for WordPress version compatibility.
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties
-->
<config name="minimum_supported_wp_version" value="5.4.1"/>

<!-- Plugin-specific expected properties-->
<!-- Rules: WPGraphQL Coding Standards -->
<!-- https://github.com/AxeWP/WPGraphQL-Coding-Standards/WPGraphQL/ruleset.xml -->
<rule ref="WPGraphQL">
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
</rule>

<!-- Individual rule configuration -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. -->
<property name="prefixes" type="array" value="WPGraphQL\GF, wp_graphql, gf_graphql, _gf, WPGRAPHQL_GF" />
<!-- @todo drop gf_graphql -->
<property name="prefixes" type="array" value="WPGraphQL\GF, wp_graphql, gf_graphql, graphql_gf, _gf, WPGRAPHQL_GF" />
</properties>
</rule>
<rule ref="WordPress.WP.I18n">
Expand All @@ -45,39 +66,4 @@
</properties>
</rule>

<!-- Rules: WordPress Coding Standards -->
<!-- Load WordPress VIP Go standards - for use with projects on the (newer) VIP Go platform. -->
<rule ref="WordPress-VIP-Go" />

<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<rule ref="WordPress-Core">
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<exclude name="WordPress.PHP.DisallowShortTernary.Found"/>
<exclude name="WordPress.CodeAnalysis.AssignmentInCondition.Found"/>
<exclude name="WordPress.Files.FileName" />
<exclude name="WordPress.NamingConventions.ValidVariableName" />
<!-- Maybe Add later: -->
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound" />
<exclude name="Generic.Commenting.DocComment.MissingShort" />
</rule>
<rule ref="WordPress-Docs" />
<rule ref="WordPress-Extra" />



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

<!-- Enforce short array syntax -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>

<!--Disable DocBlock requirements if inherited -->
<rule ref="Squiz.Commenting.FunctionComment">
<properties>
<property name="skipIfInheritdoc" value="true" />
</properties>
</rule>
</ruleset>
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@
- dev: Refactor database ID resolution when the GraphQL `ID` type is indeterminate. Note: The following input args now work with both database and global IDs: `GfEntriesConnectionWhereArgs.formIds`, `GfFormsConnectionwhereArgs.formIds`.
- dev: Remove usage of deprecated `WPGraphQL\Data\DataSource::resolve_post_object()` method.
- dev: Prime the GfForm dataloader when querying form connections, to prevent unnecessary database queries.
- chore: Implement `axepress/wp-graphql-cs` PHP_Codesniffer ruleset.
- docs: Add missing documentation regarding using `productValues` input when submitting forms.

## v0.12.1 - Bug fix
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Expand Up @@ -35,14 +35,13 @@
"lucatume/wp-browser": "^3.0",
"wp-graphql/wp-graphql-testcase": "~2.3",
"phpunit/phpunit": "^9.0",
"php-coveralls/php-coveralls": "^2.5",
"phpstan/phpstan": "^1.2",
"phpstan/extension-installer": "^1.1",
"szepeviktor/phpstan-wordpress": "^1.0",
"axepress/wp-graphql-stubs": "^1.11.1",
"wp-cli/wp-cli-bundle": "^2.6",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"automattic/vipwpcs": "^2.3"
"axepress/wp-graphql-cs": "dev-develop",
"wp-cli/wp-cli-bundle": "^2.8.1",
"php-coveralls/php-coveralls": "^2.5"
},
"config": {
"optimize-autoloader": true,
Expand Down

0 comments on commit fae94d4

Please sign in to comment.