Class: MetzScan::Analyzers::InheritanceDescendants

Inherits:
Object
  • Object
show all
Defined in:
lib/metz_scan/analyzers/inheritance_descendants.rb,
lib/metz_scan/analyzers/inheritance_descendants/triage.rb,
lib/metz_scan/analyzers/inheritance_descendants/finding.rb,
lib/metz_scan/analyzers/inheritance_descendants/metadata.rb,
lib/metz_scan/analyzers/inheritance_descendants/root_kind.rb

Overview

Reports configured inheritance roots with enough known descendants.

Defined Under Namespace

Modules: Metadata, RootKind, Triage Classes: Finding, Location

Constant Summary collapse

RULE_ID =
"MetzProject/DeepInheritanceTree"
PROJECT_ANALYZER_STATUS =
"validated"
CONFIDENCE =
"medium"
TRIAGE_SEVERITY =
"manual review"
TRIAGE_SUMMARY =
"Validated inheritance signal; review broad base classes and descendant spread in context."
WHY =
"Large inheritance trees hide coupling and make changes expensive."
SUGGESTED_NEXT_MOVES =
[
  "Review whether the base class is carrying multiple responsibilities.",
  "Prefer composition or narrower shared modules when descendants only need part of the base behavior."
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(paths: nil, index: nil, base_names: nil, minimum_descendants: 3) ⇒ InheritanceDescendants

Returns a new instance of InheritanceDescendants.



28
29
30
31
32
33
# File 'lib/metz_scan/analyzers/inheritance_descendants.rb', line 28

def initialize(paths: nil, index: nil, base_names: nil, minimum_descendants: 3)
  @paths = Array(paths)
  @index = index || ProjectIndex.build(@paths)
  @base_names = Array(base_names).compact
  @minimum_descendants = minimum_descendants
end

Instance Method Details

#callObject



35
36
37
38
39
# File 'lib/metz_scan/analyzers/inheritance_descendants.rb', line 35

def call
  return [] unless index.available?

  base_candidates.filter_map { |base_name| finding_for(base_name) }
end