Skip to content

Update redudant empty on global sniff to catch empty and not just ! e…#2862

Merged
Crabcyborg merged 1 commit into
masterfrom
update_redundant_empty_on_global_sniff_to_catch_more_code
Jan 22, 2026
Merged

Update redudant empty on global sniff to catch empty and not just ! e…#2862
Crabcyborg merged 1 commit into
masterfrom
update_redundant_empty_on_global_sniff_to_catch_more_code

Conversation

@Crabcyborg

@Crabcyborg Crabcyborg commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

…mpty

Summary by CodeRabbit

  • Chores
    • Internal code quality improvements and optimizations across the codebase to enhance performance and maintainability.
    • Developer tooling enhancements to better detect and standardize code patterns.

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

@coderabbitai

coderabbitai Bot commented Jan 22, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR replaces empty() function calls with direct boolean negation (! $var) in three application files, and updates the PHPCS sniff rule to detect and suggest replacements for both empty($var) and !empty($var) patterns on global variables, with corresponding fixes for each case.

Changes

Cohort / File(s) Summary
Application Code Refactoring
classes/helpers/FrmAppHelper.php, classes/models/fields/FrmFieldType.php, classes/views/xml/posts_xml.php
Replaced empty() function checks with direct boolean negation (! $var) for global variable truthiness tests. Each change affects initialization conditions with functionally equivalent control flow.
PHPCS Sniff Enhancement
phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantEmptyOnGlobalSniff.php
Extended sniff logic to detect and handle both empty($var) and !empty($var) patterns on globals. For negated form, replaces with plain variable; for non-negated, replaces with ! $var. Updated documentation, detection logic, and token fix workflow to apply replacements conditionally.
PHPCS Configuration
phpcs-sniffs/Formidable/ruleset.xml
Repositioned RedundantEmptyOnGlobal rule within the Code Analysis block to consolidate rule ordering.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Empty() calls have had their day,
Boolean checks light up the way!
The sniff now knows both forms we test—
Cleaner code, we're so blessed!

🚥 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 accurately summarizes the main change: updating the RedundantEmptyOnGlobal sniff to detect both empty($var) and !empty($var) patterns on globals, not just the negated form.
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 f4c7828 into master Jan 22, 2026
36 of 38 checks passed
@Crabcyborg
Crabcyborg deleted the update_redundant_empty_on_global_sniff_to_catch_more_code branch January 22, 2026 13:23
@codecov

codecov Bot commented Jan 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 27.05%. Comparing base (242ec04) to head (24f31b8).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
classes/models/fields/FrmFieldType.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2862      +/-   ##
============================================
- Coverage     27.05%   27.05%   -0.01%     
  Complexity     8866     8866              
============================================
  Files           145      145              
  Lines         29880    29874       -6     
============================================
- Hits           8084     8082       -2     
+ Misses        21796    21792       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

stephywells pushed a commit that referenced this pull request Apr 4, 2026
…obal_sniff_to_catch_more_code

Update redudant empty on global sniff to catch empty and not just ! e…
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