Skip to content

feat: Add unified full_analysis tool #47

@nnennandukwe

Description

@nnennandukwe

Summary

Add a full_analysis tool that runs all code quality checkers in a single invocation and provides a unified report. This is the primary entry point for comprehensive code analysis.

Parent Epic

Part of: #40 - Evolve into Python Code Quality MCP

Depends On

Behavior

Runs all available tools and aggregates results:

  1. Parse source once with Astroid
  2. Run each checker against the shared AST
  3. Aggregate issues into unified report
  4. Calculate overall code quality score

MCP Tool Interface

{
  "name": "full_analysis",
  "description": "Run all code quality checks and get a comprehensive report",
  "inputSchema": {
    "type": "object",
    "properties": {
      "file_path": {"type": "string"},
      "source_code": {"type": "string"},
      "checks": {
        "type": "array",
        "items": {
          "type": "string",
          "enum": ["performance", "pythonic", "security", "complexity", "dead_code", "type_coverage"]
        },
        "description": "Specific checks to run (default: all)"
      },
      "severity_threshold": {
        "type": "string",
        "enum": ["critical", "high", "medium", "low", "info"],
        "default": "info"
      }
    }
  }
}

Example Output

{
  "file": "src/processor.py",
  "quality_score": 72,
  "grade": "C",
  "summary": {
    "total_issues": 12,
    "critical": 1,
    "high": 2,
    "medium": 5,
    "low": 4,
    "by_tool": {
      "performance": 2,
      "pythonic": 4,
      "security": 1,
      "complexity": 3,
      "dead_code": 2,
      "type_coverage": 0
    }
  },
  "issues": [
    {
      "tool": "security",
      "category": "sql_injection",
      "severity": "critical",
      "message": "...",
      "line": 45
    },
    // ... all issues from all tools
  ],
  "metrics": {
    "complexity": {
      "average_cyclomatic": 8.5,
      "max_cyclomatic": 25
    },
    "type_coverage": {
      "overall_percent": 74.1
    }
  },
  "recommendations": [
    "Fix 1 critical security issue (SQL injection on line 45)",
    "Reduce complexity in 'process_data' function (cyclomatic: 25)",
    "Add type hints to 3 public functions"
  ]
}

Quality Score Calculation

Weighted scoring based on issue severity and count:

  • Critical: -20 points each
  • High: -10 points each
  • Medium: -5 points each
  • Low: -2 points each
  • Info: -1 point each

Starting from 100, minimum 0.

Grade mapping:

  • A: 90-100
  • B: 80-89
  • C: 70-79
  • D: 60-69
  • F: 0-59

Implementation

  1. Create src/workshop_mcp/tools/full_analysis/
  2. Implement tool orchestration (run all checkers)
  3. Share parsed AST across checkers (efficiency)
  4. Aggregate and deduplicate issues
  5. Calculate quality score and grade
  6. Generate prioritized recommendations
  7. Register tool in MCP server

Acceptance Criteria

  • Runs all available checkers
  • Single Astroid parse shared across tools
  • Aggregated issue report
  • Quality score and letter grade
  • Prioritized recommendations
  • Option to run subset of checks
  • Severity threshold filtering

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions