Skip to content

Decompose plot() (CC 33) and validate_input() (CC 31) #71

Description

@tschm

Subcategory: Code complexity
Score: 5 → 10

Average complexity is healthy — A (3.26) across 53 blocks, and all 10 modules rank A on the maintainability index. Two outliers drag the score down, both ranked E (radon's second-worst grade):

  • src/pycharting/api/interface.py:75 plot — E (33), 13 parameters, ~37 branch points across a ~240-line body
  • src/pycharting/data/ingestion.py:27 validate_input — E (31), 8 parameters

Both are wide optional-kwarg normalizers: a long sequential run of if arg is None / isinstance coercion branches. Suggested decomposition — extract per-concern helpers (array coercion, OHLC fallback derivation, overlay validation, subplot-spec validation, trade validation), or accept a params dataclass / Pydantic model instead of 13 positional-or-keyword arguments.

Also worth trimming while in the area (rank B, not currently failing):

  • src/pycharting/core/lifecycle.py:99 _monitor_connection — B (9)
  • src/pycharting/core/lifecycle.py:190 stop_server — B (9)
  • src/pycharting/data/ingestion.py:328 DataManager.get_chunk — B (10)

done when

uvx radon cc src -a -s shows no block ranked worse than C (CC ≤ 10), with the 100% coverage gate still green.

Evidence

src/pycharting/api/interface.py
    F 75:0 plot - E (33)
src/pycharting/data/ingestion.py
    F 27:0 validate_input - E (31)
Average complexity: A (3.2641509433962264)

Surfaced by the Rhiza quality gates during the template bump to jebel-quant/rhiza@v1.2.2, which enabled the stricter ruff rule families (ANN, A, BLE, ARG) and TYPECHECKER=both. Gate status at time of filing: make fmt FAIL, make typecheck FAIL, make docs-coverage FAIL, test-layout FAIL; make deptry, make security, make test PASS (154 tests, 100% coverage).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions