fix
This commit is contained in:
@@ -47,6 +47,9 @@ class MustNotCallFunctionEngine(_FunctionCallBase):
|
||||
class CountFunctionCallEngine(_FunctionCallBase):
|
||||
def _message(self, rule, count):
|
||||
target = rule["target"]
|
||||
exact = rule.get("exact")
|
||||
if exact is not None and count != exact:
|
||||
return rule.get("message") or f"{target}() 需要调用 {exact} 次,当前 {count} 次"
|
||||
min_count = rule.get("min")
|
||||
max_count = rule.get("max")
|
||||
if min_count is not None and count < min_count:
|
||||
@@ -62,13 +65,14 @@ class CountFunctionCallEngine(_FunctionCallBase):
|
||||
|
||||
def describe(self, rule, language, mapping):
|
||||
target = rule["target"]
|
||||
min_count = rule.get("min")
|
||||
max_count = rule.get("max")
|
||||
if rule.get("message"):
|
||||
return rule["message"]
|
||||
exact = rule.get("exact")
|
||||
if exact is not None:
|
||||
return f"{target}() 调用 {exact} 次"
|
||||
parts = []
|
||||
if min_count is not None:
|
||||
parts.append(f"至少 {min_count} 次")
|
||||
if max_count is not None:
|
||||
parts.append(f"至多 {max_count} 次")
|
||||
if rule.get("min") is not None:
|
||||
parts.append(f"至少 {rule['min']} 次")
|
||||
if rule.get("max") is not None:
|
||||
parts.append(f"至多 {rule['max']} 次")
|
||||
return f"{target}() " + "、".join(parts)
|
||||
|
||||
Reference in New Issue
Block a user