archunitpython 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- archunitpython/__init__.py +45 -0
- archunitpython/common/__init__.py +18 -0
- archunitpython/common/assertion/__init__.py +3 -0
- archunitpython/common/assertion/violation.py +21 -0
- archunitpython/common/error/__init__.py +3 -0
- archunitpython/common/error/errors.py +13 -0
- archunitpython/common/extraction/__init__.py +13 -0
- archunitpython/common/extraction/extract_graph.py +345 -0
- archunitpython/common/extraction/graph.py +39 -0
- archunitpython/common/fluentapi/__init__.py +3 -0
- archunitpython/common/fluentapi/checkable.py +28 -0
- archunitpython/common/logging/__init__.py +3 -0
- archunitpython/common/logging/types.py +18 -0
- archunitpython/common/pattern_matching.py +80 -0
- archunitpython/common/projection/__init__.py +30 -0
- archunitpython/common/projection/cycles/__init__.py +4 -0
- archunitpython/common/projection/cycles/cycle_utils.py +49 -0
- archunitpython/common/projection/cycles/cycles.py +26 -0
- archunitpython/common/projection/cycles/johnsons_apsp.py +110 -0
- archunitpython/common/projection/cycles/model.py +22 -0
- archunitpython/common/projection/cycles/tarjan_scc.py +86 -0
- archunitpython/common/projection/edge_projections.py +36 -0
- archunitpython/common/projection/project_cycles.py +85 -0
- archunitpython/common/projection/project_edges.py +43 -0
- archunitpython/common/projection/project_nodes.py +49 -0
- archunitpython/common/projection/types.py +40 -0
- archunitpython/common/regex_factory.py +76 -0
- archunitpython/common/types.py +29 -0
- archunitpython/common/util/__init__.py +3 -0
- archunitpython/common/util/declaration_detector.py +115 -0
- archunitpython/common/util/logger.py +100 -0
- archunitpython/files/__init__.py +3 -0
- archunitpython/files/assertion/__init__.py +28 -0
- archunitpython/files/assertion/custom_file_logic.py +107 -0
- archunitpython/files/assertion/cycle_free.py +29 -0
- archunitpython/files/assertion/depend_on_files.py +67 -0
- archunitpython/files/assertion/matching_files.py +64 -0
- archunitpython/files/fluentapi/__init__.py +3 -0
- archunitpython/files/fluentapi/files.py +403 -0
- archunitpython/metrics/__init__.py +3 -0
- archunitpython/metrics/assertion/__init__.py +0 -0
- archunitpython/metrics/assertion/metric_thresholds.py +51 -0
- archunitpython/metrics/calculation/__init__.py +0 -0
- archunitpython/metrics/calculation/count.py +148 -0
- archunitpython/metrics/calculation/distance.py +110 -0
- archunitpython/metrics/calculation/lcom.py +177 -0
- archunitpython/metrics/common/__init__.py +19 -0
- archunitpython/metrics/common/types.py +67 -0
- archunitpython/metrics/extraction/__init__.py +0 -0
- archunitpython/metrics/extraction/extract_class_info.py +246 -0
- archunitpython/metrics/fluentapi/__init__.py +3 -0
- archunitpython/metrics/fluentapi/export_utils.py +89 -0
- archunitpython/metrics/fluentapi/metrics.py +589 -0
- archunitpython/metrics/projection/__init__.py +0 -0
- archunitpython/py.typed +0 -0
- archunitpython/slices/__init__.py +3 -0
- archunitpython/slices/assertion/__init__.py +13 -0
- archunitpython/slices/assertion/admissible_edges.py +108 -0
- archunitpython/slices/fluentapi/__init__.py +3 -0
- archunitpython/slices/fluentapi/slices.py +220 -0
- archunitpython/slices/projection/__init__.py +8 -0
- archunitpython/slices/projection/slicing_projections.py +128 -0
- archunitpython/slices/uml/__init__.py +4 -0
- archunitpython/slices/uml/export_diagram.py +31 -0
- archunitpython/slices/uml/generate_rules.py +71 -0
- archunitpython/testing/__init__.py +3 -0
- archunitpython/testing/assertion.py +47 -0
- archunitpython/testing/common/__init__.py +4 -0
- archunitpython/testing/common/color_utils.py +57 -0
- archunitpython/testing/common/violation_factory.py +97 -0
- archunitpython/testing/pytest_plugin/__init__.py +0 -0
- archunitpython-1.0.0.dist-info/METADATA +660 -0
- archunitpython-1.0.0.dist-info/RECORD +75 -0
- archunitpython-1.0.0.dist-info/WHEEL +4 -0
- archunitpython-1.0.0.dist-info/licenses/LICENSE +7 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""Convert violations to human-readable test messages."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
from archunitpython.common.assertion.violation import EmptyTestViolation, Violation
|
|
8
|
+
from archunitpython.files.assertion.custom_file_logic import CustomFileViolation
|
|
9
|
+
from archunitpython.files.assertion.cycle_free import ViolatingCycle
|
|
10
|
+
from archunitpython.files.assertion.depend_on_files import ViolatingFileDependency
|
|
11
|
+
from archunitpython.files.assertion.matching_files import ViolatingNode
|
|
12
|
+
from archunitpython.metrics.assertion.metric_thresholds import (
|
|
13
|
+
FileCountViolation,
|
|
14
|
+
MetricViolation,
|
|
15
|
+
)
|
|
16
|
+
from archunitpython.slices.assertion.admissible_edges import ViolatingEdge
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class TestViolation:
|
|
21
|
+
"""A test-friendly violation representation."""
|
|
22
|
+
|
|
23
|
+
message: str
|
|
24
|
+
details: str
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ViolationFactory:
|
|
28
|
+
"""Convert violations to test-friendly format."""
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def from_violation(violation: Violation) -> TestViolation:
|
|
32
|
+
if isinstance(violation, EmptyTestViolation):
|
|
33
|
+
return TestViolation(
|
|
34
|
+
message="No files matched",
|
|
35
|
+
details=violation.message,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
if isinstance(violation, ViolatingNode):
|
|
39
|
+
return TestViolation(
|
|
40
|
+
message="File pattern violation",
|
|
41
|
+
details=f"File '{violation.projected_node.label}' "
|
|
42
|
+
f"{'matches' if violation.is_negated else 'does not match'} "
|
|
43
|
+
f"pattern '{violation.check_pattern.regexp.pattern}'",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
if isinstance(violation, ViolatingFileDependency):
|
|
47
|
+
edge = violation.dependency
|
|
48
|
+
return TestViolation(
|
|
49
|
+
message="File dependency violation",
|
|
50
|
+
details=f"'{edge.source_label}' "
|
|
51
|
+
f"{'depends on' if violation.is_negated else 'does not depend on'} "
|
|
52
|
+
f"'{edge.target_label}'",
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
if isinstance(violation, ViolatingCycle):
|
|
56
|
+
cycle_str = " -> ".join(
|
|
57
|
+
e.source_label for e in violation.cycle
|
|
58
|
+
)
|
|
59
|
+
return TestViolation(
|
|
60
|
+
message="Circular dependency detected",
|
|
61
|
+
details=f"Cycle: {cycle_str}",
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
if isinstance(violation, CustomFileViolation):
|
|
65
|
+
return TestViolation(
|
|
66
|
+
message=violation.message,
|
|
67
|
+
details=f"File: {violation.file_info.path}",
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
if isinstance(violation, MetricViolation):
|
|
71
|
+
return TestViolation(
|
|
72
|
+
message=f"Metric '{violation.metric_name}' violation",
|
|
73
|
+
details=f"Class '{violation.class_name}' in '{violation.file_path}': "
|
|
74
|
+
f"value={violation.metric_value:.2f}, "
|
|
75
|
+
f"threshold={violation.threshold:.2f} ({violation.comparison})",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
if isinstance(violation, FileCountViolation):
|
|
79
|
+
return TestViolation(
|
|
80
|
+
message=f"File metric '{violation.metric_name}' violation",
|
|
81
|
+
details=f"File '{violation.file_path}': "
|
|
82
|
+
f"value={violation.metric_value:.2f}, "
|
|
83
|
+
f"threshold={violation.threshold:.2f} ({violation.comparison})",
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
if isinstance(violation, ViolatingEdge):
|
|
87
|
+
edge = violation.projected_edge
|
|
88
|
+
return TestViolation(
|
|
89
|
+
message="Slice dependency violation",
|
|
90
|
+
details=f"'{edge.source_label}' -> '{edge.target_label}' "
|
|
91
|
+
f"is {'forbidden' if violation.is_negated else 'not allowed'}",
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
return TestViolation(
|
|
95
|
+
message="Architecture violation",
|
|
96
|
+
details=str(violation),
|
|
97
|
+
)
|
|
File without changes
|