Skip to content

Update sniff to catch more early returns#2885

Merged
Crabcyborg merged 2 commits into
masterfrom
update_sniff_to_catch_more_early_returns
Jan 26, 2026
Merged

Update sniff to catch more early returns#2885
Crabcyborg merged 2 commits into
masterfrom
update_sniff_to_catch_more_early_returns

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Jan 26, 2026

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved form filter accessibility on the entries list by adding screen reader labels and reorganizing filter controls for better usability with assistive technologies
  • Improvements

    • Optimized form import processing workflow to enhance reliability and consistency

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 26, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Three files undergo refactoring: a helper for entry list navigation applies guard logic inversion and adds accessibility labels; an XML helper adopts an early-return pattern for form import logic; and a PHP_CodeSniffer sniff extends to detect early-return opportunities after up to three simple assignment statements.

Changes

Cohort / File(s) Summary
Accessibility and UI Refactoring
classes/helpers/FrmEntriesListHelper.php
Inverts guard logic to exit early when not on top tab or form_id is present. Adds screen-reader-only label for form filter. Reorganizes DOM structure to keep forms dropdown and filter button in same container without changing external behavior.
Control Flow Refactoring
classes/helpers/FrmXMLHelper.php
Replaces nested conditional with early-return guard pattern. When form is missing or old_style is not set, function returns early; otherwise, casts form to array, updates custom_style, re-invokes import updater, computes has_changed check, and applies form update.
CodeSniffer Sniff Enhancement
phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/FlipIfToEarlyReturnSniff.php
Extends sniff to detect if statements appearing after up to three simple assignment statements. Adds findIfAfterSimpleSetup() helper to skip whitespace and assignments; adds isSimpleAssignment() helper to validate assignment patterns. Adjusts control flow to use either initial if or if found after setup.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Guards flip and returns flow early and bright,
Assignments we skip, then patterns take flight!
Screen-readers now hear what was silent before,
The sniff sees deeper—what helpers explore! ✨

✨ 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 a13abda into master Jan 26, 2026
15 of 16 checks passed
@Crabcyborg Crabcyborg deleted the update_sniff_to_catch_more_early_returns branch January 26, 2026 20:03
stephywells pushed a commit that referenced this pull request Apr 4, 2026
…arly_returns

Update sniff to catch more early returns
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.

1 participant