Skip to content

Add install step write cops#22947

Merged
p-linnane merged 1 commit into
mainfrom
install-steps-write-rubocops
Jul 4, 2026
Merged

Add install step write cops#22947
p-linnane merged 1 commit into
mainfrom
install-steps-write-rubocops

Conversation

@MikeMcQuaid

Copy link
Copy Markdown
Member
  • Make the install-step RuboCops convert simple literal writes now that the write DSL can preserve overwrite semantics explicitly.
  • Leave newline-less writes as legacy Ruby because the step DSL appends a trailing newline and autocorrection must not alter file contents.

  • 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 Hyperfine benchmarks.
  • 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?

  • AI was used to generate or assist with generating this PR.

OpenAI Codex 5.5 xhigh with local review and testing.


- Make the install-step RuboCops convert simple literal writes now that
  the `write` DSL can preserve overwrite semantics explicitly.
- Leave newline-less writes as legacy Ruby because the step DSL appends
  a trailing newline and autocorrection must not alter file contents.
@MikeMcQuaid MikeMcQuaid marked this pull request as ready for review July 4, 2026 17:41
Copilot AI review requested due to automatic review settings July 4, 2026 17:41

Copilot AI 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.

Pull request overview

This PR updates Homebrew’s install-step RuboCops to also recognize and safely autocorrect simple “config file write” patterns inside legacy post_install / flight blocks into the *_steps DSL, now that write can explicitly preserve overwrite behavior. It deliberately avoids autocorrecting writes that don’t end in a newline because the step DSL appends a trailing newline and must not change file contents.

Changes:

  • Extend the shared install-steps RuboCop helper to convert simple .write, .atomic_write, and File.write (when the content is a literal string ending with \n) into write ..., overwrite: true.
  • Add new formula and cask RuboCop specs covering both the positive autocorrection cases and the “no trailing newline” non-autocorrect cases.
  • Update the project plan markdown to mark the PR 5.2 item as completed and document the scope.

Reviewed changes

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

File Description
Library/Homebrew/test/rubocops/install_steps_spec.rb Adds coverage for formula post_install autocorrection to post_install_steps for literal newline-terminated writes (and ensures no autocorrect without trailing newline).
Library/Homebrew/test/rubocops/cask/install_steps_spec.rb Adds coverage for cask postflight autocorrection to postflight_steps for literal newline-terminated writes (and ensures no autocorrect without trailing newline).
Library/Homebrew/rubocops/shared/install_steps_helper.rb Implements conversion logic for write/atomic_write/File.write into write step lines with overwrite: true, preserving heredoc formatting.
Library/Homebrew/json_api_postinstall_preflight_postflight_plan.md Marks the corresponding plan item completed and records the implemented scope/constraints.

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

@p-linnane p-linnane added this pull request to the merge queue Jul 4, 2026
Merged via the queue into main with commit 72ba737 Jul 4, 2026
43 checks passed
@p-linnane p-linnane deleted the install-steps-write-rubocops branch July 4, 2026 20:39
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