Ruby

Ruby

Made by DeepSource

Trailing comma in attribute declaration detected RB-LI1099

Bug risk
Major

Leaving a trailing comma in attribute declarations, such as #attr_reader will nullify the next method definition by overriding it with a getter method.

Bad practice

class Foo
  attr_reader :bar,

  def foo
    puts "Can not be reached."
  end
end

Recommended

class Foo
  attr_reader :bar

  def foo
    puts "This is very much reachable!"
  end
end