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

Extra: do not allow ambiguous conditions (needs PHPCS 3.9.0) #2429

Merged
merged 2 commits into from
Mar 5, 2024

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Mar 4, 2024

Composer: raise the minimum supported PHPCS version to 3.9.0

Extra: do not allow ambiguous conditions

This new PHPCS 3.9.0 sniff will flag code which contains a || and a && operator in the same condition and their precedence is not clarified via parenthesis.

This should allow for users of WPCS to find/prevent some bugs in code.

I'd personally would highly recommend for WP Core to also use this sniff, but I suspect that will need due discussion/Make post/handbook change.

Note: running this sniff on WP Core as-is, would (to my surprise) not actually trigger any new errors.

Includes updating a code snippet in the Ruleset test to comply.

This new PHPCS 3.9.0 sniff will flag code which contains a `||` and a `&&` operator in the same condition and their precedence is not clarified via parenthesis.

This should allow for users of WPCS to find/prevent some bugs in code.

I'd personally would **_highly_** recommend for WP Core to also use this sniff, but I suspect that will need due discussion/Make post/handbook change.

Note: running this sniff on WP Core as-is, would (to my surprise) not actually trigger any new errors.

Includes updating a code snippet in the Ruleset test to comply.
@jrfnl jrfnl added Component: Extra Type: Enhancement Status: Review ready Focus: Code analysis Sniffs to prevent common mistakes and improve code in general labels Mar 4, 2024
@jrfnl jrfnl added this to the 3.1.0 milestone Mar 4, 2024
@GaryJones GaryJones merged commit ae6d254 into develop Mar 5, 2024
46 checks passed
@GaryJones GaryJones deleted the feature/update-for-phpcs-3.9.0 branch March 5, 2024 08:28
@jrfnl jrfnl mentioned this pull request Mar 22, 2024
36 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Extra Focus: Code analysis Sniffs to prevent common mistakes and improve code in general Type: Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants