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

Fix someThreadSafety::InstanceVariableInClassMethod false positive offenses #42

Merged

Conversation

viralpraxis
Copy link
Collaborator

@viralpraxis viralpraxis commented Sep 9, 2024

Fixes #28, fixes #16, fixes #13

Detecting Data.define, Struct.new and Class.new is essentially the same as detecting define_method ancestors.

NOTE: there is a common issue for both new and existing logic: we do not check if new-lexical-scope-ancestor is also an ancestor for class method. See https://github.com/viralpraxis/rubocop-thread_safety/blob/9a7e9437aadaf3f6fdbe5e847c19542361f6cd92/spec/rubocop/cop/thread_safety/instance_variable_in_class_method_spec.rb#L108 for false negative example

I'll try to evaluate performance impact and check if it the issue mentioned above is fixable

@viralpraxis viralpraxis self-assigned this Sep 9, 2024
@viralpraxis viralpraxis force-pushed the enhance-ivar-in-class-methods-cop branch from 9c53955 to 9a7e943 Compare September 9, 2024 12:46
Copy link
Collaborator

@mikegee mikegee left a comment

Choose a reason for hiding this comment

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

Thanks!

@viralpraxis viralpraxis force-pushed the enhance-ivar-in-class-methods-cop branch from 9a7e943 to 0e61b75 Compare September 11, 2024 15:35
@viralpraxis
Copy link
Collaborator Author

I'll try to evaluate performance impact and check if it the issue mentioned above is fixable

Done.

@mikegee mind taking a look at this once again?

@viralpraxis viralpraxis force-pushed the enhance-ivar-in-class-methods-cop branch from 0e61b75 to 065e6fe Compare September 11, 2024 15:39
@viralpraxis viralpraxis marked this pull request as ready for review September 12, 2024 11:04
@viralpraxis
Copy link
Collaborator Author

Alright, hope it's OK to merge 🙂

@viralpraxis viralpraxis merged commit 5dc92f7 into rubocop:master Sep 13, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants