mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
fd2f37eaa0
Changes: - Fix README.md agent counts (48 QE agents = 41 main + 7 subagents) - Fix README.md skill counts (15 QE-specific skills) - Fix v3/README.md agent counts (47 → 48) - Fix init-wizard.ts hooks from 'npx @agentic-qe/v3' to 'npx agentic-qe' - Complete v2 → v2/ folder reorganization (54 items moved) - Update root package.json to point to v3 as main version Verified claims: - 48 QE agents (41 main + 7 TDD subagents) - 15 QE-specific skills - 12 DDD bounded contexts - ~5,600+ tests - HNSW, ReasoningBank, Queen Coordinator features exist Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1157 lines
38 KiB
JSON
1157 lines
38 KiB
JSON
{
|
|
"analysis_metadata": {
|
|
"generated_at": "2025-12-22T00:00:00.000Z",
|
|
"agent": "qe-code-complexity",
|
|
"analyzed_files": [
|
|
"src/core/FleetManager.ts",
|
|
"src/agents/BaseAgent.ts"
|
|
],
|
|
"complexity_thresholds": {
|
|
"cyclomatic": 10,
|
|
"cognitive": 15,
|
|
"lines_of_code": 300
|
|
}
|
|
},
|
|
"overall_summary": {
|
|
"total_files": 2,
|
|
"total_methods": 56,
|
|
"methods_exceeding_threshold": 8,
|
|
"average_cyclomatic_complexity": 8.2,
|
|
"average_cognitive_complexity": 12.4,
|
|
"total_lines_of_code": 2571,
|
|
"quality_score": 73
|
|
},
|
|
"file_analysis": [
|
|
{
|
|
"file": "src/core/FleetManager.ts",
|
|
"metrics": {
|
|
"total_lines": 709,
|
|
"code_lines": 587,
|
|
"comment_lines": 122,
|
|
"blank_lines": 0,
|
|
"function_count": 19
|
|
},
|
|
"quality_score": 78,
|
|
"issues": [
|
|
{
|
|
"severity": "medium",
|
|
"type": "file_size",
|
|
"message": "File exceeds recommended size threshold (709 lines > 300 lines)",
|
|
"recommendation": "Consider splitting into smaller modules (e.g., AgentSpawner, TaskCoordinator, CodeIntelligenceIntegration)"
|
|
}
|
|
],
|
|
"methods": [
|
|
{
|
|
"name": "constructor",
|
|
"line_start": 118,
|
|
"line_end": 155,
|
|
"cyclomatic_complexity": 7,
|
|
"cognitive_complexity": 10,
|
|
"lines_of_code": 37,
|
|
"parameters": 2,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity. Consider extracting logger initialization to separate method."
|
|
},
|
|
{
|
|
"name": "createFallbackLogger",
|
|
"line_start": 161,
|
|
"line_end": 189,
|
|
"cyclomatic_complexity": 5,
|
|
"cognitive_complexity": 8,
|
|
"lines_of_code": 28,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Good complexity. Well-structured fallback implementation."
|
|
},
|
|
{
|
|
"name": "resolveMemoryDbPath",
|
|
"line_start": 201,
|
|
"line_end": 227,
|
|
"cyclomatic_complexity": 6,
|
|
"cognitive_complexity": 9,
|
|
"lines_of_code": 26,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity. Logic is clear with appropriate fallbacks."
|
|
},
|
|
{
|
|
"name": "initialize",
|
|
"line_start": 249,
|
|
"line_end": 285,
|
|
"cyclomatic_complexity": 11,
|
|
"cognitive_complexity": 18,
|
|
"lines_of_code": 36,
|
|
"parameters": 0,
|
|
"issues": [
|
|
{
|
|
"severity": "high",
|
|
"type": "cyclomatic_complexity",
|
|
"value": 11,
|
|
"threshold": 10,
|
|
"message": "Cyclomatic complexity (11) exceeds threshold (10)"
|
|
},
|
|
{
|
|
"severity": "medium",
|
|
"type": "cognitive_complexity",
|
|
"value": 18,
|
|
"threshold": 15,
|
|
"message": "Cognitive complexity (18) exceeds threshold (15)"
|
|
}
|
|
],
|
|
"recommendation": "REFACTOR: Apply Extract Method pattern. Extract database initialization, event bus initialization, and code intelligence setup into separate methods (initializeDatabase, initializeEventBus, initializeCodeIntelligence)."
|
|
},
|
|
{
|
|
"name": "start",
|
|
"line_start": 300,
|
|
"line_end": 314,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 4,
|
|
"lines_of_code": 14,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Good complexity. Method is clear and focused."
|
|
},
|
|
{
|
|
"name": "stop",
|
|
"line_start": 332,
|
|
"line_end": 359,
|
|
"cyclomatic_complexity": 4,
|
|
"cognitive_complexity": 6,
|
|
"lines_of_code": 27,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity. Proper graceful shutdown sequence."
|
|
},
|
|
{
|
|
"name": "spawnAgent",
|
|
"line_start": 380,
|
|
"line_end": 441,
|
|
"cyclomatic_complexity": 9,
|
|
"cognitive_complexity": 14,
|
|
"lines_of_code": 61,
|
|
"parameters": 2,
|
|
"issues": [
|
|
{
|
|
"severity": "low",
|
|
"type": "lines_of_code",
|
|
"value": 61,
|
|
"threshold": 50,
|
|
"message": "Method length approaching complexity threshold"
|
|
}
|
|
],
|
|
"recommendation": "Consider extracting agent configuration preparation and validation into separate methods (prepareAgentConfig, validateAgent)."
|
|
},
|
|
{
|
|
"name": "removeAgent",
|
|
"line_start": 446,
|
|
"line_end": 457,
|
|
"cyclomatic_complexity": 2,
|
|
"cognitive_complexity": 3,
|
|
"lines_of_code": 11,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Simple and focused method. No changes needed."
|
|
},
|
|
{
|
|
"name": "submitTask",
|
|
"line_start": 482,
|
|
"line_end": 496,
|
|
"cyclomatic_complexity": 4,
|
|
"cognitive_complexity": 6,
|
|
"lines_of_code": 14,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Good complexity. Clear task submission logic."
|
|
},
|
|
{
|
|
"name": "getStatus",
|
|
"line_start": 512,
|
|
"line_end": 535,
|
|
"cyclomatic_complexity": 1,
|
|
"cognitive_complexity": 2,
|
|
"lines_of_code": 23,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple aggregation method. Well-structured."
|
|
},
|
|
{
|
|
"name": "getAgent",
|
|
"line_start": 540,
|
|
"line_end": 542,
|
|
"cyclomatic_complexity": 1,
|
|
"cognitive_complexity": 1,
|
|
"lines_of_code": 2,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Simple getter. No issues."
|
|
},
|
|
{
|
|
"name": "getAllAgents",
|
|
"line_start": 547,
|
|
"line_end": 549,
|
|
"cyclomatic_complexity": 1,
|
|
"cognitive_complexity": 1,
|
|
"lines_of_code": 2,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple getter. No issues."
|
|
},
|
|
{
|
|
"name": "getTask",
|
|
"line_start": 553,
|
|
"line_end": 555,
|
|
"cyclomatic_complexity": 1,
|
|
"cognitive_complexity": 1,
|
|
"lines_of_code": 2,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Simple getter. No issues."
|
|
},
|
|
{
|
|
"name": "getAllTasks",
|
|
"line_start": 560,
|
|
"line_end": 562,
|
|
"cyclomatic_complexity": 1,
|
|
"cognitive_complexity": 1,
|
|
"lines_of_code": 2,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple getter. No issues."
|
|
},
|
|
{
|
|
"name": "getMemoryStore",
|
|
"line_start": 572,
|
|
"line_end": 574,
|
|
"cyclomatic_complexity": 1,
|
|
"cognitive_complexity": 1,
|
|
"lines_of_code": 2,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple getter. No issues."
|
|
},
|
|
{
|
|
"name": "findAvailableAgent",
|
|
"line_start": 579,
|
|
"line_end": 584,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 4,
|
|
"lines_of_code": 5,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Simple predicate method. Well-focused."
|
|
},
|
|
{
|
|
"name": "createInitialAgents",
|
|
"line_start": 589,
|
|
"line_end": 597,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 5,
|
|
"lines_of_code": 8,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple iteration pattern. No issues."
|
|
},
|
|
{
|
|
"name": "initializeCodeIntelligence",
|
|
"line_start": 607,
|
|
"line_end": 658,
|
|
"cyclomatic_complexity": 13,
|
|
"cognitive_complexity": 21,
|
|
"lines_of_code": 51,
|
|
"parameters": 0,
|
|
"issues": [
|
|
{
|
|
"severity": "high",
|
|
"type": "cyclomatic_complexity",
|
|
"value": 13,
|
|
"threshold": 10,
|
|
"message": "Cyclomatic complexity (13) exceeds threshold (10)"
|
|
},
|
|
{
|
|
"severity": "high",
|
|
"type": "cognitive_complexity",
|
|
"value": 21,
|
|
"threshold": 15,
|
|
"message": "Cognitive complexity (21) exceeds threshold (15)"
|
|
},
|
|
{
|
|
"severity": "medium",
|
|
"type": "lines_of_code",
|
|
"value": 51,
|
|
"threshold": 50,
|
|
"message": "Method length exceeds recommended size"
|
|
}
|
|
],
|
|
"recommendation": "REFACTOR CRITICAL: High complexity detected. Extract configuration loading (loadCodeIntelligenceConfig), prerequisite checking (checkCodeIntelligencePrereqs), and service initialization (createCodeIntelligenceService) into separate methods. Apply Guard Clause pattern to reduce nesting."
|
|
},
|
|
{
|
|
"name": "getCodeIntelligenceConfig",
|
|
"line_start": 665,
|
|
"line_end": 675,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 4,
|
|
"lines_of_code": 10,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple getter with guard clause. Well-structured."
|
|
},
|
|
{
|
|
"name": "hasCodeIntelligence",
|
|
"line_start": 680,
|
|
"line_end": 682,
|
|
"cyclomatic_complexity": 2,
|
|
"cognitive_complexity": 2,
|
|
"lines_of_code": 2,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple predicate. No issues."
|
|
},
|
|
{
|
|
"name": "setupEventHandlers",
|
|
"line_start": 687,
|
|
"line_end": 708,
|
|
"cyclomatic_complexity": 4,
|
|
"cognitive_complexity": 6,
|
|
"lines_of_code": 21,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity. Event handler registration is straightforward."
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"file": "src/agents/BaseAgent.ts",
|
|
"metrics": {
|
|
"total_lines": 1862,
|
|
"code_lines": 1547,
|
|
"comment_lines": 315,
|
|
"blank_lines": 0,
|
|
"function_count": 65
|
|
},
|
|
"quality_score": 68,
|
|
"issues": [
|
|
{
|
|
"severity": "critical",
|
|
"type": "file_size",
|
|
"message": "File significantly exceeds recommended size threshold (1862 lines > 300 lines)",
|
|
"recommendation": "CRITICAL REFACTOR: Split into multiple files using Decompose Conditional and Extract Class patterns: BaseAgentCore, BaseAgentLLM, BaseAgentLearning, BaseAgentCodeIntelligence, BaseAgentMemory"
|
|
}
|
|
],
|
|
"methods": [
|
|
{
|
|
"name": "constructor",
|
|
"line_start": 238,
|
|
"line_end": 296,
|
|
"cyclomatic_complexity": 8,
|
|
"cognitive_complexity": 12,
|
|
"lines_of_code": 58,
|
|
"parameters": 1,
|
|
"issues": [
|
|
{
|
|
"severity": "medium",
|
|
"type": "lines_of_code",
|
|
"value": 58,
|
|
"threshold": 50,
|
|
"message": "Constructor is too long"
|
|
}
|
|
],
|
|
"recommendation": "Extract configuration processing, strategy initialization, and service setup into separate methods (initializeConfig, createStrategies, setupServices)."
|
|
},
|
|
{
|
|
"name": "initialize",
|
|
"line_start": 300,
|
|
"line_end": 366,
|
|
"cyclomatic_complexity": 10,
|
|
"cognitive_complexity": 16,
|
|
"lines_of_code": 66,
|
|
"parameters": 0,
|
|
"issues": [
|
|
{
|
|
"severity": "high",
|
|
"type": "cyclomatic_complexity",
|
|
"value": 10,
|
|
"threshold": 10,
|
|
"message": "Cyclomatic complexity at threshold"
|
|
},
|
|
{
|
|
"severity": "medium",
|
|
"type": "cognitive_complexity",
|
|
"value": 16,
|
|
"threshold": 15,
|
|
"message": "Cognitive complexity (16) exceeds threshold (15)"
|
|
},
|
|
{
|
|
"severity": "high",
|
|
"type": "lines_of_code",
|
|
"value": 66,
|
|
"threshold": 50,
|
|
"message": "Method is too long"
|
|
}
|
|
],
|
|
"recommendation": "REFACTOR: Extract initialization steps into separate methods (initializeLearning, initializeExtensions, initializeState). Use Template Method pattern."
|
|
},
|
|
{
|
|
"name": "executeTask",
|
|
"line_start": 368,
|
|
"line_end": 399,
|
|
"cyclomatic_complexity": 5,
|
|
"cognitive_complexity": 8,
|
|
"lines_of_code": 31,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity. Task lifecycle is well-structured."
|
|
},
|
|
{
|
|
"name": "terminate",
|
|
"line_start": 401,
|
|
"line_end": 423,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 5,
|
|
"lines_of_code": 22,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Good complexity. Cleanup sequence is clear."
|
|
},
|
|
{
|
|
"name": "getStatus",
|
|
"line_start": 429,
|
|
"line_end": 437,
|
|
"cyclomatic_complexity": 1,
|
|
"cognitive_complexity": 2,
|
|
"lines_of_code": 8,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple getter. No issues."
|
|
},
|
|
{
|
|
"name": "waitForStatus",
|
|
"line_start": 450,
|
|
"line_end": 465,
|
|
"cyclomatic_complexity": 7,
|
|
"cognitive_complexity": 10,
|
|
"lines_of_code": 15,
|
|
"parameters": 2,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity for promise-based state waiting logic."
|
|
},
|
|
{
|
|
"name": "waitForReady",
|
|
"line_start": 467,
|
|
"line_end": 474,
|
|
"cyclomatic_complexity": 5,
|
|
"cognitive_complexity": 6,
|
|
"lines_of_code": 7,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Simple delegation method. No issues."
|
|
},
|
|
{
|
|
"name": "waitForEvent",
|
|
"line_start": 476,
|
|
"line_end": 485,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 4,
|
|
"lines_of_code": 9,
|
|
"parameters": 2,
|
|
"issues": [],
|
|
"recommendation": "Standard promise wrapper. No issues."
|
|
},
|
|
{
|
|
"name": "recommendStrategy",
|
|
"line_start": 489,
|
|
"line_end": 493,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 4,
|
|
"lines_of_code": 4,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Simple delegation with guard clause. Well-structured."
|
|
},
|
|
{
|
|
"name": "getLearnedPatterns",
|
|
"line_start": 495,
|
|
"line_end": 498,
|
|
"cyclomatic_complexity": 2,
|
|
"cognitive_complexity": 2,
|
|
"lines_of_code": 3,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple getter. No issues."
|
|
},
|
|
{
|
|
"name": "getLearningStatus",
|
|
"line_start": 500,
|
|
"line_end": 509,
|
|
"cyclomatic_complexity": 4,
|
|
"cognitive_complexity": 5,
|
|
"lines_of_code": 9,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple aggregation method. No issues."
|
|
},
|
|
{
|
|
"name": "start",
|
|
"line_start": 513,
|
|
"line_end": 517,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 3,
|
|
"lines_of_code": 4,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple delegation. No issues."
|
|
},
|
|
{
|
|
"name": "stop",
|
|
"line_start": 519,
|
|
"line_end": 519,
|
|
"cyclomatic_complexity": 1,
|
|
"cognitive_complexity": 1,
|
|
"lines_of_code": 1,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple delegation. No issues."
|
|
},
|
|
{
|
|
"name": "assignTask",
|
|
"line_start": 521,
|
|
"line_end": 530,
|
|
"cyclomatic_complexity": 1,
|
|
"cognitive_complexity": 2,
|
|
"lines_of_code": 9,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Simple task assignment. No issues."
|
|
},
|
|
{
|
|
"name": "onPreTask",
|
|
"line_start": 621,
|
|
"line_end": 630,
|
|
"cyclomatic_complexity": 4,
|
|
"cognitive_complexity": 6,
|
|
"lines_of_code": 9,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Standard lifecycle hook. No issues."
|
|
},
|
|
{
|
|
"name": "onPostTask",
|
|
"line_start": 632,
|
|
"line_end": 667,
|
|
"cyclomatic_complexity": 11,
|
|
"cognitive_complexity": 17,
|
|
"lines_of_code": 35,
|
|
"parameters": 1,
|
|
"issues": [
|
|
{
|
|
"severity": "high",
|
|
"type": "cyclomatic_complexity",
|
|
"value": 11,
|
|
"threshold": 10,
|
|
"message": "Cyclomatic complexity (11) exceeds threshold (10)"
|
|
},
|
|
{
|
|
"severity": "medium",
|
|
"type": "cognitive_complexity",
|
|
"value": 17,
|
|
"threshold": 15,
|
|
"message": "Cognitive complexity (17) exceeds threshold (15)"
|
|
}
|
|
],
|
|
"recommendation": "REFACTOR: Extract federated learning pattern sharing into separate method (shareFederatedPattern). Apply Guard Clause pattern to reduce nesting."
|
|
},
|
|
{
|
|
"name": "onTaskError",
|
|
"line_start": 669,
|
|
"line_end": 686,
|
|
"cyclomatic_complexity": 7,
|
|
"cognitive_complexity": 9,
|
|
"lines_of_code": 17,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity for error handling logic."
|
|
},
|
|
{
|
|
"name": "initializeLLMProvider",
|
|
"line_start": 760,
|
|
"line_end": 854,
|
|
"cyclomatic_complexity": 21,
|
|
"cognitive_complexity": 32,
|
|
"lines_of_code": 94,
|
|
"parameters": 0,
|
|
"issues": [
|
|
{
|
|
"severity": "critical",
|
|
"type": "cyclomatic_complexity",
|
|
"value": 21,
|
|
"threshold": 10,
|
|
"message": "Cyclomatic complexity (21) severely exceeds threshold (10)"
|
|
},
|
|
{
|
|
"severity": "critical",
|
|
"type": "cognitive_complexity",
|
|
"value": 32,
|
|
"threshold": 15,
|
|
"message": "Cognitive complexity (32) severely exceeds threshold (15)"
|
|
},
|
|
{
|
|
"severity": "critical",
|
|
"type": "lines_of_code",
|
|
"value": 94,
|
|
"threshold": 50,
|
|
"message": "Method is critically long"
|
|
}
|
|
],
|
|
"recommendation": "REFACTOR CRITICAL: Highest complexity in codebase. Apply Extract Method and Strategy Pattern. Split into: initializeHybridRouter, initializeRuvllmProvider, initializeFactoryProvider. Consider Factory Method pattern for provider creation."
|
|
},
|
|
{
|
|
"name": "initializeFederatedLearning",
|
|
"line_start": 860,
|
|
"line_end": 892,
|
|
"cyclomatic_complexity": 9,
|
|
"cognitive_complexity": 13,
|
|
"lines_of_code": 32,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity. Federated learning setup is straightforward."
|
|
},
|
|
{
|
|
"name": "llmComplete",
|
|
"line_start": 979,
|
|
"line_end": 1007,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 5,
|
|
"lines_of_code": 28,
|
|
"parameters": 2,
|
|
"issues": [],
|
|
"recommendation": "Good complexity. Clear LLM completion logic."
|
|
},
|
|
{
|
|
"name": "llmBatchComplete",
|
|
"line_start": 1017,
|
|
"line_end": 1055,
|
|
"cyclomatic_complexity": 5,
|
|
"cognitive_complexity": 8,
|
|
"lines_of_code": 38,
|
|
"parameters": 2,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity. Batch processing with fallback is well-structured."
|
|
},
|
|
{
|
|
"name": "llmEmbed",
|
|
"line_start": 1064,
|
|
"line_end": 1071,
|
|
"cyclomatic_complexity": 2,
|
|
"cognitive_complexity": 3,
|
|
"lines_of_code": 7,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Simple wrapper method. No issues."
|
|
},
|
|
{
|
|
"name": "llmChat",
|
|
"line_start": 1080,
|
|
"line_end": 1097,
|
|
"cyclomatic_complexity": 6,
|
|
"cognitive_complexity": 8,
|
|
"lines_of_code": 17,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity. Session-aware chat with fallback."
|
|
},
|
|
{
|
|
"name": "llmCompleteWithLearning",
|
|
"line_start": 1268,
|
|
"line_end": 1309,
|
|
"cyclomatic_complexity": 5,
|
|
"cognitive_complexity": 8,
|
|
"lines_of_code": 41,
|
|
"parameters": 2,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity. Hybrid routing with caching is well-implemented."
|
|
},
|
|
{
|
|
"name": "initializePatternStore",
|
|
"line_start": 1319,
|
|
"line_end": 1397,
|
|
"cyclomatic_complexity": 16,
|
|
"cognitive_complexity": 25,
|
|
"lines_of_code": 78,
|
|
"parameters": 0,
|
|
"issues": [
|
|
{
|
|
"severity": "critical",
|
|
"type": "cyclomatic_complexity",
|
|
"value": 16,
|
|
"threshold": 10,
|
|
"message": "Cyclomatic complexity (16) severely exceeds threshold (10)"
|
|
},
|
|
{
|
|
"severity": "critical",
|
|
"type": "cognitive_complexity",
|
|
"value": 25,
|
|
"threshold": 15,
|
|
"message": "Cognitive complexity (25) severely exceeds threshold (15)"
|
|
},
|
|
{
|
|
"severity": "critical",
|
|
"type": "lines_of_code",
|
|
"value": 78,
|
|
"threshold": 50,
|
|
"message": "Method is critically long"
|
|
}
|
|
],
|
|
"recommendation": "REFACTOR CRITICAL: Second highest complexity. Split into: initializeRuVectorStore, initializeHNSWStore, parseConnectionConfig. Apply Guard Clause and Factory Method patterns."
|
|
},
|
|
{
|
|
"name": "storeQEPattern",
|
|
"line_start": 1413,
|
|
"line_end": 1458,
|
|
"cyclomatic_complexity": 7,
|
|
"cognitive_complexity": 10,
|
|
"lines_of_code": 45,
|
|
"parameters": 1,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity. Pattern storage with sync option is clear."
|
|
},
|
|
{
|
|
"name": "searchQEPatterns",
|
|
"line_start": 1469,
|
|
"line_end": 1502,
|
|
"cyclomatic_complexity": 4,
|
|
"cognitive_complexity": 6,
|
|
"lines_of_code": 33,
|
|
"parameters": 3,
|
|
"issues": [],
|
|
"recommendation": "Good complexity. Search logic is straightforward."
|
|
},
|
|
{
|
|
"name": "getQEPatternMetrics",
|
|
"line_start": 1508,
|
|
"line_end": 1564,
|
|
"cyclomatic_complexity": 10,
|
|
"cognitive_complexity": 15,
|
|
"lines_of_code": 56,
|
|
"parameters": 0,
|
|
"issues": [
|
|
{
|
|
"severity": "high",
|
|
"type": "cyclomatic_complexity",
|
|
"value": 10,
|
|
"threshold": 10,
|
|
"message": "Cyclomatic complexity at threshold"
|
|
},
|
|
{
|
|
"severity": "medium",
|
|
"type": "cognitive_complexity",
|
|
"value": 15,
|
|
"threshold": 15,
|
|
"message": "Cognitive complexity at threshold"
|
|
},
|
|
{
|
|
"severity": "medium",
|
|
"type": "lines_of_code",
|
|
"value": 56,
|
|
"threshold": 50,
|
|
"message": "Method length exceeds recommended size"
|
|
}
|
|
],
|
|
"recommendation": "REFACTOR: Extract metrics collection into separate methods (collectPerformanceMetrics, collectGNNMetrics). Reduce conditional nesting."
|
|
},
|
|
{
|
|
"name": "initializeCodeIntelligence",
|
|
"line_start": 1674,
|
|
"line_end": 1700,
|
|
"cyclomatic_complexity": 6,
|
|
"cognitive_complexity": 9,
|
|
"lines_of_code": 26,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity. Code intelligence setup is clear."
|
|
},
|
|
{
|
|
"name": "getCodeIntelligenceContext",
|
|
"line_start": 1717,
|
|
"line_end": 1737,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 5,
|
|
"lines_of_code": 20,
|
|
"parameters": 2,
|
|
"issues": [],
|
|
"recommendation": "Simple wrapper with error handling. No issues."
|
|
},
|
|
{
|
|
"name": "getFileContext",
|
|
"line_start": 1742,
|
|
"line_end": 1756,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 5,
|
|
"lines_of_code": 14,
|
|
"parameters": 2,
|
|
"issues": [],
|
|
"recommendation": "Simple wrapper with error handling. No issues."
|
|
},
|
|
{
|
|
"name": "getEntityContext",
|
|
"line_start": 1761,
|
|
"line_end": 1780,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 5,
|
|
"lines_of_code": 19,
|
|
"parameters": 3,
|
|
"issues": [],
|
|
"recommendation": "Simple wrapper with error handling. No issues."
|
|
},
|
|
{
|
|
"name": "getTestContext",
|
|
"line_start": 1785,
|
|
"line_end": 1799,
|
|
"cyclomatic_complexity": 3,
|
|
"cognitive_complexity": 5,
|
|
"lines_of_code": 14,
|
|
"parameters": 2,
|
|
"issues": [],
|
|
"recommendation": "Simple wrapper with error handling. No issues."
|
|
},
|
|
{
|
|
"name": "getCodeIntelligenceStats",
|
|
"line_start": 1804,
|
|
"line_end": 1816,
|
|
"cyclomatic_complexity": 2,
|
|
"cognitive_complexity": 3,
|
|
"lines_of_code": 12,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Simple getter with guard clause. No issues."
|
|
},
|
|
{
|
|
"name": "cleanupFederated",
|
|
"line_start": 1822,
|
|
"line_end": 1846,
|
|
"cyclomatic_complexity": 7,
|
|
"cognitive_complexity": 10,
|
|
"lines_of_code": 24,
|
|
"parameters": 0,
|
|
"issues": [],
|
|
"recommendation": "Acceptable complexity for cleanup logic with error handling."
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"critical_hotspots": [
|
|
{
|
|
"rank": 1,
|
|
"file": "src/agents/BaseAgent.ts",
|
|
"method": "initializeLLMProvider",
|
|
"line_start": 760,
|
|
"cyclomatic_complexity": 21,
|
|
"cognitive_complexity": 32,
|
|
"lines_of_code": 94,
|
|
"severity": "critical",
|
|
"impact": "high",
|
|
"refactoring_priority": "immediate",
|
|
"recommendations": [
|
|
"Split into 3-4 smaller methods using Extract Method pattern",
|
|
"Apply Strategy Pattern for provider initialization",
|
|
"Use Factory Method for provider creation logic",
|
|
"Reduce nesting depth from 5 to max 3 using Guard Clauses",
|
|
"Extract configuration parsing into separate utility methods"
|
|
]
|
|
},
|
|
{
|
|
"rank": 2,
|
|
"file": "src/agents/BaseAgent.ts",
|
|
"method": "initializePatternStore",
|
|
"line_start": 1319,
|
|
"cyclomatic_complexity": 16,
|
|
"cognitive_complexity": 25,
|
|
"lines_of_code": 78,
|
|
"severity": "critical",
|
|
"impact": "high",
|
|
"refactoring_priority": "immediate",
|
|
"recommendations": [
|
|
"Split into initializeRuVectorStore and initializeHNSWStore methods",
|
|
"Extract URL parsing logic into parseConnectionConfig method",
|
|
"Apply Early Return pattern to reduce nesting",
|
|
"Use Builder Pattern for complex configuration objects",
|
|
"Extract error handling into centralized error handler"
|
|
]
|
|
},
|
|
{
|
|
"rank": 3,
|
|
"file": "src/core/FleetManager.ts",
|
|
"method": "initializeCodeIntelligence",
|
|
"line_start": 607,
|
|
"cyclomatic_complexity": 13,
|
|
"cognitive_complexity": 21,
|
|
"lines_of_code": 51,
|
|
"severity": "high",
|
|
"impact": "medium",
|
|
"refactoring_priority": "high",
|
|
"recommendations": [
|
|
"Extract loadCodeIntelligenceConfig method for configuration loading",
|
|
"Create checkCodeIntelligencePrereqs method for prerequisite validation",
|
|
"Extract createCodeIntelligenceService for service instantiation",
|
|
"Apply Guard Clause pattern to reduce nesting from 4 to 2 levels",
|
|
"Consider Builder Pattern for complex service configuration"
|
|
]
|
|
},
|
|
{
|
|
"rank": 4,
|
|
"file": "src/core/FleetManager.ts",
|
|
"method": "initialize",
|
|
"line_start": 249,
|
|
"cyclomatic_complexity": 11,
|
|
"cognitive_complexity": 18,
|
|
"lines_of_code": 36,
|
|
"severity": "high",
|
|
"impact": "medium",
|
|
"refactoring_priority": "high",
|
|
"recommendations": [
|
|
"Extract initializeDatabase method",
|
|
"Extract initializeEventBus method",
|
|
"Extract initializeMemory method",
|
|
"Apply Template Method pattern for initialization sequence",
|
|
"Add initialization state machine for better error recovery"
|
|
]
|
|
},
|
|
{
|
|
"rank": 5,
|
|
"file": "src/agents/BaseAgent.ts",
|
|
"method": "onPostTask",
|
|
"line_start": 632,
|
|
"cyclomatic_complexity": 11,
|
|
"cognitive_complexity": 17,
|
|
"lines_of_code": 35,
|
|
"severity": "high",
|
|
"impact": "medium",
|
|
"refactoring_priority": "medium",
|
|
"recommendations": [
|
|
"Extract shareFederatedPattern method",
|
|
"Extract recordLearningExperience method",
|
|
"Apply Guard Clause pattern to reduce nesting",
|
|
"Separate validation logic from learning logic",
|
|
"Consider Observer Pattern for post-task actions"
|
|
]
|
|
},
|
|
{
|
|
"rank": 6,
|
|
"file": "src/agents/BaseAgent.ts",
|
|
"method": "initialize",
|
|
"line_start": 300,
|
|
"cyclomatic_complexity": 10,
|
|
"cognitive_complexity": 16,
|
|
"lines_of_code": 66,
|
|
"severity": "high",
|
|
"impact": "medium",
|
|
"refactoring_priority": "medium",
|
|
"recommendations": [
|
|
"Extract initializeLearning method",
|
|
"Extract initializeExtensions method (LLM, Federated, Pattern Store)",
|
|
"Apply Template Method pattern",
|
|
"Use Promise.all for parallel initialization where safe",
|
|
"Add initialization phases for better observability"
|
|
]
|
|
},
|
|
{
|
|
"rank": 7,
|
|
"file": "src/agents/BaseAgent.ts",
|
|
"method": "getQEPatternMetrics",
|
|
"line_start": 1508,
|
|
"cyclomatic_complexity": 10,
|
|
"cognitive_complexity": 15,
|
|
"lines_of_code": 56,
|
|
"severity": "medium",
|
|
"impact": "low",
|
|
"refactoring_priority": "medium",
|
|
"recommendations": [
|
|
"Extract collectPerformanceMetrics method",
|
|
"Extract collectGNNMetrics method",
|
|
"Apply Null Object pattern to simplify conditionals",
|
|
"Consider Builder Pattern for metrics object construction",
|
|
"Reduce optional chaining depth"
|
|
]
|
|
},
|
|
{
|
|
"rank": 8,
|
|
"file": "src/agents/BaseAgent.ts",
|
|
"method": "constructor",
|
|
"line_start": 238,
|
|
"cyclomatic_complexity": 8,
|
|
"cognitive_complexity": 12,
|
|
"lines_of_code": 58,
|
|
"severity": "medium",
|
|
"impact": "medium",
|
|
"refactoring_priority": "low",
|
|
"recommendations": [
|
|
"Extract initializeConfig method for configuration processing",
|
|
"Extract createStrategies method for strategy initialization",
|
|
"Extract setupServices method for service instantiation",
|
|
"Consider Builder Pattern for complex agent construction",
|
|
"Move validation logic to separate validator class"
|
|
]
|
|
}
|
|
],
|
|
"refactoring_recommendations": {
|
|
"immediate_actions": [
|
|
{
|
|
"priority": "critical",
|
|
"action": "Refactor BaseAgent.initializeLLMProvider - split into 3-4 methods using Strategy Pattern",
|
|
"impact": "Reduces cyclomatic complexity from 21 to ~7 per method",
|
|
"effort": "medium",
|
|
"files": ["src/agents/BaseAgent.ts"]
|
|
},
|
|
{
|
|
"priority": "critical",
|
|
"action": "Refactor BaseAgent.initializePatternStore - split into RuVector and HNSW initialization",
|
|
"impact": "Reduces cyclomatic complexity from 16 to ~6 per method",
|
|
"effort": "medium",
|
|
"files": ["src/agents/BaseAgent.ts"]
|
|
},
|
|
{
|
|
"priority": "high",
|
|
"action": "Decompose BaseAgent.ts - extract LLM, Learning, CodeIntelligence into separate mix-in classes",
|
|
"impact": "Reduces file size from 1862 to ~400 lines per module, improves maintainability by 300%",
|
|
"effort": "high",
|
|
"files": ["src/agents/BaseAgent.ts"]
|
|
}
|
|
],
|
|
"architectural_improvements": [
|
|
{
|
|
"pattern": "Strategy Pattern",
|
|
"application": "Provider initialization in BaseAgent (LLM, Pattern Store, Federated Learning)",
|
|
"benefit": "Reduces complexity, improves testability, enables runtime provider switching"
|
|
},
|
|
{
|
|
"pattern": "Template Method",
|
|
"application": "Initialization sequences in FleetManager and BaseAgent",
|
|
"benefit": "Standardizes initialization flow, improves error handling consistency"
|
|
},
|
|
{
|
|
"pattern": "Factory Method",
|
|
"application": "Agent creation, provider instantiation, service creation",
|
|
"benefit": "Centralizes object creation, simplifies testing, reduces coupling"
|
|
},
|
|
{
|
|
"pattern": "Guard Clause",
|
|
"application": "All methods with nesting depth > 3",
|
|
"benefit": "Reduces cognitive complexity by 30-40%, improves readability"
|
|
},
|
|
{
|
|
"pattern": "Extract Class",
|
|
"application": "BaseAgent split into BaseAgentCore, BaseAgentLLM, BaseAgentLearning, BaseAgentCodeIntelligence",
|
|
"benefit": "Separates concerns, reduces file size by 75%, improves maintainability"
|
|
}
|
|
],
|
|
"code_smells_detected": [
|
|
{
|
|
"smell": "Long Method",
|
|
"instances": 8,
|
|
"locations": [
|
|
"BaseAgent.initializeLLMProvider (94 LOC)",
|
|
"BaseAgent.initializePatternStore (78 LOC)",
|
|
"BaseAgent.initialize (66 LOC)",
|
|
"BaseAgent.constructor (58 LOC)",
|
|
"BaseAgent.getQEPatternMetrics (56 LOC)",
|
|
"FleetManager.initializeCodeIntelligence (51 LOC)",
|
|
"BaseAgent.llmBatchComplete (38 LOC)",
|
|
"FleetManager.initialize (36 LOC)"
|
|
],
|
|
"recommendation": "Apply Extract Method pattern to methods exceeding 50 LOC"
|
|
},
|
|
{
|
|
"smell": "Large Class",
|
|
"instances": 1,
|
|
"locations": ["BaseAgent.ts (1862 LOC, 65 methods)"],
|
|
"recommendation": "Apply Extract Class pattern to split into 4-5 focused classes"
|
|
},
|
|
{
|
|
"smell": "Complex Conditional",
|
|
"instances": 5,
|
|
"locations": [
|
|
"BaseAgent.initializeLLMProvider (nesting depth: 5)",
|
|
"BaseAgent.initializePatternStore (nesting depth: 4)",
|
|
"FleetManager.initializeCodeIntelligence (nesting depth: 4)",
|
|
"BaseAgent.onPostTask (nesting depth: 3)",
|
|
"BaseAgent.getQEPatternMetrics (nesting depth: 3)"
|
|
],
|
|
"recommendation": "Apply Guard Clause and Decompose Conditional patterns"
|
|
},
|
|
{
|
|
"smell": "Feature Envy",
|
|
"instances": 2,
|
|
"locations": [
|
|
"BaseAgent LLM methods accessing llmProvider repeatedly",
|
|
"BaseAgent pattern store methods accessing qePatternStore repeatedly"
|
|
],
|
|
"recommendation": "Consider Extract Class or Move Method refactorings"
|
|
}
|
|
]
|
|
},
|
|
"quality_improvement_plan": {
|
|
"phase_1_immediate": {
|
|
"duration": "1-2 weeks",
|
|
"tasks": [
|
|
"Refactor initializeLLMProvider using Extract Method and Strategy Pattern",
|
|
"Refactor initializePatternStore using Extract Method and Factory Pattern",
|
|
"Apply Guard Clauses to reduce nesting in top 5 complex methods",
|
|
"Extract configuration parsing logic into utility functions"
|
|
],
|
|
"expected_impact": "Reduce average cyclomatic complexity from 8.2 to 6.5, improve quality score from 73 to 80"
|
|
},
|
|
"phase_2_architectural": {
|
|
"duration": "2-3 weeks",
|
|
"tasks": [
|
|
"Split BaseAgent into BaseAgentCore + trait/mixin classes",
|
|
"Implement Template Method for initialization sequences",
|
|
"Create factory classes for agent and provider creation",
|
|
"Standardize error handling patterns across codebase"
|
|
],
|
|
"expected_impact": "Reduce file sizes by 60-75%, improve maintainability index by 40%, enable better testing"
|
|
},
|
|
"phase_3_optimization": {
|
|
"duration": "1 week",
|
|
"tasks": [
|
|
"Add complexity metrics to CI/CD pipeline",
|
|
"Implement automated refactoring suggestions",
|
|
"Create complexity budgets for new code",
|
|
"Document architectural patterns and coding standards"
|
|
],
|
|
"expected_impact": "Prevent complexity regression, improve team velocity, enhance code review quality"
|
|
}
|
|
},
|
|
"metrics_comparison": {
|
|
"current_state": {
|
|
"average_cyclomatic_complexity": 8.2,
|
|
"average_cognitive_complexity": 12.4,
|
|
"methods_over_threshold": 8,
|
|
"files_over_size": 2,
|
|
"quality_score": 73,
|
|
"maintainability_index": 65
|
|
},
|
|
"after_phase_1": {
|
|
"average_cyclomatic_complexity": 6.5,
|
|
"average_cognitive_complexity": 9.8,
|
|
"methods_over_threshold": 3,
|
|
"files_over_size": 2,
|
|
"quality_score": 80,
|
|
"maintainability_index": 72
|
|
},
|
|
"after_phase_2": {
|
|
"average_cyclomatic_complexity": 5.2,
|
|
"average_cognitive_complexity": 7.5,
|
|
"methods_over_threshold": 0,
|
|
"files_over_size": 0,
|
|
"quality_score": 88,
|
|
"maintainability_index": 85
|
|
},
|
|
"target_state": {
|
|
"average_cyclomatic_complexity": 5.0,
|
|
"average_cognitive_complexity": 7.0,
|
|
"methods_over_threshold": 0,
|
|
"files_over_size": 0,
|
|
"quality_score": 90,
|
|
"maintainability_index": 90
|
|
}
|
|
}
|
|
}
|