Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vikrampm1 opened this issue Jun 26, 2024 · 0 comments · Fixed by #163
Closed

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

vikrampm1 opened this issue Jun 26, 2024 · 0 comments · Fixed by #163
Assignees
Labels
priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: bug The issue is a confirmed bug.
Milestone

Comments

@vikrampm1
Copy link
Contributor

vikrampm1 commented Jun 26, 2024

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
@vikrampm1 vikrampm1 added priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: bug The issue is a confirmed bug. labels Jun 26, 2024
@faisal-alvi faisal-alvi self-assigned this Jun 27, 2024
@faisal-alvi faisal-alvi added this to the Future Release milestone Jun 27, 2024
@vikrampm1 vikrampm1 modified the milestones: Future Release, 4.7.1 Jul 20, 2024
@vikrampm1 vikrampm1 modified the milestones: 4.7.1, 4.7.2 Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants