|
| None | complexity (click.Context ctx, tuple[Path,...] paths, Path|None coverage_data, bool json_mode, int|None top, int|None max_cc, float|None max_crap, bool changed, Path|None baseline_path, Path|None write_baseline_path) |
| None | _check_baseline_options (Thresholds thresholds, Path|None baseline_path, Path|None write_baseline_path) |
| Verdict | _build_gate_verdict (AnalysisReport report, Thresholds thresholds, Path root, Path|None baseline_path, Path|None write_baseline_path) |
| tuple[Path, click.ClickException|None] | _resolve_root (click.Context ctx) |
| Thresholds | _resolve_gate_thresholds (Path root, int|None max_cc, float|None max_crap, Path|None coverage_data) |
| tuple[Path,...] | _changed_targets (Path root, tuple[Path,...] paths, bool json_mode) |
| tuple[Path,...] | _resolve_targets (tuple[Path,...] paths, Path root, click.ClickException|None root_error) |
| None | _emit_report (AnalysisReport report, bool json_mode, int|None top, Verdict|None verdict=None) |
Purpose
-------
Expose the on-demand complexity instrument through Click.
Responsibilities
----------------
- Parse paths, coverage data, JSON mode, and human truncation options.
- Parse the plan-226 gate options: thresholds and their exit-code contract.
- Scope a call to the git-modified file set under ``--changed``.
- Record and compare the don't-get-worse baseline.
- Default analysis to the discovered Option C project root.
- Convert dependency and path failures into clear CLI errors.
Diagnostics
-----------
Domain: OCT-COMPLEXITY
Levels:
L2 - command lifecycle
L3 - option and output details
L4 - deep tracing
Contracts
---------
- ``--top`` affects human output only.
- With no threshold active the command is informational and exits 0, byte for
byte as it did before plan 226.
- With a threshold active the command exits 0 when clean, 2 when any function
breaches, and 3 when the call cannot be honestly evaluated.
- Machine-readable stdout contains JSON only.
Dependencies
------------
- click (CLI adapter)
- oct.complexity.baseline (ratchet document I/O)
- oct.complexity.service (analysis and rendering)
- oct.complexity.thresholds (verdict and exit-code contract)
- oct.core.octrc (optional complexity configuration section)
- oct.core.project_root (default target discovery)
- oct.complexity.coverage (missing coverage.py error, raised as a CLI error)
- oct.core.git (lazy; git-modified Python files for --changed)
| tuple[Path, ...] oct.complexity.command._changed_targets |
( |
Path | root, |
|
|
tuple[Path, ...] | paths, |
|
|
bool | json_mode ) |
|
protected |
Return the git-modified Python files, scoped exactly as the linter is.
Discovery is :func:`oct.core.git.git_changed_files`, the same helper
``oct lint --changed`` uses, and the result passes through the service's
own exclusion set so ``--changed`` narrows the measured universe without
widening it. A git failure is refused rather than collapsed to an empty
list: an empty measurement reads as a pass, and a gate that passes
because git broke is worse than one that stops.
Definition at line 278 of file command.py.