lib/packwerk/offenses_formatter.rb in packwerk-3.0.1 vs lib/packwerk/offenses_formatter.rb in packwerk-3.1.0

- old
+ new

@@ -20,25 +20,34 @@ class << self extend T::Sig sig { params(base: Class).void } def included(base) - @offenses_formatters ||= T.let(@offenses_formatters, T.nilable(T::Array[Class])) - @offenses_formatters ||= [] - @offenses_formatters << base + offenses_formatters << base end sig { returns(T::Array[OffensesFormatter]) } def all - T.unsafe(@offenses_formatters).map(&:new) + load_defaults + T.cast(offenses_formatters.map(&:new), T::Array[OffensesFormatter]) end sig { params(identifier: String).returns(OffensesFormatter) } def find(identifier) formatter_by_identifier(identifier) end private + + sig { void } + def load_defaults + require("packwerk/formatters/default_offenses_formatter") + end + + sig { returns(T::Array[Class]) } + def offenses_formatters + @offenses_formatters ||= T.let([], T.nilable(T::Array[Class])) + end sig { params(name: String).returns(OffensesFormatter) } def formatter_by_identifier(name) @formatter_by_identifier ||= T.let(nil, T.nilable(T::Hash[String, T.nilable(OffensesFormatter)])) @formatter_by_identifier ||= begin