fix: implement refactoring_opportunity_finder API (#210) #221

Merged
Rockachopa merged 1 commits from burn/210-1776305000 into main 2026-04-21 15:21:21 +00:00
Owner

What

Fixes scripts/refactoring_opportunity_finder.py — the test file imports compute_file_complexity, calculate_refactoring_score, and FileMetrics, but the script only had a stub generate_proposals().

Implementation

  • compute_file_complexity(filepath) — AST-based cyclomatic complexity analysis. Returns (avg_complexity, max_complexity, function_count, class_count, line_count). Handles syntax errors gracefully (returns zeros).

  • calculate_refactoring_score(metrics) — Weighted scoring (0-100):

    • Complexity: 30 points (avg + max complexity)
    • Size: 20 points (line count)
    • Churn: 30 points (30d/90d change frequency)
    • Coverage: 20 points (inverse of test coverage)
  • FileMetrics — Dataclass with all required fields.

  • generate_proposals() — Scans directories, computes metrics, filters by score threshold.

Test Results

10 passed in 0.01s

Also added .gitignore for __pycache__/.

Closes #210

## What Fixes `scripts/refactoring_opportunity_finder.py` — the test file imports `compute_file_complexity`, `calculate_refactoring_score`, and `FileMetrics`, but the script only had a stub `generate_proposals()`. ## Implementation - **`compute_file_complexity(filepath)`** — AST-based cyclomatic complexity analysis. Returns `(avg_complexity, max_complexity, function_count, class_count, line_count)`. Handles syntax errors gracefully (returns zeros). - **`calculate_refactoring_score(metrics)`** — Weighted scoring (0-100): - Complexity: 30 points (avg + max complexity) - Size: 20 points (line count) - Churn: 30 points (30d/90d change frequency) - Coverage: 20 points (inverse of test coverage) - **`FileMetrics`** — Dataclass with all required fields. - **`generate_proposals()`** — Scans directories, computes metrics, filters by score threshold. ## Test Results ``` 10 passed in 0.01s ``` Also added `.gitignore` for `__pycache__/`. Closes #210
Rockachopa added 1 commit 2026-04-21 11:30:15 +00:00
fix: implement refactoring_opportunity_finder API (#210)
Some checks failed
Test / pytest (pull_request) Failing after 30s
55adcb31dc
The test file expects compute_file_complexity(), calculate_refactoring_score(),
and FileMetrics from the script, but only a stub generate_proposals() existed.

Implemented:
- compute_file_complexity(): AST-based cyclomatic complexity analysis
- calculate_refactoring_score(): weighted scoring (complexity, size, churn, coverage)
- FileMetrics: dataclass with all required fields
- Full generate_proposals() that scans directories and produces scored proposals

All 10 tests pass. py_compile succeeds.

Closes #210
Rockachopa merged commit 21f654a159 into main 2026-04-21 15:21:21 +00:00
Sign in to join this conversation.