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

phpcs:enable breaks subsequent phpcs:ignore annotations #2327

Closed
smileBeda opened this issue Aug 3, 2023 · 3 comments
Closed

phpcs:enable breaks subsequent phpcs:ignore annotations #2327

smileBeda opened this issue Aug 3, 2023 · 3 comments

Comments

@smileBeda
Copy link

smileBeda commented Aug 3, 2023

Bug Description

When using the phpcs:disable, phpcs:enable pattern and subsequently an annotation phpcs:ignore is made, the phpcs:ignore is not ignoring the flag anymore.

A short example:

/**
 * Disable WPCS rules
 *
 * Note to reviewers:
 * (Whatever message here)
 * phpcs:disable WordPress.Security.NonceVerification.Recommended
 * phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotValidated
 */
[Whatever related code here]
/**
 * Enableble WPCS rules
 * phpcs:enable WordPress.Security.NonceVerification.Recommended
 * phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotValidated
 */
[Some more code]
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[Whatever other related code here]

In this example, the last annotation will not "work", meaning that [Whatever other related code here] is still flagged even if we ignore the specific rule.

This does not happen, if we do not use the disable/enable pattern prior to the ignore annotation.


I am aware that this might be a PHPCS issue rather than a WPCS issue, I have however not found any such related complaint when looking for this issue in PHPCS-only related topics.

Has anyone here experienced the same, and/or resolved it?
(other than just keep using enable/disable for all other annotations too)

@jrfnl
Copy link
Member

jrfnl commented Aug 3, 2023

@smileBeda This is 100% a PHPCS issue and nothing to do with WPCS.

I'm surprised to hear about this though and would like to see some real code to test with as I tested that feature extensively when it came out and fixed any and all bugs I could find at the time.

@jrfnl
Copy link
Member

jrfnl commented Aug 3, 2023

@smileBeda Just to satisfy my curiousity I've just tested this with a sniff I was working on and some test code for that sniff, using the pattern of annotations for your example, and I cannot reproduce the issue.

This will need a solid reproduction sample if you want to report this upstream (as otherwise I will have to close the issue there just the same).

@jrfnl
Copy link
Member

jrfnl commented Aug 15, 2023

Closing as wrong repo + not reproducable.

@jrfnl jrfnl closed this as not planned Won't fix, can't repro, duplicate, stale Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants