Skip to content

Reduce complexity of plot() and validate_input() (CC 32 / 31) #44

Description

@tschm

Subcategory: Code complexity
Score: 5 → 8 (target)

Two functions rank E on cyclomatic complexity (radon cc), far past the C threshold (CC ≥ 11):

  • src/pycharting/api/interface.py:35plotCC 32
  • src/pycharting/data/ingestion.py:29validate_inputCC 31

plot mixes list→array conversion, server acquire/reuse, URL construction, browser launch, a blocking loop, and error handling in one body. validate_input bundles index handling, per-series conversion, OHLC-mode selection, and high/low validation.

Suggested fix: extract helpers — e.g. _coerce_inputs, _acquire_server, _build_chart_url, _run_blocking for plot; split OHLC-mode selection and high/low bounds checks out of validate_input.

Done when: no block in src/ exceeds CC 10 — uvx radon cc src -s reports no C-or-worse block.

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