-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Change superclass for many cops #17
Conversation
Let's depend as little as possible on `::RuboCop::Cop::RSpec::Base` as cop superclass. Now, only `InferredSpecType` inherits from rubocop-rspec's base class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
How hard do you think it will be to untangle the remaining one?
I would need to add these few lines to the cop: include RuboCop::RSpec::Language
def on_new_investigation
super
RuboCop::RSpec::Language.config = config['RSpec']['Language']
end The first part seems fine, but overwriting The problem seems to be that rubocop-rspec doesn’t define |
It can’t be at load time, as the language config can vary in sub-directories. Can we subscribe somehow to the configloader, and set the languageconfig there? That shared memory issue again. I can’t recall what the original issue was. And do we really compile node patterns from scratch on new investigation (as the language config may have changed). The topic is not trivial. |
RuboCop Would have the same problem then, right? I guess there is a per-directory(or per-configfile) cache that maybe we could rely on? |
RuboCop doesn’t seem to need this to update dynamic matchers like |
Oh, good point. Changing a class variable when doing parallel processing isn’t so good 😅 RuboCop uses the Parallel gem which uses processes, threads or ractors. As I read RuboCop, Parallel.each and Parallel.map it looks like we default to running in threads. (Maybe RuboCop should be explicit about that…) |
Anyway, I declare scope creep 😄 Would the PR be okay to merge as-is, and then I’ll look into opening another PR for fixing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine. Let's follow up with another PR.
See #19. |
Let's depend as little as possible on
::RuboCop::Cop::RSpec::Base
as cop superclass.Now, only
InferredSpecType
inherits from rubocop-rspec's base class.See also rubocop/rubocop-rspec#1511
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).Added tests.Updated documentation.Added an entry to theCHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).