Ruby

Ruby

Made by DeepSource

Use of class variables detected RB-ST1018

Anti-pattern
Minor

Care is needed when setting a value for a class variable; if a class has been inherited, changing the value of a class variable also affects the inheriting classes. This means that it's almost always better to use a class instance variable instead.

Bad practice

class A
  @@test = 10
end

Recommended

class A
  @test = 10
end

# OR

class A
  def test
    @@test # you can access class variable without offense
  end
end