Coverage for analyzers / python.py: 93%
14 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-08 15:04 -0800
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-08 15:04 -0800
1"""Python source file analyzer -- assembles all metrics."""
3from __future__ import annotations
5from analyzers.shared import create_analyzer_file_fn, create_analyzer_source_fn
6from parsers.python import parse, collect_functions, func_name
7from patterns.python import check_patterns
8from metrics.lloc.python import count_lloc
9from metrics.halstead.python import compute_halstead_py
10from metrics.npath.python import compute_npath_py
11from metrics.dtd.python import compute_dtd_py
12from metrics.cognitive.python import compute_cognitive_py
13from metrics.cyclomatic.python import compute_cyclomatic_py
14from metrics.duplication.config import PYTHON_CONFIG
16analyze_source = create_analyzer_source_fn(
17 parse_fn=parse,
18 collect_functions_fn=collect_functions,
19 func_name_fn=func_name,
20 compute_cognitive_fn=compute_cognitive_py,
21 compute_halstead_fn=compute_halstead_py,
22 compute_npath_fn=compute_npath_py,
23 compute_dtd_fn=compute_dtd_py,
24 compute_cyclomatic_fn=compute_cyclomatic_py,
25 count_lloc_fn=count_lloc,
26 dup_config=PYTHON_CONFIG,
27 check_patterns_fn=check_patterns,
28)
31def analyze_file(filepath, timing_manager=None):
32 """Analyze a Python file and return cognitive complexity scores."""
33 return create_analyzer_file_fn(analyze_source)(
34 filepath, timing_manager=timing_manager
35 )