Index
provide.testkit.quality.complexity
¶
Complexity analysis integration for provide-testkit.
Provides code complexity analysis using radon and other complexity tools. Integrates with the quality framework for comprehensive complexity analysis.
Features: - Cyclomatic complexity analysis with radon - Maintainability index calculation - Raw metrics (lines of code, etc.) - Integration with quality gates - Grade-based reporting (A, B, C, D, F)
Usage
Basic complexity analysis¶
def test_with_complexity(complexity_analyzer): result = complexity_analyzer.analyze(path) assert result.passed
Complexity with quality gates¶
runner = QualityRunner() results = runner.run_with_gates(path, {"complexity": "B"})
Classes¶
ComplexityAnalyzer
¶
Code complexity analyzer using radon and other tools.
Provides high-level interface for complexity analysis with automatic artifact management and integration with the quality framework.
Initialize complexity analyzer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any] | None
|
Complexity analyzer configuration options |
None
|
Source code in provide/testkit/quality/complexity/analyzer.py
Functions¶
analyze
¶
Run complexity analysis on the given path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to analyze |
required |
**kwargs
|
Any
|
Additional options including artifact_dir |
{}
|
Returns:
| Type | Description |
|---|---|
QualityResult
|
QualityResult with complexity analysis data |
Source code in provide/testkit/quality/complexity/analyzer.py
report
¶
Generate report from QualityResult (implements QualityTool protocol).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
QualityResult
|
Complexity result |
required |
format
|
str
|
Report format |
'terminal'
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted report |
Source code in provide/testkit/quality/complexity/analyzer.py
ComplexityFixture
¶
Bases: BaseQualityFixture
Pytest fixture for complexity analysis integration.
Initialize complexity fixture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any] | None
|
Complexity analyzer configuration |
None
|
artifact_dir
|
Path | None
|
Directory for artifacts |
None
|
Source code in provide/testkit/quality/complexity/fixture.py
Functions¶
analyze
¶
Perform complexity analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to analyze |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Complexity analysis results |
Source code in provide/testkit/quality/complexity/fixture.py
generate_report
¶
Generate complexity report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str
|
Report format (terminal, json) |
'terminal'
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted report |
Source code in provide/testkit/quality/complexity/fixture.py
setup
¶
Setup complexity analysis.