Skip to content

Fix dynamic completion audit crash#22380

Merged
MikeMcQuaid merged 1 commit into
mainfrom
fix-dynamic-completions-audit
May 22, 2026
Merged

Fix dynamic completion audit crash#22380
MikeMcQuaid merged 1 commit into
mainfrom
fix-dynamic-completions-audit

Conversation

@MikeMcQuaid
Copy link
Copy Markdown
Member

Fixes #22379

  • Avoid crashing on formulae that build shells: from a loop.
  • Keep the cop limited to literal shell lists it can safely rewrite.
  • Cover the rustup completion pattern that exposed the issue.

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes. Non-maintainers may only have one AI-assisted/generated PR open at a time.

OpenAI Codex 5.5 xhigh with local review and testing.


- Avoid crashing on formulae that build `shells:` from a loop.
- Keep the cop limited to literal shell lists it can safely rewrite.
- Cover the `rustup` completion pattern that exposed the issue.
Copilot AI review requested due to automatic review settings May 22, 2026 08:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a crash in the FormulaAudit/SingleGenerateCompletionsDSLCall RuboCop cop when it encounters generate_completions_from_executable calls whose shells: argument isn’t a simple literal list (e.g., shells: [shell] from a loop), as reported in #22379.

Changes:

  • Prevent the cop from crashing by only collecting shells when it can safely extract a literal shells: [:bash|:zsh|:fish] value.
  • Add an RSpec case covering the dynamic-shell loop pattern (similar to the rustup completion pattern that triggered the crash).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Library/Homebrew/rubocops/lines.rb Makes shell extraction nil-safe so non-literal shells: usage doesn’t raise during auditing.
Library/Homebrew/test/rubocops/lines/generate_completions_spec.rb Adds coverage ensuring the cop reports no offense (and does not crash) for dynamically generated shells:.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue May 22, 2026
Merged via the queue into main with commit 1fa041f May 22, 2026
41 checks passed
@MikeMcQuaid MikeMcQuaid deleted the fix-dynamic-completions-audit branch May 22, 2026 11:21
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.

SingleGenerateCompletionsDSLCall errors with single and valid multi-call

3 participants