Skip to content

diagnostic: fix spacing around warnings - #24485

Merged
HaraldNordgren merged 4 commits into
mainfrom
diagnostic-warning-spacing
Nov 5, 2026
Merged

HaraldNordgren merged 4 commits into
mainfrom
diagnostic-warning-spacing

Conversation

@HaraldNordgren

@HaraldNordgren HaraldNordgren commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

brew doctor puts two blank lines between this warning and its remediation, so they don't look related:

Warning: Some installed kegs have no formulae!
This means they were either deleted or installed manually.


You should find replacements for the following formulae:

  terraform

Finding#to_s already separates the two and this heredoc also ended in a blank line, so this removes it.

brew upgrade has the opposite problem, with a multi-line warning running straight into the next output:

Warning: You are using macOS 12.
We (and Apple) do not provide support for this old version.

Homebrew no longer builds bottles for this configuration.
Consider MacPorts, which provides binary packages for this macOS version:
  https://www.macports.org
==> Would upgrade 1 dependency:
llvm 22.1.8 -> 23.1.5

Diagnostic.checks now prints a blank line after multi-line warnings, which also separates two in a row. One-line warnings stay as they are and this doesn't affect brew doctor, which prints its own findings. The exception is :build_error_checks, because commands that continue after a failed build print their own blank line. brew upgrade already did and brew install now does too, so the next formula's output no longer runs into a warning. Outside Tier 1 a failed brew install can now get two blank lines before the tier message, as brew upgrade already does.

To reproduce:

mkdir -p "$(brew --cellar)/removed-formula/1.0"
brew doctor check_deleted_formula
rmdir "$(brew --cellar)/removed-formula/1.0" "$(brew --cellar)/removed-formula"
brew install --dry-run hello # needs a multi-line warning, e.g. on macOS 12

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

Claude Code (Claude Opus 5.5) found the causes, wrote the changes and their specs and ran them. Each new spec was seen failing before the code it covers was added. It ran the brew doctor reproduction, brew install --dry-run hello and a failing two-formula brew install from a local tap in a terminal on macOS 12. It ran brew lgtm on the final branch, which passed.


- `Finding#to_s` already separates the text from the remediation, so
  the blank line ending this heredoc doubled the gap
- Print a blank line after them in `Diagnostic.checks` so they stand
  apart from the output that follows
- Skip it for `:build_error_checks`, which end a failed build's output,
  as the tier message that follows adds its own blank line
@HaraldNordgren
HaraldNordgren force-pushed the diagnostic-warning-spacing branch from 4c9f03f to 4e0722e Compare November 4, 2026 21:10
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Multi-line diagnostic findings now have a blank line after non-build-error messages, making them easier to distinguish from surrounding output.
    • Failed-build diagnostics retain their existing spacing and do not gain an extra blank line after the message.
    • A blank line now separates a reported build error from its detailed error output.

Diagnostic checks adjust spacing after multi-line findings, and the deleted-formula finding text no longer includes an embedded blank line. Build-error handling prints a blank line before the error dump. Tests cover these output changes.

Changes: Diagnostic and build-error output

Layer / File(s) Summary
Diagnostic finding text and spacing
Library/Homebrew/diagnostic.rb, Library/Homebrew/test/diagnostic_spec.rb, Library/Homebrew/test/diagnostic_checks_spec.rb
Non-fatal checks add a blank line after multi-line findings, except for build-error checks. The deleted-formula finding text no longer includes an embedded blank line. Tests cover both spacing rules and the deleted-formula diagnostic content.
Build-error output boundary
Library/Homebrew/install.rb, Library/Homebrew/test/install_spec.rb
Build-error handling prints a blank line before dumping error details. A regression test checks the standard output.
Merge Risk: Low · up to 0de8b

A macOS source-build warning can gain an extra blank line; base the spacing check on warning text before merging.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title "diagnostic: fix spacing around warnings" matches the main change. The PR removes an extra blank line from a check_deleted_formula heredoc and adds a blank line after multi-line warnings in …
Description check Passed The description matches the changeset. It explains the two blank lines after the brew doctor warning, the missing separation after multi-line warnings in brew upgrade and brew install, the :build_erro…
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.
Full details: Title check

Explanation

The title "diagnostic: fix spacing around warnings" matches the main change. The PR removes an extra blank line from a check_deleted_formula heredoc and adds a blank line after multi-line warnings in Diagnostic.checks and install_formulae. The title is specific and short, and it names the affected area (diagnostic warnings), so it passes.

Full details: Description check

Explanation

The description matches the changeset. It explains the two blank lines after the brew doctor warning, the missing separation after multi-line warnings in brew upgrade and brew install, the :build_error_checks exception, and the reproduction steps. It describes the same files and behaviour as the raw summary, so it passes.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b2933145-156d-4ca1-b52a-c17f571026df
Commits

Reviewing files that changed from the base of the PR and between 8b0b7e4 and 4c9f03f.

Files selected for processing: 3
  • Library/Homebrew/diagnostic.rb
  • Library/Homebrew/test/diagnostic_checks_spec.rb
  • Library/Homebrew/test/diagnostic_spec.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.

Comment thread Library/Homebrew/diagnostic.rb Resolved
@HaraldNordgren
HaraldNordgren marked this pull request as draft November 4, 2026 21:48
- `Diagnostic.checks` adds no blank line after a failed build's checks,
  so the next formula's output could run straight into a warning
- Match `brew upgrade`, which already prints one after `e.dump`
@HaraldNordgren
HaraldNordgren marked this pull request as ready for review November 4, 2026 23:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Base the spacing check on the warning text. · diagnostic.rb:54

Library/Homebrew/diagnostic.rb:54
Minor · Functional Correctness · Quick win

Base the spacing check on the warning text.

During a macOS source build, check_clt_up_to_date can return one-line warning text with non-empty remediation. Finding#to_s then contains a newline from the remediation, so this predicate adds an extra stderr blank line. Check finding.text instead. This preserves the required separator after multi-line warning text without changing one-line warnings.

Suggested fix
-            $stderr.puts if type != :build_error_checks && finding.to_s.include?("\n")
+            $stderr.puts if type != :build_error_checks && finding.text.include?("\n")
Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b7949353-e9c2-4c59-a510-b616adf9af31
Commits

Reviewing files that changed from the base of the PR and between f40af3b and 0de8b93.

Files selected for processing: 3
  • Library/Homebrew/diagnostic.rb
  • Library/Homebrew/install.rb
  • Library/Homebrew/test/install_spec.rb
Files skipped from review as they are similar to previous changes: 1
  • Library/Homebrew/diagnostic.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.

@HaraldNordgren
HaraldNordgren added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit 944ccca Nov 5, 2026
59 checks passed
@HaraldNordgren
HaraldNordgren deleted the diagnostic-warning-spacing branch November 5, 2026 07:34

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

Thanks!

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.

3 participants

⌂ 换网址