woocommerce / woocommerce-square

Square POS and Payments Integration
https://woo.com/products/square
Other
11 stars 7 forks source link

WooCommerce PHPCS sniff throws an error when using @since x.x.x on hooks #159

Closed vikrampm1 closed 4 months ago

vikrampm1 commented 5 months ago

Describe the Bug

We use the woocommerce/woocommerce-sniffs package for our PHPCS sniffs. There is one sniff here (WooCommerce.Commenting.CommentHooks.MissingSinceVersionComment) that will throw an error if a @since statement is added to a hook doc but doesn't contain a valid value. Reference failure here: https://github.com/woocommerce/woocommerce-square/actions/runs/9600765725/job/26477782151

Since we aren't always sure when opening a PR what the final released version will be, we always use x.x.x for those statements, which is fine for function, method or parameter statements but will get flagged when using it for hooks. We always update these x.x.x statements before a release so I think we can just ignore these particular sniff by adding the following to our phpcs.xml.dist file:

<rule ref="WooCommerce.Commenting">
    <!-- It wants @since to contain defined version and does not allow just x.x.x -->
    <exclude name="WooCommerce.Commenting.CommentHooks.MissingSinceVersionComment"/>
</rule>

To Reproduce

See the following PHPCS error on the #615 PR: https://github.com/woocommerce/woocommerce-deposits/actions/runs/9649327093/job/26612562501

Can also check out this branch locally (fix/586) and run PHPCS locally to see the failure:

./vendor/bin/phpcs-changed -s --git --git-base origin/trunk includes/api/class-wc-deposits-store-api.php