ameba icon indicating copy to clipboard operation
ameba copied to clipboard

[Feature Request] Lint against accessing instance variables outside of the instance of a class

Open DanielGilchrist opened this issue 7 months ago • 4 comments

It's possible to access instance variables on an instance of a class similarly to instance_variable_get in Ruby

class MyKlass
  def initialize(@my_instance_var : String); end
end

puts MyKlass.new("hello").@my_instance_var
# => "hello"

Crystal Playground

This can be handy for debugging purposes but I think generally should be discouraged as I think it's commonly expected that instance variables are private to the instance of a class.

DanielGilchrist avatar Jul 12 '24 12:07 DanielGilchrist