Skip to content

rubocop: Always run the "every formula should have a test block" check - #24188

Merged
MikeMcQuaid merged 1 commit into
mainfrom
formula-test-block-audit
Oct 10, 2026
Merged

MikeMcQuaid merged 1 commit into
mainfrom
formula-test-block-audit

Conversation

@issyl0

@issyl0 issyl0 commented Oct 7, 2026

Copy link
Copy Markdown
Member

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

  • So that every formula has a test block, this should be non-strict.

Copilot AI lite review requested due to automatic review settings October 7, 2026 12:44
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a9ae0672-6931-4c59-bc01-8873131ca5ba

📥 Commits

Reviewing files that changed from the base of the PR and between e45eac8 and f7aede5.


📒 Files selected for processing (1)
  • Library/Homebrew/rubocops/class.rb

💤 Files with no reviewable changes (1)
  • Library/Homebrew/rubocops/class.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📜 Recent review details
⏰ Context from checks skipped due to timeout. (21)
  • GitHub Check: docker (arm64 Ubuntu 26.04)
  • GitHub Check: docker (arm64 Ubuntu 24.04)
  • GitHub Check: docker (x86_64 Ubuntu 26.04)
  • GitHub Check: docker (x86_64 Ubuntu 24.04)
  • GitHub Check: Analyze
  • GitHub Check: tests (no Sorbet)
  • GitHub Check: tests (load-only Linux)
  • GitHub Check: tests (macOS, 1/2)
  • GitHub Check: tests (online, 2/2)
  • GitHub Check: tests (macOS, 2/2)
  • GitHub Check: tests (Linux, 1/2)
  • GitHub Check: tests (load-only macOS)
  • GitHub Check: tests (generic OS, 2/2)
  • GitHub Check: tests (Linux, 2/2)
  • GitHub Check: tests (online, 1/2)
  • GitHub Check: tests (generic OS, 1/2)
  • GitHub Check: syntax
  • GitHub Check: docs
  • GitHub Check: generate-tags
  • GitHub Check: workflow_syntax
  • GitHub Check: vendor-gems


📝 Summary

Summary by CodeRabbit

  • Bug Fixes

    • Formula checks now report when a formula is missing a test block, while continuing to exempt disabled formulas. Checks for empty or non-real test blocks and test-call arguments remain in place.
  • Tests

    • Added coverage confirming that formulas without test blocks are reported and that disabled formulas are exempt.

Walkthrough

FormulaAudit::Test now reports formulas without a test block, except when the formula uses disable!. The separate TestPresent cop and its tests were removed. Tests cover both cases, and the documentation configuration and PortableFormula shim disable FormulaAudit/Test.

Changes

Formula test-block audit

Layer / File(s) Summary
Audit missing test blocks
Library/Homebrew/rubocops/class.rb, Library/Homebrew/test/rubocops/class/test_present.rb, Library/Homebrew/test/rubocops/class/test_spec.rb, Library/Homebrew/sorbet/rbi/dsl/rubo_cop/cop/formula_audit_strict/test_present.rbi
FormulaAudit::Test reports a missing test block unless the formula uses disable!. The separate TestPresent cop, its tests, and its RBI declaration were removed. Tests cover both cases.
Configure audit exclusions
docs/.rubocop.yml, Library/Homebrew/sorbet/rbi/shims/portable_formula.rbi
The docs RuboCop configuration and PortableFormula shim disable FormulaAudit/Test.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Suggested reviewers: mikemcquaid


Merge Risk: ⚪ Minimal · up to f7aed

Ordinary formula audits now check for missing test blocks while preserving the intended exceptions. No issue identified here prevents merging after normal checks.

Architecture Summary

Architecture risk: 🔵 Low · up to e45ea

The change affects 2 systems.

Changed systems: Library, docs

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — Library (service) was modified; 5 changed files map to changed impact.
  • observed — docs (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in Library/Homebrew/rubocops/class.rb: FormulaAudit::Test now reports a missing test block unless the formula uses disable!; it marks the class node when the body is absent, then returns. Previously, this cop returned when no test block existed, leaving that check to the separate TestPresent cop.
  • observed — Modified behavior in Library/Homebrew/rubocops/class.rb: The TestPresent cop, which separately reported when a formula lacked a test block unless it used disable!, was removed.
  • observed — Modified behavior in Library/Homebrew/test/rubocops/class/test_present.rb: Deleted the TestPresent cop tests, including expectations for an offense when a formula lacks a test block and no offense when the formula is disabled.
  • observed — Modified behavior in Library/Homebrew/test/rubocops/class/test_spec.rb: Adds a test expecting an offense when a formula has no test do block.


Pre-merge checks | Passed 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description check Passed The description states that the test-block check should apply to every formula and identifies the change as non-strict. It directly relates to the changeset.
Title check Passed The title clearly summarizes the primary change: making the formula test-block check run for every formula. It is concise and directly related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@issyl0
issyl0 requested a review from SMillerDev October 7, 2026 12:47

This comment was marked as resolved.

@issyl0
issyl0 force-pushed the formula-test-block-audit branch from 74a5527 to e45eac8 Compare October 7, 2026 13:05

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good call, thanks!

@MikeMcQuaid
MikeMcQuaid enabled auto-merge October 7, 2026 13:11
@SMillerDev

Copy link
Copy Markdown
Member

Does this have to wait for Homebrew/homebrew-core#314008 and Homebrew/homebrew-core#315821?

@issyl0

issyl0 commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

Does this have to wait for Homebrew/homebrew-core#314008 and Homebrew/homebrew-core#315821?

Yeah, tap_syntax CI is failing. I'll rerun when they're merged?

- So that every formula has a test block, this should be non-strict.
- Fold it into the existing "test should have real things in it" cop for
  tidiness.
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Oct 10, 2026
Merged via the queue into main with commit 6971647 Oct 10, 2026
83 of 84 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the formula-test-block-audit branch October 10, 2026 18:05
kwabenantim added a commit to kwabenantim/homebrew-chaste that referenced this pull request Oct 12, 2026
Homebrew/brew#24188 made a `test do` block mandatory in `brew style`,
which fails tap-syntax for this formula. Bump version so the rebuilt
bottle gets its own release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants