Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Singleton from formatters #1904

Merged
merged 1 commit into from Apr 10, 2024

Conversation

Earlopain
Copy link
Contributor

Motivation

This will make it trivial to reload the rubocop config for #1457 without doing an awkward Singleton.__init__.
With GlobalState being a thing now, I don't see the need for a singleton anymore but open to hearing something else.

Implementation

Just use new everywhere. This exposed an issue with the unload_rubocop_runner function. RuboCopFormatter isn't defined if RuboCopRunner isn't defined, so both need to be removed for test_shows_error_if_formatter_set_to_rubocop_but_rubocop_not_available to properly work

Automated Tests

Existing ones

Manual Tests

Do some formatting, I guess.

This will make it trivial to reload the rubocop config for Shopify#1457 without doing an
awkward `Singleton.__init__`.
With `GlobalState` being a thing now, I don't see the need for a singleton
@Earlopain Earlopain requested a review from a team as a code owner April 9, 2024 15:47
@andyw8 andyw8 added chore Chore task server This pull request should be included in the server gem's release notes labels Apr 9, 2024
@vinistock vinistock added breaking-change Non-backward compatible change and removed chore Chore task labels Apr 10, 2024
Copy link
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

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

Nice. Thanks for the contribution!

We indeed don't need the singletons anymore and I'm happy to see them go.

Since the formatters are registered and kept in memory, we still achieve the same original goal (which was to avoid re-loading RuboCop configurations multiple times).

@vinistock vinistock merged commit 3850b82 into Shopify:main Apr 10, 2024
24 of 25 checks passed
@Earlopain Earlopain deleted the formatters-singleton branch April 10, 2024 20:14
@vinistock vinistock added other Changes that aren't bugfixes, enhancements or breaking changes and removed breaking-change Non-backward compatible change labels Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
other Changes that aren't bugfixes, enhancements or breaking changes server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants