Skip to content

Add validation for since tag version #30

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

Merged
merged 1 commit into from
Jun 30, 2022
Merged

Add validation for since tag version #30

merged 1 commit into from
Jun 30, 2022

Conversation

roykho
Copy link
Contributor

@roykho roykho commented Jun 27, 2022

This PR adds validation for the [at]since version to make sure they have supplied a valid version for that tag.

Closes #28

Prereq:
Make sure you have this PR pulled down and that your global PHPCS is referencing this change.

Testing:

  • Git clone https://github.com/woocommerce/woocommerce.
  • Go to your cloned repo and modify the file plugins/woocommerce/woocommerce.php. Add a do_action or apply_filters hook with docblock. Add the [at]since tag without version. For example:
/**
 * Description
 *
 * @since
 */
do_action( 'hook' );
  • Now in the root of your repo run phpcs -s plugins/woocommerce/woocommerce.php.
  • Ensure you see the violation that no versions were supplied with the [at]since tag.
  • Now add the version in either <x.x.x> or <x.x> format and run the sniff command again.
  • This time you should see no violations.

Note:
I did not add the check for description as per the original #28 issue as this is already being picked up by the generic PEAR rules.

Task:
After approved and merged, we need to do a release and bump the woocommerce-sniffs version in WooCommerce-monorepo.

Verified

This commit was signed with the committer’s verified signature.
roykho Roy Ho
@roykho roykho requested a review from psealock June 27, 2022 16:32
@psealock
Copy link

Make sure you have this PR pulled down and that your global PHPCS is referencing this change

What's the best way to do this? Using the --standard=path/to/standard isn't working for me as it can't find the WooCommerce ruleset

# From this repo
phpcs --standard=src/WooCommerce-Core ../woocommerce/plugins/woocommerce/woocommerce.php

@roykho
Copy link
Contributor Author

roykho commented Jun 28, 2022

@psealock - I would suggest installing it globally. composer global require woocommerce/woocommerce-sniffs. Then you can run phpcs --config-set default_standard WooCommerce-Core. Then find where your phpcs rulesets are installed by running phpcs --config-show. You can then symlink this repo to where you have it installed so your global will always reference this repo for development.

Copy link

@psealock psealock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job @roykho ! This is working great, and a missing description is picked up as a violation as well 🚢

@roykho roykho merged commit b76fe28 into trunk Jun 30, 2022
@roykho roykho deleted the improve/hooksniff branch June 30, 2022 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Hook @since Validation
2 participants