-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontracts.py
More file actions
72 lines (59 loc) · 2.17 KB
/
contracts.py
File metadata and controls
72 lines (59 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2026 Den Rozhnovskiy
from __future__ import annotations
from enum import IntEnum
from typing import Final
BASELINE_SCHEMA_VERSION: Final = "2.1"
BASELINE_FINGERPRINT_VERSION: Final = "1"
CACHE_VERSION: Final = "2.5"
REPORT_SCHEMA_VERSION: Final = "2.8"
METRICS_BASELINE_SCHEMA_VERSION: Final = "1.2"
DEFAULT_COMPLEXITY_THRESHOLD: Final = 20
DEFAULT_COUPLING_THRESHOLD: Final = 10
DEFAULT_COHESION_THRESHOLD: Final = 4
DEFAULT_REPORT_DESIGN_COMPLEXITY_THRESHOLD: Final = 20
DEFAULT_REPORT_DESIGN_COUPLING_THRESHOLD: Final = 10
DEFAULT_REPORT_DESIGN_COHESION_THRESHOLD: Final = 4
DEFAULT_HEALTH_THRESHOLD: Final = 60
COMPLEXITY_RISK_LOW_MAX: Final = 10
COMPLEXITY_RISK_MEDIUM_MAX: Final = 20
COUPLING_RISK_LOW_MAX: Final = 5
COUPLING_RISK_MEDIUM_MAX: Final = 10
COHESION_RISK_MEDIUM_MAX: Final = 3
HEALTH_WEIGHTS: Final[dict[str, float]] = {
"clones": 0.25,
"complexity": 0.20,
"coupling": 0.10,
"cohesion": 0.15,
"dead_code": 0.10,
"dependencies": 0.10,
"coverage": 0.10,
}
class ExitCode(IntEnum):
SUCCESS = 0
CONTRACT_ERROR = 2
GATING_FAILURE = 3
INTERNAL_ERROR = 5
REPOSITORY_URL: Final = "https://github.com/orenlab/codeclone"
ISSUES_URL: Final = "https://github.com/orenlab/codeclone/issues"
DOCS_URL: Final = "https://orenlab.github.io/codeclone/"
def cli_help_epilog() -> str:
return "\n".join(
[
"Exit codes:",
" 0 Success.",
" 2 Contract error: untrusted or invalid baseline, invalid output",
" configuration, incompatible versions, or unreadable sources in",
" CI/gating mode.",
" 3 Gating failure: new clones, threshold violations, or metrics",
" quality gate failures.",
" 5 Internal error: unexpected exception.",
"",
f"Repository: {REPOSITORY_URL}",
f"Issues: {ISSUES_URL}",
f"Docs: {DOCS_URL}",
]
)