Skip to content

Conversation

@Crabcyborg
Copy link
Contributor

@Crabcyborg Crabcyborg commented Jan 27, 2026

This catches several more instances in Pro.

See https://github.com/Strategy11/formidable-pro/pull/6273

Summary by CodeRabbit

Release Notes

  • Improvements
    • Enhanced detection of redundant parentheses around standalone function calls in logical expressions and conditional statements
    • Improved handling of redundantly negated function calls across various code contexts
    • More sophisticated simple expression analysis with enhanced ternary operation detection
    • Refined whitespace handling consistency across redundancy checks

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

The PR enhances redundant parentheses detection in a PHPCS sniff by expanding token filtering with the Tokens utility, introducing new helper methods for function-call and ternary expression analysis, and extending support for additional logical operators and expression patterns.

Changes

Cohort / File(s) Summary
Redundant Parentheses Analysis Enhancement
phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantParenthesesSniff.php
Introduced isSimpleFunctionCall helper to detect standalone function calls; added isRedundantFunctionCallInLogicalExpression to identify redundantly wrapped function calls in logical contexts; expanded isRedundantComparisonInLogicalExpression to accept SEMICOLON, COMMA, and INLINE_THEN tokens; enhanced isSimpleComparisonExpression with ternary tracking; broadened isRedundantNegatedFunctionCall to support additional logical operators (T_LOGICAL_AND, T_LOGICAL_OR); migrated token lookups to use Tokens::$emptyTokens for generalized whitespace filtering.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 A sniff grows wise with each new guard,
Detecting parentheses, though the task is hard,
Function calls and logical dance,
Token utilities give a second glance—
Redundancy falls before our keen sight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Update sniff to fix more redundant parens uses' directly relates to the main change—expanding the redundant parentheses detection sniff to handle additional cases like function calls in logical expressions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Crabcyborg Crabcyborg merged commit 4961d4a into master Jan 27, 2026
37 of 38 checks passed
@Crabcyborg Crabcyborg deleted the update_redundant_paren_sniff branch January 27, 2026 19:49
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.

2 participants