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

Can we have a cop to recommend not using Dir.chdir? #29

Open
timdiggins opened this issue Nov 14, 2023 · 1 comment
Open

Can we have a cop to recommend not using Dir.chdir? #29

timdiggins opened this issue Nov 14, 2023 · 1 comment

Comments

@timdiggins
Copy link

Is your feature request related to a problem? Please describe.

I was recently bitten by the issue that Dir.chdir (including with a block) actually affects the process (rather than somehow being local to the ruby thread ) and thus is non threadsafe.

Describe the solution you'd like

A built in cop to ban Dir.chdir.
Ruby 3.0 throws an error if you try to chdir within another chdir (from another thread) https://bugs.ruby-lang.org/issues/15661

Describe alternatives you've considered

It's possible to use this code more or less as is: https://gist.github.com/masutaka/68d372b7f7910f552eeb215bb2e5d3cc

but think it would be good to have it built in. Thoughts?

@koic
Copy link
Member

koic commented Nov 15, 2023

This probably looks like an issue handled by RuboCop::ThreadSafety rather than RuboCop core.
https://github.com/rubocop/rubocop-thread_safety

@koic koic transferred this issue from rubocop/rubocop Nov 15, 2023
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

No branches or pull requests

2 participants