Skip to content

New sniff to improve inline comment consistency#2859

Merged
Crabcyborg merged 11 commits into
masterfrom
new_sniff_to_make_inline_comments_more_consistent
Jan 22, 2026
Merged

New sniff to improve inline comment consistency#2859
Crabcyborg merged 11 commits into
masterfrom
new_sniff_to_make_inline_comments_more_consistent

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Jan 22, 2026

This enforces that comments have a space (// Comment instead of //Comment) and start with a capital (// Commentinstead of// comment`).

There are various exceptions where this isn't really helpful.

Summary by CodeRabbit

  • Style

    • Standardized comment capitalization and formatting throughout the codebase for improved consistency.
  • Chores

    • Added a new PHP CodeSniffer sniff to enforce consistent comment spacing and capitalization rules in future development.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 22, 2026

Warning

Rate limit exceeded

@Crabcyborg has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 7 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.

📝 Walkthrough

Walkthrough

This PR standardizes comment formatting across 70+ files by capitalizing the first letter of comments and making minor wording adjustments, while introducing a new PHP_CodeSniffer sniff to enforce consistent comment spacing and capitalization rules.

Changes

Cohort / File(s) Summary
PHP_CodeSniffer Infrastructure
phpcs-sniffs/Formidable/Sniffs/Commenting/CommentSpacingSniff.php, phpcs-sniffs/Formidable/ruleset.xml
New CommentSpacingSniff class (180 lines) enforces space after // and optional capitalization of comment text; includes logic to detect code-like comments and single-word comments to avoid unnecessary capitalization. Ruleset entry added to enable the sniff.
Controllers - Comment Updates
classes/controllers/FrmAddonsController.php, FrmAppController.php, FrmApplicationsController.php, FrmDashboardController.php, FrmFieldsController.php, FrmFormActionsController.php, FrmFormsController.php, FrmSimpleBlocksController.php, FrmStylesController.php, FrmXMLController.php
Comment text capitalization adjustments (e.g., "don't" → "Don't", "view" → "View"). No behavioral or control-flow changes.
Helpers - Comment Updates
classes/helpers/FrmApiHelper.php, FrmAppHelper.php, FrmCSVExportHelper.php, FrmEntriesHelper.php, FrmFieldsHelper.php, FrmFormsHelper.php, FrmListHelper.php, FrmStylesHelper.php, FrmXMLHelper.php
Comment capitalization and minor wording updates across multiple methods. No functional changes.
Models - Comment Updates
classes/models/FrmAddon.php, FrmAntiSpam.php, FrmCreateFile.php, FrmDb.php, FrmEmail.php, FrmEntry.php, FrmEntryMeta.php, FrmEntryValidate.php, FrmField.php, FrmFieldFormHtml.php, FrmFieldValue.php, FrmForm.php, FrmFormAction.php, FrmFormApi.php, FrmFormMigrator.php, FrmHoneypot.php, FrmInbox.php, FrmInstallerSkin.php, FrmMigrate.php, FrmPersonalData.php, FrmPluginSearch.php, FrmReviews.php, FrmSalesApi.php, FrmStyle.php, FrmUsage.php, fields/FrmFieldCaptcha.php, fields/FrmFieldType.php, fields/FrmFieldUrl.php
Comment text capitalization and phrasing updates throughout model classes. No logic or control-flow changes.
Views - Comment Updates
classes/views/frm-entries/errors.php, form.php, frm-fields/front-end/checkbox-field.php, frm-form-actions/form_action.php, styles/manage.php, xml/forms_xml.php, xml/posts_xml.php
Comment capitalization adjustments in view templates. No behavioral changes.
Tests - Comment Updates
tests/phpunit/base/FrmAjaxUnitTest.php, FrmUnitTest.php, frm_factory.php, bootstrap.php, database/test_FrmMigrate.php, emails/test_FrmEmail.php, test_FrmEmailSummaryHelper.php, entries/test_FrmEntriesController.php, test_FrmPersonalData.php, fields/test_FrmFieldValidate.php, test_FrmFieldsAjax.php, forms/test_FrmForm.php, test_FrmFormsController.php, misc/test_FrmAppController.php, test_FrmAppHelper.php, test_FrmCSVExportHelper.php, styles/test_FrmStylesController.php, test_ajax.php
Comment capitalization standardization in test files. No test logic changes.
Third-party Integrations
square/helpers/FrmSquareLiteConnectHelper.php, stripe/controllers/FrmStrpLiteActionsController.php, FrmTransLiteActionsController.php, FrmTransLiteListsController.php, helpers/FrmStrpLiteConnectHelper.php, FrmStrpLiteLinkRedirectHelper.php
Comment capitalization updates in Square and Stripe integration files. No functional changes.
Configuration
rector.php
Comment capitalization updates in configuration file. No functional impact.
Factories
classes/factories/FrmFieldFactory.php
Comment capitalization change in filter-related comment.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

The review scope is large (70+ files) with highly homogeneous changes (comment capitalization following a consistent pattern), which reduces per-file complexity. The primary effort focuses on understanding and validating the new CommentSpacingSniff logic (~15 minutes) and spot-checking that comment changes follow the established pattern (~5 minutes).

Possibly related PRs

  • #2761: Adds ShortFunctionBlankLineSniff PHP_CodeSniffer sniff and applies associated style fixes across the codebase.
  • #2604: Widespread non-functional comment/docblock edits across many of the same controller, helper, and model files.
  • #2785: Introduces new custom PHP_CodeSniffer rules under phpcs-sniffs/Formidable directory with similar infrastructure patterns.

Poem

🐰 With hop and bound through comments clean,
Capitals now reign supreme!
A sniff to catch each lowercase start,
Our code's fresh polish, fine art! ✨

🚥 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 describes the primary change: a new PHP_CodeSniffer sniff was added to enforce comment spacing and capitalization consistency. While the PR also includes cosmetic comment updates across many files, these are secondary to the main objective of introducing the sniff rule.
Docstring Coverage ✅ Passed Docstring coverage is 95.59% 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@classes/models/FrmFieldValue.php`:
- Line 250: The comment in FrmFieldValue.php documents the WordPress filter hook
but alters its casing ("Frm_display_{fieldtype}_value_custom"), which can
mislead developers because hook names are case-sensitive; update the comment to
use the exact hook name "frm_display_{fieldtype}_value_custom" or rephrase the
sentence so the hook is shown verbatim while still allowing natural
capitalization elsewhere (locate the comment near the FrmFieldValue class
methods that reference the frm_display hook).

In `@classes/models/FrmUsage.php`:
- Around line 61-63: Update the inline comment above the $uuid assignment in
FrmUsage (the lines referencing md5( uniqid() . site_url() )) to correct the
grammar: change "an unique id" to "a unique id" so the comment reads "Close
enough to provide a unique id".

In `@phpcs-sniffs/Formidable/Sniffs/Commenting/CommentSpacingSniff.php`:
- Around line 95-97: The no-space auto-fix branch in CommentSpacingSniff.php
omits the TODO/FIXME exceptions, causing inconsistent capitalization; update the
preg_match regex used in the auto-fix path (the condition that sets $newText via
ucfirst when preg_match('/^[a-z]/', $firstChar) && ! $looksLikeCode && !
$isSingleWord && ! preg_match(...)) to include the same TODO/FIXME/other tokens
used by $shouldCapitalize so the exception list is identical to
$shouldCapitalize's regex, ensuring comments like "//todo:" are treated the same
in both branches.

In `@stripe/helpers/FrmStrpLiteLinkRedirectHelper.php`:
- Line 200: Update the capitalization of the payment method label in
FrmStrpLiteLinkRedirectHelper: find the comment/string "IDeal" (the one reading
"IDeal redirects URLs are incorrectly encoded.") and change it to the official
"iDEAL" to match the usage elsewhere (e.g., the "iDEAL" occurrence near line 98)
so the file uses a consistent brand casing throughout.
🧹 Nitpick comments (1)
classes/models/fields/FrmFieldCaptcha.php (1)

243-243: Consider rewording for grammatical completeness.

The comment "The double rendering issue using the frm_turnstile_js_url hook." is a sentence fragment. Consider one of these alternatives:

  • Lowercase to continue from line 242: // the double rendering issue using the frm_turnstile_js_url hook.
  • Complete sentence: // This addresses the double rendering issue when using the frm_turnstile_js_url hook.
✍️ Suggested improvement

Option 1 (continuation from line 242):

-// The double rendering issue using the frm_turnstile_js_url hook.
+// the double rendering issue using the frm_turnstile_js_url hook.

Option 2 (complete sentence):

-// The double rendering issue using the frm_turnstile_js_url hook.
+// This addresses the double rendering issue when using the frm_turnstile_js_url hook.

Comment thread classes/models/FrmFieldValue.php Outdated
Comment thread classes/models/FrmUsage.php
Comment thread phpcs-sniffs/Formidable/Sniffs/Commenting/CommentSpacingSniff.php Outdated
Comment thread stripe/helpers/FrmStrpLiteLinkRedirectHelper.php Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 27.05%. Comparing base (e6d1ed9) to head (242ec04).
⚠️ Report is 56 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #2859   +/-   ##
=========================================
  Coverage     27.04%   27.05%           
- Complexity     8857     8866    +9     
=========================================
  Files           145      145           
  Lines         29812    29880   +68     
=========================================
+ Hits           8063     8084   +21     
- Misses        21749    21796   +47     

☔ 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.

@Crabcyborg Crabcyborg merged commit 0d21e13 into master Jan 22, 2026
16 checks passed
@Crabcyborg Crabcyborg deleted the new_sniff_to_make_inline_comments_more_consistent branch January 22, 2026 01:35
stephywells pushed a commit that referenced this pull request Apr 4, 2026
…ments_more_consistent

New sniff to improve inline comment consistency
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