Ruby logoRuby/
RB-ST1018

Use of class variables detectedRB-ST1018

Minor severityMinor
Anti-pattern categoryAnti-pattern

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
class A
  @test = 10
end

# OR

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