New sniff to add early returns to functions that are one big if#2803
Conversation
📝 WalkthroughWalkthroughAdds a new PHP_CodeSniffer sniff that flips single-if-bodied functions to early-return form, registers it in the ruleset, and applies the early-return refactor to two controller methods by inverting conditionals and using early returns. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.php⚙️ CodeRabbit configuration file
Files:
🪛 PHPMD (2.15.0)phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/FlipIfToEarlyReturnSniff.php159-159: Avoid unused parameters such as '$funcOpener'. (undefined) (UnusedFormalParameter) 159-159: Avoid unused parameters such as '$funcCloser'. (undefined) (UnusedFormalParameter) 320-337: Avoid unused private methods such as 'hasElseOrElseif'. (undefined) (UnusedPrivateMethod) ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
✏️ Tip: You can disable this entire section by setting 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. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2803 +/- ##
============================================
- Coverage 27.10% 27.09% -0.02%
+ Complexity 8847 8840 -7
============================================
Files 145 145
Lines 29816 29760 -56
============================================
- Hits 8083 8063 -20
+ Misses 21733 21697 -36 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.