You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Person < Struct.new(:name)
def name
"Mr #{super}"
end
end
Person.ancestors
=> [Person, #<Class:0x0000558c1ea93a58>, Struct, Enumerable, Object, PP::ObjectMixin, Kernel, BasicObject]
Person.new(:matz).name
=> "Mr matz"
to...
Person = Struct.new(:name) do
def name
"Mr #{super}"
end
end
Person.ancestors
=> [Person, Struct, Enumerable, Object, PP::ObjectMixin, Kernel, BasicObject]
Person.new(:matz).name
=> `name': super: no superclass method `name' for #<struct Person name=:matz> (NoMethodError)
I think the purpose of Style/StructInheritance is to prevent these extra class levels. But this Auto-correct might change the semantics of the code.
Describe the solution you'd like
Make Auto-correct of Style/StructInheritance unsafe.
Rubocop version
~ rubocop -v
1.18.4
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Auto-correct of Style/StructInheritance is safe now.
(https://docs.rubocop.org/rubocop/cops_style.html#stylestructinheritance)
But Auto-correct of Style/StructInheritance will change the inheritance chain for the constant like this.
to...
I think the purpose of Style/StructInheritance is to prevent these extra class levels. But this Auto-correct might change the semantics of the code.
Describe the solution you'd like
Make Auto-correct of Style/StructInheritance unsafe.
Rubocop version
The text was updated successfully, but these errors were encountered: