block-open-source / goose-plugins

Apache License 2.0
8 stars 10 forks source link

feat: code complexity analyzer toolkit #70

Open Johnnyevans32 opened 16 hours ago

Johnnyevans32 commented 16 hours ago

Code Complexity Analyzer Toolkit for Goose

Resolves #62

Overview

The Code Complexity Analyzer Toolkit automates the analysis of Python codebases, evaluating key complexity metrics to assess code quality and maintainability.

Features

Usage

  1. Add the toolkit to your profiles.yaml:
my-profile:
  provider: openai
  processor: gpt-4o
  accelerator: gpt-4o-mini
  moderator: passive
  toolkits:
    - developer
    - complexity_analyzer
  1. Run Goose with the profile:
goose session start --profile my-profile
  1. Use the toolkit:
analyze complexity "<directory_path>"

Output

The toolkit returns a dictionary with the following keys:

Example:

{
    "avg_cyclomatic_complexity": 5.2,
    "avg_halstead_complexity": 140.1,
    "avg_maintainability_index": 68.5,
    "errors": []
}

Testing

Run tests using unittest:

 uv run pytest tests -m "not integration" 

🛠️ Adding to goose-plugins

pyproject.toml

[project.entry-points."goose.toolkit"]
complexity_analyzer = "goose.toolkit.complexity_analyzer:CodeComplexityToolkit"