oct
Loading...
Searching...
No Matches
oct.complexity.engine Namespace Reference

Classes

class  FunctionComplexity
class  _DecisionCounter
class  _FunctionCollector

Functions

bool _is_wildcard_pattern (ast.pattern pattern)
list[FunctionComplexity] analyze_source (str source, str filename="<unknown>")
list[FunctionComplexity] analyze_file (str|Path path)

Detailed Description

Purpose
-------
Compute stable per-function cyclomatic complexity from Python syntax trees.

Responsibilities
----------------
- Apply Plan 214's pinned decision-counting convention.
- Score nested functions and lambdas independently from their parents.
- Preserve file, qualname, and source-span coordinates for every result.

Diagnostics
-----------
Domain: OCT-COMPLEXITY
Levels:
    L2 - lifecycle
    L3 - measurement details
    L4 - deep tracing

Contracts
---------
- Every function starts with complexity one.
- The engine imports only Python standard-library modules.
- Syntax errors propagate so orchestration can report them honestly.

Dependencies
------------
- ast (Python syntax tree)
- tokenize (declared source encodings)

Function Documentation

◆ _is_wildcard_pattern()

bool oct.complexity.engine._is_wildcard_pattern ( ast.pattern pattern)
protected
Return whether a match pattern is the bare wildcard underscore.

Definition at line 140 of file engine.py.

Here is the caller graph for this function:

◆ analyze_file()

list[FunctionComplexity] oct.complexity.engine.analyze_file ( str | Path path)
Analyze one Python file using its declared source encoding.

Definition at line 228 of file engine.py.

Here is the call graph for this function:

◆ analyze_source()

list[FunctionComplexity] oct.complexity.engine.analyze_source ( str source,
str filename = "<unknown>" )
Analyze Python source text and return records in source order.

``SyntaxError`` is intentionally allowed to reach the caller. Directory
orchestration records that error explicitly instead of silently omitting
the file.

Definition at line 212 of file engine.py.

Here is the caller graph for this function: