{
  "item_type": "subsection",
  "chapter_id": "analysis-guide",
  "subsection_id": "debt-patterns",
  "subsection_title": "Debt Patterns",
  "subsection_file": "book/src/analysis-guide/debt-patterns.md",
  "feature_mappings": [],
  "drift_detected": true,
  "severity": "high",
  "quality_assessment": "Documentation has significant inaccuracies: claims 27 debt types but codebase has 35. The documentation covers 27 'priority-specific' debt types but omits 8 legacy variants. GodModule is documented as separate but code uses unified GodObject. Category mappings are accurate.",
  "issues": [
    {
      "type": "incorrect_information",
      "severity": "high",
      "section": "Introduction",
      "description": "Documentation claims 27 debt types but actual implementation has 35 debt types in DebtType enum",
      "current_content": "Debtmap detects 27 types of technical debt",
      "should_be": "Debtmap detects 35 types of technical debt (27 priority-specific + 8 legacy types)",
      "fix_suggestion": "Update count to 35 and either document all debt types or clarify that only priority-specific types are documented, with legacy types (Todo, Fixme, CodeSmell, Complexity, Dependency, ResourceManagement, CodeOrganization, TestComplexity, TestQuality) deprecated for specialized variants",
      "source_reference": "src/priority/debt_types.rs:47-205"
    },
    {
      "type": "missing_content",
      "severity": "high",
      "section": "Debt Type Enum",
      "description": "Missing documentation for 8 legacy debt types: Todo, Fixme, CodeSmell, Complexity, Dependency, ResourceManagement, CodeOrganization, TestComplexity, TestQuality",
      "fix_suggestion": "Add section explaining legacy debt types are kept for backward compatibility but specialized variants should be preferred. These include: Todo (use TestTodo for tests), Fixme, CodeSmell, Complexity (use ComplexityHotspot), Dependency, ResourceManagement, CodeOrganization, TestComplexity (use TestComplexityHotspot), TestQuality",
      "source_reference": "src/priority/debt_types.rs:48-77 (marked as 'Legacy variants from core::DebtType')"
    },
    {
      "type": "incorrect_information",
      "severity": "medium",
      "section": "Architecture Debt",
      "description": "GodModule listed as separate debt type but code uses unified GodObject variant that handles all detection types (GodClass, GodFile, GodModule) via detection_type field",
      "current_content": "Lists GodObject and GodModule as separate types",
      "should_be": "GodObject is a unified variant with detection_type field distinguishing between GodClass, GodFile, GodModule",
      "fix_suggestion": "Update to explain that GodObject is a unified variant. The god_object_indicators.detection_type field distinguishes between GodClass, GodFile, and GodModule. Document all three detection scenarios under single GodObject entry.",
      "source_reference": "src/priority/debt_types.rs:143-154 (comment: 'Unified god object variant representing all detection types')"
    },
    {
      "type": "outdated_information",
      "severity": "medium",
      "section": "Debt Type Enum",
      "description": "Source references point to src/priority/mod.rs but DebtType is now in src/priority/debt_types.rs",
      "current_content": "Source: DebtType structure defined in src/priority/mod.rs:158-288",
      "should_be": "Source: DebtType structure defined in src/priority/debt_types.rs:47-205",
      "fix_suggestion": "Update all source references from mod.rs to debt_types.rs. The DebtType enum was refactored to a separate module.",
      "source_reference": "src/priority/mod.rs:194 (comment: 'DebtType moved to debt_types module for reduced complexity')"
    },
    {
      "type": "outdated_information",
      "severity": "medium",
      "section": "Debt Categories",
      "description": "Category mapping source reference points to wrong lines in mod.rs",
      "current_content": "Source: Verified from src/priority/mod.rs:309-347",
      "should_be": "Source: Verified from src/priority/mod.rs:216-254 (DebtCategory::from_debt_type method)",
      "fix_suggestion": "Update line number references to match current file structure",
      "source_reference": "src/priority/mod.rs:216-254"
    },
    {
      "type": "incomplete_explanation",
      "severity": "low",
      "section": "DebtType Enum Note",
      "description": "Documentation mentions 'adjusted_cyclomatic' field for ComplexityHotspot but the actual struct only has 'cyclomatic' and 'cognitive' fields",
      "current_content": "ComplexityHotspot includes cyclomatic, cognitive, and adjusted_cyclomatic (entropy-adjusted)",
      "should_be": "ComplexityHotspot includes cyclomatic and cognitive fields (no adjusted_cyclomatic in current implementation)",
      "fix_suggestion": "Remove reference to adjusted_cyclomatic or verify if this field exists elsewhere in the type system",
      "source_reference": "src/priority/debt_types.rs:84-87"
    },
    {
      "type": "incomplete_explanation",
      "severity": "low",
      "section": "Type Organization Debt",
      "description": "ScatteredType severity thresholds documented (Low=2 files, Medium=3-5, High=6+) but field is a String not enum in code",
      "current_content": "severity: Low=2 files, Medium=3-5 files, High=6+ files",
      "should_be": "severity is stored as String in the debt type, with values derived from file_count threshold",
      "fix_suggestion": "Clarify that severity is a derived String field calculated from file_count, not a separate enum",
      "source_reference": "src/priority/debt_types.rs:190-195"
    }
  ],
  "positive_aspects": [
    "Excellent detailed explanation of complexity-weighted god object detection with formula and real-world examples",
    "Comprehensive code examples showing bad vs good patterns for Testing, Performance, and Code Quality debt types",
    "Well-organized by category (Testing, Architecture, Performance, Code Quality) with clear strategic focus guidance",
    "Good coverage of Type Organization debt patterns (ScatteredType, OrphanedFunctions, UtilitiesSprawl) with examples",
    "Clear debt scoring formula explanation with priority weights table",
    "Strong coverage of detection criteria for 27 priority-specific debt types",
    "Good language-specific notes about patterns that only apply to certain languages"
  ],
  "improvement_suggestions": [
    "Add section explaining legacy debt types and their relationship to specialized variants",
    "Update GodModule documentation to reflect unified GodObject implementation",
    "Update all source file references from mod.rs to debt_types.rs with correct line numbers",
    "Consider adding a comprehensive table showing all 35 debt types with their status (legacy vs priority-specific)",
    "Add note about the deprecation path for legacy types and migration guidance",
    "Verify adjusted_cyclomatic field reference - remove if not in current implementation"
  ],
  "cross_references": [],
  "metadata": {
    "analyzed_at": "2025-12-27T08:30:00Z",
    "feature_inventory": ".prodigy/book-analysis/features.json",
    "topics_covered": [
      "Debt types",
      "Debt categories",
      "Detection criteria",
      "Examples by category"
    ],
    "validation_focus": "Ensure all 25 debt types are documented with detection criteria",
    "actual_debt_type_count": 35,
    "documented_debt_type_count": 27,
    "legacy_debt_types": [
      "Todo",
      "Fixme",
      "CodeSmell",
      "Complexity",
      "Dependency",
      "ResourceManagement",
      "CodeOrganization",
      "TestComplexity",
      "TestQuality"
    ],
    "priority_specific_debt_types": [
      "TestingGap",
      "ComplexityHotspot",
      "DeadCode",
      "Duplication",
      "Risk",
      "TestComplexityHotspot",
      "TestTodo",
      "TestDuplication",
      "ErrorSwallowing",
      "AllocationInefficiency",
      "StringConcatenation",
      "NestedLoops",
      "BlockingIO",
      "SuboptimalDataStructure",
      "GodObject",
      "FeatureEnvy",
      "PrimitiveObsession",
      "MagicValues",
      "AssertionComplexity",
      "FlakyTestPattern",
      "AsyncMisuse",
      "ResourceLeak",
      "CollectionInefficiency",
      "ScatteredType",
      "OrphanedFunctions",
      "UtilitiesSprawl"
    ],
    "category_mapping_source": "src/priority/mod.rs:216-254",
    "debt_type_enum_source": "src/priority/debt_types.rs:47-205"
  }
}
