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

Include thread-safety rubocop #703

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

alexpark20
Copy link

@alexpark20 alexpark20 commented Mar 6, 2025

Include thread_safety rubocop as part of Shopify style rubocop. This PR only enables the small subset of the rules as a starting point.

Note that this is part of Falcon on SFR effort (vault project here).

@github-actions github-actions bot added the config change Changes the Rubocop config by enabling, disabling, or reconfiguring one or many cops label Mar 6, 2025
@alexpark20 alexpark20 force-pushed the thread-safety-rubocop branch 2 times, most recently from 3999c6e to 5ab601c Compare March 6, 2025 16:43
ThreadSafety/NewThread:
Description: Avoid starting new threads. Let a framework like Sidekiq handle the
threads.
Enabled: true
Copy link
Member

Choose a reason for hiding this comment

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

This should not be enabled

Copy link
Author

Choose a reason for hiding this comment

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

Right, we are not enabling it on SFR too. I will disable it 👍

Enabled: true
ThreadSafety/MutableClassInstanceVariable:
Description: Do not assign mutable objects to class instance variables.
Enabled: true
Copy link
Member

Choose a reason for hiding this comment

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

This cop is disallowing:

class FooTest < ActiveSupport::TestCase
  setup do
    @something = { a: "A" }
  end
end

Which doesn't have any thread safety issue.

We need to fix that in order to enable it.

Copy link
Author

Choose a reason for hiding this comment

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

I will not enable it yet. Good check, lets socialize how we can fix it 👍

@alexpark20 alexpark20 force-pushed the thread-safety-rubocop branch 3 times, most recently from 4c2b934 to 3cd22cb Compare March 7, 2025 15:29
@alexpark20 alexpark20 requested a review from rafaelfranca March 7, 2025 15:50
@alexpark20 alexpark20 marked this pull request as ready for review March 10, 2025 15:13
@alexpark20 alexpark20 requested a review from a team as a code owner March 10, 2025 15:13
@sambostock sambostock force-pushed the thread-safety-rubocop branch from c04fc7a to a69842b Compare March 13, 2025 03:10
@sambostock
Copy link
Contributor

The unknown cop issue is fixed, but now we have the issue that rubocop-thread_safety imposes a minimum version requirement for rubocop which is higher than our current minimum (which we test against, so it breaks CI because the dependencies are unsatisfiable).

@sambostock
Copy link
Contributor

Simply bumping it doesn't work either, as it breaks some assumptions made by the tooling that ensures version compatibility. We'll have to fix that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config change Changes the Rubocop config by enabling, disabling, or reconfiguring one or many cops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants