Add install step write cops#22947
Merged
Merged
Conversation
- 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.
Contributor
There was a problem hiding this comment.
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, andFile.write(when the content is a literal string ending with\n) intowrite ..., 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
approved these changes
Jul 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
writeDSL can preserve overwrite semantics explicitly.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?OpenAI Codex 5.5 xhigh with local review and testing.