Files
ci-demo/app/legacy_report.py

42 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Учебный модуль с высокой сложностью для метрического гейта CI.
V(G) функции classify_order — ранг C (11–20). Поэтому:
xenon --max-absolute C app/ # зелёный
xenon --max-absolute B app/ # красный — гейт не пропускает
Мораль: порог в CI делает рост сложности видимым и блокирующим.
"""
def classify_order(order, cfg):
"""Классифицировать заказ по десятку правил — намеренно сложно."""
if order is None:
return "missing"
if "total" not in order:
return "no_total"
total = order["total"]
if total < 0:
return "negative"
if total == 0:
return "empty"
if total > 100000:
return "huge"
if cfg.get("maintenance"):
return "maintenance"
if cfg.get("blocked"):
return "blocked"
if cfg.get("regions") and order.get("region") not in cfg["regions"]:
return "region"
if order.get("coupon") and not cfg.get("coupons", False):
return "coupon"
if total > cfg.get("limit", 10000):
return "limit"
if order.get("fraud") and order.get("manual_review"):
return "fraud_review"
elif order.get("fraud"):
return "fraud"
if order.get("vip") and total > 5000:
return "vip_review"
return "ok"