class RubbyCop::Cop::Style::StructInheritance

This cop checks for inheritance from Struct.new.

@example

# bad
class Person < Struct.new(:first_name, :last_name)
end

# good
Person = Struct.new(:first_name, :last_name)

Constants

MSG

Public Instance Methods

on_class(node) click to toggle source
# File lib/rubbycop/cop/style/struct_inheritance.rb, line 18
def on_class(node)
  _name, superclass, _body = *node
  return unless struct_constructor?(superclass)

  add_offense(node, superclass.source_range, MSG)
end