fix: code review — defensivな下*/去掉+B枝一致化
## 评审发现修正
### 1. __import__('re') → re (cond.py, 3处)
__import__绕过module级re引用,mock下前后不一致。
### 2. NOT路径下*/去掉 (cond.py:124-126)
NOT WS-PLAN-CODE(WS-IDX) > 50 → 返回保留了下标
其他路径(算术/标准)都去了,只有NOT路径没去。
### 3. _match_constraint防禦*/去掉 (coverage.py)
两边字段名同时去掉下标再比较,防止约束侧/解析侧
下标处理不一致导致匹配失败。
### 4. _match_leaf 防禦*/去掉 (coverage.py)
CondLeaf路径同样的防禦。
### 5. 裸字段分支去死码 (cond.py)
在外層guard保證下永遠為真,
是死码。合併為一行。
Co-Authored-By: Claude
This commit is contained in:
@@ -182,14 +182,18 @@ def mark_coverage(decision_points, leaf_stats, branch_paths, fields):
|
||||
def _match_constraint(c, parsed):
|
||||
if len(c) != 4:
|
||||
return False
|
||||
return (c[0] == parsed[0] and c[1] == parsed[1]
|
||||
c0 = re.sub(r'\s*\(.*?\)\s*$', '', str(c[0])).strip()
|
||||
p0 = re.sub(r'\s*\(.*?\)\s*$', '', str(parsed[0])).strip()
|
||||
return (c0 == p0 and c[1] == parsed[1]
|
||||
and str(c[2]) == str(parsed[2]))
|
||||
|
||||
|
||||
def _match_leaf(c, leaf):
|
||||
if len(c) != 4:
|
||||
return False
|
||||
return (c[0] == leaf.field and c[1] == leaf.op
|
||||
c0 = re.sub(r'\s*\(.*?\)\s*$', '', str(c[0])).strip()
|
||||
l0 = re.sub(r'\s*\(.*?\)\s*$', '', str(leaf.field)).strip()
|
||||
return (c0 == l0 and c[1] == leaf.op
|
||||
and str(c[2]) == str(leaf.value))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user