Skip to content

New sniff to prevent empty on function responses#2850

Merged
Crabcyborg merged 4 commits into
masterfrom
new_sniff_to_prevent_empty_on_function_response
Jan 20, 2026
Merged

New sniff to prevent empty on function responses#2850
Crabcyborg merged 4 commits into
masterfrom
new_sniff_to_prevent_empty_on_function_response

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Jan 20, 2026

Summary by CodeRabbit

  • Refactor

    • Standardized conditional logic patterns throughout the codebase to improve code consistency, readability, and maintainability while enhancing overall quality.
  • Tests

    • Introduced automated code quality checks to enforce consistent coding standards and ensure ongoing compliance with established best practices.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 20, 2026

Warning

Rate limit exceeded

@Crabcyborg has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 55 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 26bff47 and 8c9c1ca.

📒 Files selected for processing (6)
  • classes/controllers/FrmAddonsController.php
  • classes/models/FrmSolution.php
  • classes/views/styles/_buttons.php
  • classes/views/styles/components/FrmSliderStyleComponent.php
  • phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/PreferNegationOverEmptyForFunctionCallSniff.php
  • phpcs-sniffs/Formidable/ruleset.xml
📝 Walkthrough

Walkthrough

This pull request introduces a new PHP_CodeSniffer sniff to enforce a coding standard preferring negated function calls over empty() patterns, and applies this refactoring across the codebase. The changes replace empty(function()) with !function() in multiple files and register the new sniff in the PHPCS ruleset.

Changes

Cohort / File(s) Summary
License and completion checks
classes/controllers/FrmAddonsController.php, classes/models/FrmSolution.php
Inverted conditional logic from empty() to negation operator (!) for evaluating Pro license and solution completion status.
Style and layout components
classes/views/styles/_buttons.php, classes/views/styles/components/FrmSliderStyleComponent.php
Replaced empty() checks with negation for toggle 'checked' state and unit measurement detection in value label calculations.
PHPCS sniff implementation
phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/PreferNegationOverEmptyForFunctionCallSniff.php
New sniff class that detects empty() wrapping function calls and provides automated fixes to replace with negated function calls. Includes helper methods for validation and transformation logic.
PHPCS ruleset configuration
phpcs-sniffs/Formidable/ruleset.xml
Registered the new PreferNegationOverEmptyForFunctionCall sniff rule in the CodeAnalysis section of the Formidable PHPCS ruleset.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 A sniff to catch what's incomplete,
Where empty() and negation meet,
We flip the logic, clean and lean—
The prettiest code you've ever seen!


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 c77b0cb into master Jan 20, 2026
15 checks passed
@Crabcyborg Crabcyborg deleted the new_sniff_to_prevent_empty_on_function_response branch January 20, 2026 21:48
stephywells pushed a commit that referenced this pull request Apr 4, 2026
…n_function_response

New sniff to prevent empty on function responses
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