Add rector rule for SimplifyIfReturnBoolRector#2667
Conversation
|
Warning Rate limit exceeded@Crabcyborg has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 21 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
WalkthroughThis PR simplifies conditional return logic across 15 files by replacing explicit if-else blocks with single return expressions. The rector.php configuration was updated to remove SimplifyIfReturnBoolRector from the skipped rules, enabling this simplification pattern to be applied throughout the codebase. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes
Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
classes/helpers/FrmAppHelper.php (1)
4815-4816: Orphaned comment is now misleading.The comment
// The URL isn't to an XML file.was originally associated with the early return for the failure case. Now that the logic is simplified to a single return, this comment is misleading since:
- The function is generic and handles any expected extension, not just XML
- The comment doesn't accurately describe what the return statement does
Consider removing the orphaned comment or updating it:
- // The URL isn't to an XML file. return $expected_extension === $ext;classes/helpers/FrmFormMigratorsHelper.php (1)
18-18: Consider using strict comparison inin_array.The
in_arraycall is missing the third parameter for strict comparison. While the current usage with string class names likely works correctly, adding strict comparison is a defensive best practice to avoid potential type coercion issues.- return ! empty( $dismissed ) && in_array( $form['class'], $dismissed ); + return ! empty( $dismissed ) && in_array( $form['class'], $dismissed, true );
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
classes/controllers/FrmAddonsController.php(1 hunks)classes/controllers/FrmAppController.php(1 hunks)classes/controllers/FrmDashboardController.php(2 hunks)classes/helpers/FrmApiHelper.php(1 hunks)classes/helpers/FrmAppHelper.php(1 hunks)classes/helpers/FrmFormMigratorsHelper.php(1 hunks)classes/helpers/FrmFormsHelper.php(1 hunks)classes/models/FrmApplicationTemplate.php(1 hunks)classes/models/FrmEmail.php(1 hunks)classes/models/FrmEntry.php(1 hunks)classes/models/FrmStyle.php(1 hunks)classes/models/fields/FrmFieldType.php(1 hunks)classes/views/styles/components/FrmStyleComponent.php(1 hunks)rector.php(0 hunks)stripe/models/FrmStrpLiteAuth.php(2 hunks)
💤 Files with no reviewable changes (1)
- rector.php
🧰 Additional context used
🧬 Code graph analysis (3)
classes/models/FrmApplicationTemplate.php (1)
classes/helpers/FrmFormsHelper.php (2)
FrmFormsHelper(6-2188)plan_is_allowed(1667-1690)
classes/controllers/FrmAppController.php (1)
classes/helpers/FrmAppHelper.php (2)
FrmAppHelper(6-5050)simple_get(807-816)
classes/views/styles/components/FrmStyleComponent.php (1)
classes/helpers/FrmAppHelper.php (2)
FrmAppHelper(6-5050)get_param(737-774)
⏰ 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)
- GitHub Check: PHP 7.4 tests in WP trunk
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: Cypress
- GitHub Check: Cypress
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: PHP 7.4 tests in WP trunk
🔇 Additional comments (14)
classes/models/FrmStyle.php (1)
371-371: LGTM!The simplification correctly converts the
preg_matchresult to a boolean. Sincepreg_matchreturns 1 for a match and 0 for no match, the(bool)cast produces the same result as the previous if/else block.classes/models/FrmEntry.php (1)
267-267: LGTM!The negated condition correctly inverts the original early-return logic. When
parent_form_idis set and truthy (repeating field entries), the function returnsfalseto skip duplicate checking, which matches the original behavior.classes/controllers/FrmDashboardController.php (2)
300-300: LGTM!The boolean expression correctly consolidates the CTA display logic: show CTA when counter is zero or less, except for the entries counter when no form exists.
368-368: LGTM!The simplified expression correctly checks if the banner was closed by the current user. The strict comparison (
trueparameter) inin_arrayis preserved, ensuring type-safe matching.classes/controllers/FrmAddonsController.php (1)
1340-1343: Auth comparison simplification looks correctThe new
return ! empty( $auth ) && hash_equals( $auth, $post_auth );preserves the previous behavior with proper short‑circuiting and keepshash_equalsuse intact. No logic or security regression here.classes/helpers/FrmFormsHelper.php (1)
2109-2122: is_gutenberg_editor boolean return is safely simplifiedReturning
'post.php' === $pagenowdirectly is logically equivalent to the previous conditional and keeps the earlier REST URL guards intact.classes/controllers/FrmAppController.php (1)
1436-1447: in_our_pages final condition simplification is correctThe combined return using
in_array( $pagenow, ... ) && 'frm_application' === FrmAppHelper::simple_get( 'taxonomy' )is behaviorally equivalent to the prior branching logic and keeps strict comparisons.classes/models/FrmEmail.php (1)
487-520: has_recipients simplification matches existing behavior
return ! ( empty( $this->to ) && empty( $this->cc ) && empty( $this->bcc ) );is equivalent to the previous explicit true/false branching and keepsshould_send()semantics unchanged.classes/helpers/FrmApiHelper.php (1)
20-43: is_for_user tail return is correctly collapsedThe final
return self::check_free_segments( $who );preserves the earlier behavior where the method fell through to checking the free segments last; only the return style changed.classes/models/FrmApplicationTemplate.php (1)
242-267: is_available_for_purchase now returns plan check directly
return FrmFormsHelper::plan_is_allowed( $args );is a straight simplification of the previous true/false branching and keeps all surrounding validation logic intact.classes/views/styles/components/FrmStyleComponent.php (1)
230-235: hide_component conditional is safely condensedThe method still short‑circuits when
not_show_inis empty, and the final equality check against the sanitizedsectionparam is equivalent to the previous if/return pattern.classes/models/fields/FrmFieldType.php (1)
1779-1786: HTML‑stripping privilege check remains equivalentThe new
return ! ( ! empty( $entry->user_id ) && $this->user_id_is_privileged( $entry->user_id ) );together with the precedingupdated_bycheck keeps the same logic: do not strip for privilegedupdated_byoruser_id, strip otherwise. Only the return style was compacted.stripe/models/FrmStrpLiteAuth.php (2)
659-659: LGTM!The simplification correctly converts the explicit conditional return to a direct boolean expression. The
(bool)cast appropriately handlespreg_match's return values (1, 0, or false).
864-864: LGTM!The simplification correctly converts the explicit conditional return to a direct boolean expression. The compound condition logic is preserved and reads clearly.
…turnBoolRector Add rector rule for SimplifyIfReturnBoolRector
No description provided.