Skip to content

Code Quality Improvement Goals - April 2026 #953

@github-actions

Description

@github-actions

Monthly code quality tracking issue for April 2026. Based on automated analysis of the azlin Python codebase.


Overall Health Score: 78/100 (C+)

The codebase is in generally good shape, with excellent docstring coverage and low technical debt. The main areas for improvement are function length and the extreme complexity of doc_sync.py::main.


Module Quality Scorecard

Module Avg Complexity MI Score Grade Notes
src/azlin/__init__.py 1.0 100 A Perfect
src/azlin/rust_bridge.py 5.3 49.8 B- One long/complex function
scripts/audit_key_operations.py 5.0 62.2 B Good structure
scripts/doc_sync.py 38.0 62.7 D main() needs splitting
scripts/extract_help.py 3.1 43.4 C Long functions
scripts/generate_docs.py 2.5 49.4 C Very long functions
scripts/validate_documentation.py 5.6 42.8 C- Complex comparisons
scripts/cli_documentation/extractor.py 4.2 60.1 B- Some complexity
scripts/cli_documentation/generator.py 3.7 63.2 B- Acceptable
scripts/cli_documentation/sync_manager.py 3.1 67.4 B Good
scripts/cli_documentation/validator.py 2.1 73.7 B+ Good
scripts/cli_documentation/models.py 1.8 66.4 B Good
scripts/cli_documentation/hasher.py 1.9 69.9 B Good
scripts/cli_documentation/example_manager.py 2.2 67.7 B Good

Top Issues to Address

1. Critical: doc_sync.py::main — Complexity 38 (Grade E) 🔴

This single function has cyclomatic complexity of 38, which is nearly double the recommended maximum (20). It is also 165 lines long.

  • Split into logical sub-functions (e.g., _setup_paths(), _sync_commands(), _generate_reports())
  • Target: reduce to ≤5 functions each with complexity ≤8

Before:

def main() -> None:
    # 165 lines, 38 branches
    ...

After:

def main() -> None:
    paths = _setup_paths()
    commands = _discover_commands(paths)
    _sync_documentation(commands, paths)
    _report_results()

2. High: generate_docs.py — Extremely long functions 🟡

  • generate_first_vm(): 296 lines
  • generate_concepts(): 312 lines

These are generation functions that likely contain large blocks of static content. Consider:

  • Extract static content into template files or constants
  • Break into smaller generation steps with clear responsibilities

3. Medium: rust_bridge.py::_download_from_release — Complexity 15 🟡

  • 68 lines, C-rated complexity

  • Handles multiple platforms, architectures, and error paths

  • Extract platform-selection logic into a _select_asset() helper

  • Target: reduce to complexity ≤8


4. Medium: Deep nesting (113 lines at 5+ indent levels) 🟡

Across the scripts directory, 113 lines have 5+ levels of indentation. This indicates nested loops/conditionals that could be flattened.

  • Review extract_help.py and validate_documentation.py for guard-clause opportunities
  • Use early returns to reduce nesting depth

5. Low: Type annotation coverage at 81% 🟢

20% of functions (20 of 105) lack type annotations. The project uses Pyright strict mode on src/, but scripts are not covered.

  • Add type annotations to scripts directory functions
  • Consider enabling Pyright for scripts/ as well

Strengths to Maintain 🎉

  • Zero TODO/FIXME debt — clean codebase with no deferred tasks
  • Excellent docstring coverage: 91.4% (96/105 functions documented)
  • No functions with >10 parameters — clean API design
  • Average cyclomatic complexity: 4.26 (Grade A) — healthy overall
  • No circular imports detected
  • All maintainability scores rated A by radon

Metrics Snapshot (2026-04-06)

{
  "date": "2026-04-06",
  "overall_score": 78,
  "total_loc": 4122,
  "total_sloc": 2354,
  "total_functions": 105,
  "avg_complexity": 4.26,
  "max_complexity": 38,
  "max_complexity_function": "doc_sync.py::main",
  "docstring_coverage_pct": 91.4,
  "type_hint_coverage_pct": 81.0,
  "todo_count": 0,
  "long_functions_count": 14,
  "deeply_nested_lines": 113,
  "magic_numbers": "minimal"
}

Progress Tracking

  • Refactor doc_sync.py::main (complexity 38 → target ≤8 per sub-function)
  • Split generate_docs.py::generate_concepts (312 lines → target <50)
  • Split generate_docs.py::generate_first_vm (296 lines → target <50)
  • Reduce rust_bridge.py::_download_from_release complexity (15 → ≤8)
  • Flatten deeply nested code blocks in scripts
  • Improve type annotation coverage in scripts/ (81% → 90%)

Generated by Code Quality Tracker bot on 2026-04-06

Generated by Code Quality Tracker

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions