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

False positive: ThreadSafety/InstanceVariableInClassMethod in anonymous classes #13

Open
jas14 opened this issue Jul 1, 2022 · 0 comments

Comments

@jas14
Copy link

jas14 commented Jul 1, 2022

Summary

ThreadSafety/InstanceVariableInClassMethod rule fires when assigning an anonymous class's instance variable.

Example file

class Outer
  def self.create_anonymous_class
    Class.new do
      def initialize
        @anonymous_variable = 'hi'
      end
    end
  end
end

Expected

No errors.

Actual

Inspecting 1 file
C

Offenses:

test.rb:7:9: C: ThreadSafety/InstanceVariableInClassMethod: Avoid instance variables in class methods.
        @anonymous_variable = 'hi'
        ^^^^^^^^^^^^^^^^^^^
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

1 participant