MCPcopy Create free account
hub / github.com/Qinbf/groundmap / list_relation_issues

Function list_relation_issues

scripts/k.py:681–716  ·  view source on GitHub ↗

扫所有 wikilinks,找出"看起来像关系类型但不在 RELATION_TYPES 白名单"的引用。 典型场景: - 拼写错误:[[X|SUPORTS]]、[[X|EXTNDS]] - 用了非标准关系:[[X|IMPLEMENTS]]、[[X|CONTRADICTS]] 短缩写(长度 < 5 且无下划线,如 RFC / API)不会触发——它们更可能是别名。 归档区 (wiki/_archive_*) 不检查。

(pages)

Source from the content-addressed store, hash-verified

679
680
681def list_relation_issues(pages) -> list[dict]:
682 """扫所有 wikilinks,找出"看起来像关系类型但不在 RELATION_TYPES 白名单"的引用。
683
684 典型场景:
685 - 拼写错误:[[X|SUPORTS]]、[[X|EXTNDS]]
686 - 用了非标准关系:[[X|IMPLEMENTS]]、[[X|CONTRADICTS]]
687
688 短缩写(长度 < 5 且无下划线,如 RFC / API)不会触发——它们更可能是别名。
689 归档区 (wiki/_archive_*) 不检查。
690 """
691 out = []
692 for page in pages:
693 if "_archive" in page.path:
694 continue
695 scan_text = mask_code_spans(page.raw_content)
696 for m in WIKILINK_RE.finditer(scan_text):
697 third = m.group(3)
698 if not _looks_like_relation(third):
699 continue
700 stripped = third.strip()
701 if stripped in RELATION_TYPES:
702 continue
703 line = page.raw_content[: m.start()].count("\n") + 1
704 out.append({
705 "path": page.path,
706 "title": page.title,
707 "line": line,
708 "raw": m.group(0),
709 "bad_relation": stripped,
710 "suggestion": (
711 f"{stripped!r} 不在标准关系白名单 {sorted(RELATION_TYPES)}。"
712 f"如果是关系类型:改为白名单中某条;"
713 f"如果本意是显示别名:改为小写 / 中文 / 加空格让其不再形似关系。"
714 ),
715 })
716 return out
717
718
719# ========== 关系词频次失衡扫描(list-relation-balance) ==========

Callers 2

health_reportFunction · 0.85
_main_implFunction · 0.85

Calls 2

mask_code_spansFunction · 0.85
_looks_like_relationFunction · 0.85

Tested by

no test coverage detected