[tests] Restore refactoring_opportunity_finder API expected by test_refactoring_opportunity_finder.py #210

Closed
opened 2026-04-21 07:21:42 +00:00 by Rockachopa · 2 comments
Owner

Problem

python3 -m pytest -q fails during collection because scripts/test_refactoring_opportunity_finder.py imports symbols that scripts/refactoring_opportunity_finder.py does not define.

Current failure:

E   AttributeError: module 'rof' has no attribute 'compute_file_complexity'

The test expects at least:

  • compute_file_complexity
  • calculate_refactoring_score
  • FileMetrics

But the script currently only exposes a sample generate_proposals() stub.

Reproduction

cd /tmp/compounding-intelligence-676
python3 -m pytest scripts/test_refactoring_opportunity_finder.py -q

Impact

  • full project test collection is broken
  • the refactoring opportunity pipeline contract is not implemented
  • current repo docs overstate how much of the pipeline is operational

Acceptance Criteria

  • scripts/refactoring_opportunity_finder.py defines the API expected by scripts/test_refactoring_opportunity_finder.py
  • python3 -m pytest scripts/test_refactoring_opportunity_finder.py -q passes
  • the implementation does real complexity / scoring work rather than a placeholder stub
## Problem `python3 -m pytest -q` fails during collection because `scripts/test_refactoring_opportunity_finder.py` imports symbols that `scripts/refactoring_opportunity_finder.py` does not define. Current failure: ``` E AttributeError: module 'rof' has no attribute 'compute_file_complexity' ``` The test expects at least: - `compute_file_complexity` - `calculate_refactoring_score` - `FileMetrics` But the script currently only exposes a sample `generate_proposals()` stub. ## Reproduction ```bash cd /tmp/compounding-intelligence-676 python3 -m pytest scripts/test_refactoring_opportunity_finder.py -q ``` ## Impact - full project test collection is broken - the refactoring opportunity pipeline contract is not implemented - current repo docs overstate how much of the pipeline is operational ## Acceptance Criteria - [ ] `scripts/refactoring_opportunity_finder.py` defines the API expected by `scripts/test_refactoring_opportunity_finder.py` - [ ] `python3 -m pytest scripts/test_refactoring_opportunity_finder.py -q` passes - [ ] the implementation does real complexity / scoring work rather than a placeholder stub
Author
Owner

Implemented in PR #221.

  • compute_file_complexity() — AST-based cyclomatic complexity
  • calculate_refactoring_score() — weighted scoring (complexity, size, churn, coverage)
  • FileMetrics dataclass with all required fields
  • All 10 tests pass
Implemented in PR #221. - `compute_file_complexity()` — AST-based cyclomatic complexity - `calculate_refactoring_score()` — weighted scoring (complexity, size, churn, coverage) - `FileMetrics` dataclass with all required fields - All 10 tests pass
Author
Owner

PR #223 created: #223

Implemented the full API expected by tests:

  1. compute_file_complexity(filepath) — AST-based cyclomatic complexity

    • Returns (avg, max_c, functions, classes, lines)
    • Handles if/while/for/except/assert/comprehension/BoolOp
    • Returns zeros for syntax errors
  2. FileMetrics dataclass — All 10 fields: path, lines, complexity, max_complexity, functions, classes, churn_30d, churn_90d, test_coverage, refactoring_score

  3. calculate_refactoring_score(metrics) — Weighted 0-100 scoring

    • Complexity (0-30), Size (0-20), Churn (0-25), Coverage (0-15), Density (0-10)
  4. generate_proposals(root, min_score) — Scan and rank files

All 10 tests should pass.

PR #223 created: https://forge.alexanderwhitestone.com/Timmy_Foundation/compounding-intelligence/pulls/223 Implemented the full API expected by tests: 1. **`compute_file_complexity(filepath)`** — AST-based cyclomatic complexity - Returns `(avg, max_c, functions, classes, lines)` - Handles if/while/for/except/assert/comprehension/BoolOp - Returns zeros for syntax errors 2. **`FileMetrics` dataclass** — All 10 fields: path, lines, complexity, max_complexity, functions, classes, churn_30d, churn_90d, test_coverage, refactoring_score 3. **`calculate_refactoring_score(metrics)`** — Weighted 0-100 scoring - Complexity (0-30), Size (0-20), Churn (0-25), Coverage (0-15), Density (0-10) 4. **`generate_proposals(root, min_score)`** — Scan and rank files All 10 tests should pass.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Timmy_Foundation/compounding-intelligence#210