Skip to content

Make Config attributes read-only#890

Open
amomchilov wants to merge 1 commit intomainfrom
Alex/tidy-sorbet-config
Open

Make Config attributes read-only#890
amomchilov wants to merge 1 commit intomainfrom
Alex/tidy-sorbet-config

Conversation

@amomchilov
Copy link
Copy Markdown
Contributor

@amomchilov amomchilov commented Apr 1, 2026

Well kind of, there's still some places where the arrays are edited in-place.

@amomchilov
Copy link
Copy Markdown
Contributor Author

amomchilov commented Apr 1, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@amomchilov amomchilov changed the title Make Config fields read-only Make Config attributes read-only Apr 1, 2026
@amomchilov amomchilov force-pushed the Alex/tidy-sorbet-config branch from d8279da to 487fe1b Compare April 1, 2026 20:13

#: bool
attr_accessor :no_stdlib
attr_reader :no_stdlib
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.

So we can add new paths/ignore/allowed_extensions but not change this flag?

Should we freeze the arrays then? We could also type them as Enumerable[String].

There are places where we do expect the config to not be read only: https://github.com/Shopify/spoom/blob/main/lib/spoom/coverage.rb#L19

Copy link
Copy Markdown
Contributor Author

@amomchilov amomchilov Apr 2, 2026

Choose a reason for hiding this comment

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

So we can add new paths/ignore/allowed_extensions but not change this flag?

Yeah basically.

Should we freeze the arrays then?

Not without changing the places like the one you mentioned, or that I change in this PR.

This is very much a half-measure, but still a marginal improvement

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.

What are the benefits of making it half-read-only? Can we keep it writable?

Base automatically changed from Alex/replace-manual-copy-with-dup to main April 2, 2026 14:47
@amomchilov amomchilov force-pushed the Alex/tidy-sorbet-config branch from 487fe1b to 47e43de Compare April 2, 2026 15:45
@amomchilov amomchilov marked this pull request as ready for review April 2, 2026 20:33
@amomchilov amomchilov requested a review from a team as a code owner April 2, 2026 20:33
@st0012
Copy link
Copy Markdown
Member

st0012 commented Apr 2, 2026

Are these 2 PRs performance optimization? Or do they fix some bad usage patterns we saw somewhere?

@amomchilov
Copy link
Copy Markdown
Contributor Author

@st0012 Just cleans ups I/Claude found while implementing #888

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