Skip to content

New sniff to remove extra white space before closing brace#2807

Merged
Crabcyborg merged 2 commits into
masterfrom
new_sniff_to_remove_extra_white_space_before_closing_brace
Jan 15, 2026
Merged

New sniff to remove extra white space before closing brace#2807
Crabcyborg merged 2 commits into
masterfrom
new_sniff_to_remove_extra_white_space_before_closing_brace

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Jan 15, 2026

Summary by CodeRabbit

  • New Features

    • Added a new code quality inspection rule that detects and automatically fixes unnecessary blank lines before closing braces, improving formatting consistency.
  • Chores

    • Improved comparison operator handling logic in code analysis tools for better condition transformation.
    • Whitespace and formatting cleanup across the codebase for enhanced consistency.

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

@Crabcyborg Crabcyborg added this to the 6.28 milestone Jan 15, 2026
@Crabcyborg Crabcyborg changed the base branch from master to make_new_sniffers_better_at_negating_conditions January 15, 2026 17:39
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 15, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This pull request performs comprehensive whitespace cleanup across the codebase and introduces a new PHP_CodeSniffer sniff to enforce formatting standards. It removes empty lines from controllers, helpers, models, and tests; adds a new NoBlankLineBeforeCloseBraceSniff to detect and auto-fix blank lines before closing braces; enhances two existing code-analysis sniffs with a comparison operator-flipping helper method; and registers the new sniff in the ruleset.

Changes

Cohort / File(s) Summary
Whitespace Cleanup in Classes
classes/controllers/FrmAddonsController.php, classes/controllers/FrmFormsController.php, classes/helpers/FrmEntriesHelper.php, classes/models/FrmDb.php, classes/models/FrmPluginSearch.php, classes/models/FrmEntryFormatter.php
Removed extraneous blank lines in various methods across controllers, helpers, and models. No functional or control flow changes; purely formatting refinements.
Test Whitespace Cleanup
tests/phpunit/misc/test_FrmAddon.php
Removed empty line in foreach loop assertion; formatting only.
New Whitespace Sniff
phpcs-sniffs/Formidable/Sniffs/WhiteSpace/NoBlankLineBeforeCloseBraceSniff.php
Introduces new sniff class to detect and auto-fix blank lines before closing braces. Registers on T_CLOSE_CURLY_BRACKET, counts preceding blank lines, reports fixable error, and removes extraneous whitespace while preserving necessary indentation.
Ruleset Registration
phpcs-sniffs/Formidable/ruleset.xml
Registers new Formidable.WhiteSpace.NoBlankLineBeforeCloseBrace rule in the ruleset.
Operator Flipping Enhancement
phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/FlipForeachIfToContinueSniff.php, phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/FlipIfToEarlyReturnSniff.php
Both sniffs gain new flipComparisonOperator() helper method that maps comparison operators to their opposites (e.g., !===, >=<). Updates negateCondition() to attempt operator flipping before falling back to generic negation wrapping.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰✨ A rabbit's ode to tidiness:
Blank lines before closing braces, be gone!
Our sniffs detect them, swift and strong,
Flipping operators with grace,
Whitespace cleaned to find its place—
The codebase now stands neat and true! 🌿

🚥 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 reflects the main change: a new PHP_CodeSniffer sniff class that detects and removes blank lines before closing braces, along with supporting code refinements.
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.


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.

Base automatically changed from make_new_sniffers_better_at_negating_conditions to master January 15, 2026 17:45
@Crabcyborg Crabcyborg merged commit 342386c into master Jan 15, 2026
13 checks passed
@Crabcyborg Crabcyborg deleted the new_sniff_to_remove_extra_white_space_before_closing_brace branch January 15, 2026 17:46
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