ai-refactor-cli 0.2.0

Rule-based legacy code refactoring CLI (TypeScript any / Python typing / Django FBV→CBV). Complement to general AI coding agents.
Documentation
//! Benchmarks for ai-refactor-cli v0.2.0.
//!
//! Measures scan time for a synthetic 10 000-line Python file.
//! Run with: `cargo bench`

use criterion::{criterion_group, criterion_main, Criterion};
use std::io::Write;

fn make_large_python_file() -> String {
    let mut out = String::with_capacity(500_000);
    // Alternate typed and untyped functions so both paths are exercised.
    for i in 0..500 {
        out.push_str(&format!("def untyped_{i}(x, y):\n    return x + y\n\n"));
        out.push_str(&format!(
            "def typed_{i}(x: int, y: int) -> int:\n    return x + y\n\n"
        ));
        if i % 20 == 0 {
            out.push_str(&format!("def view_{i}(request):\n    return None\n\n"));
        }
    }
    out
}

fn bench_scan_10k_lines(c: &mut Criterion) {
    let python_src = make_large_python_file();
    assert!(
        python_src.lines().count() >= 9_000,
        "generated file too small: {} lines",
        python_src.lines().count()
    );

    // Write to a temp file so scan_path can read it.
    let dir = tempfile::tempdir().unwrap();
    let py_path = dir.path().join("large.py");
    {
        let mut f = std::fs::File::create(&py_path).unwrap();
        f.write_all(python_src.as_bytes()).unwrap();
    }
    let path_str = py_path.to_str().unwrap().to_string();

    c.bench_function("scan_10k_py_python-missing-typing", |b| {
        b.iter(|| {
            let findings =
                ai_refactor_cli::scanner::scan_path(&path_str, Some("python-missing-typing"))
                    .unwrap();
            criterion::black_box(findings);
        });
    });

    c.bench_function("scan_10k_py_django-fbv", |b| {
        b.iter(|| {
            let findings =
                ai_refactor_cli::scanner::scan_path(&path_str, Some("django-fbv")).unwrap();
            criterion::black_box(findings);
        });
    });
}

criterion_group!(benches, bench_scan_10k_lines);
criterion_main!(benches);