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

Generic/Todo-Fixme sniffs: improve handling of docblock tags and efficiency fix #3771

Closed

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Mar 2, 2023

Generic/Todo-Fixme: make the sniffs more selective

The sniffs as-they-were, would sniff all comment related tokens, including T_DOC_COMMENT_STAR, T_DOC_COMMENT_WHITESPACE etc.

Sniffing those tokens is redundant and makes the sniffs slower than is needed.

Fixed now by making the tokens being registered by the sniffs more selective/targeted.

Generic/Todo: improve handling of "todo" tags in docblocks

Until now, the sniff would only examine an individual comment token, while when a @todo tag is used in a docblock, the "task description" is normally in the next T_DOC_COMMENT_STRING token.

This commit fixes this and the sniff will now take docblock @todo tags into account.

Includes additional unit tests.

Generic/Fixme: improve handling of "fixme" tags in docblocks

Essentially the same fix as applied in the sister-commit for the Generic.Commenting.Todo sniff.

Until now, the sniff would only examine an individual comment token, while when a @fixme tag is used in a docblock, the "task description" is normally in the next T_DOC_COMMENT_STRING token.

This commit fixes this and the sniff will now take docblock @fixme tags into account.

Includes additional unit tests.

Fixes #3769 (well, aside from tags without a description, but that can't be helped)

The sniffs as-they-were, would sniff all comment related tokens, including `T_DOC_COMMENT_STAR`, `T_DOC_COMMENT_WHITESPACE` etc.

Sniffing those tokens is redundant and makes the sniffs slower than is needed.

Fixed now by making the tokens being registered by the sniffs more selective/targetted.
Until now, the sniff would only examine an individual comment token, while when a `@todo` tag is used in a docblock, the "task description" is normally in the next `T_DOC_COMMENT_STRING` token.

This commit fixes this and the sniff will now take docblock `@todo` tags into account.

Includes additional unit tests.
Essentially the same fix as applied in the sister-commit for the `Generic.Commenting.Todo` sniff.

Until now, the sniff would only examine an individual comment token, while when a `@fixme` tag is used in a docblock, the "task description" is normally in the next `T_DOC_COMMENT_STRING` token.

This commit fixes this and the sniff will now take docblock `@fixme` tags into account.

Includes additional unit tests.
@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 2, 2023

Closing as replaced by PHPCSStandards/PHP_CodeSniffer#53

@jrfnl jrfnl closed this Dec 2, 2023
@jrfnl jrfnl deleted the feature/3769-improve-todo-fixme-sniffs branch December 2, 2023 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic.Commenting.Todo.CommentFound sample not working
1 participant