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

Add Sniff to check for documentation on actions and filters #1640

Closed
superdav42 opened this issue Feb 4, 2019 · 1 comment
Closed

Add Sniff to check for documentation on actions and filters #1640

superdav42 opened this issue Feb 4, 2019 · 1 comment

Comments

@superdav42
Copy link

Is your feature request related to a problem?

I want to ensure all hooks in my plugin are properly documented.

Describe the solution you'd like

From the PHP Documentation Standards. "Both action and filter hooks should be documented on the line immediately preceding the call to do_action() or do_action_ref_array(), or apply_filters() or apply_filters_ref_array()."
I'd like a sniff to check for these documentation blocks before hooks and report if they are not found or if there is missing parameters.

Additional context (optional)

I feel like this may have existed somewhere but can't find it here which seems the most logical place for it to be.

@jrfnl
Copy link
Member

jrfnl commented Feb 4, 2019

The issue is valid, but has been reported before. Closing as duplicate of #424

@superdav42 FYI: We are aware that the documentation sniffs currently in use via the WordPress-Docs standard are nowhere near complete and don't cover the docs handbook by a long shot.

This has been a thorn in my side for quite a while now, however the existing sniffs in PHPCS itself don't easily allow for customization and writing completely new sniffs would mean duplicating a lot of logic.

So, I'm working on improving this in PHPCS first via squizlabs/PHP_CodeSniffer#2222 and squizlabs/PHP_CodeSniffer#2189.
Once the PRs addressing those issues have been accepted and released in a new PHPCS version, you can expect the WPCS docs standard/sniffs - including a hook docs sniff - to be greatly improved soon(ish) after.

@jrfnl jrfnl closed this as completed Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants