MCPcopy
hub / github.com/github/awesome-copilot / check_bugs_heading

Function check_bugs_heading

skills/quality-playbook/quality_gate.py:829–887  ·  view source on GitHub ↗

BUGS.md heading-format section (benchmark 39). Returns (bug_count, bug_ids).

(q)

Source from the content-addressed store, hash-verified

827
828
829def check_bugs_heading(q):
830 """BUGS.md heading-format section (benchmark 39).
831
832 Returns (bug_count, bug_ids).
833 """
834 print("[BUGS.md Heading Format]")
835 bugs_md = q / "BUGS.md"
836 if not bugs_md.is_file():
837 fail("BUGS.md missing")
838 return 0, []
839
840 try:
841 bugs_content = bugs_md.read_text(encoding="utf-8", errors="replace")
842 except OSError:
843 bugs_content = ""
844 lines = bugs_content.splitlines()
845
846 correct_headings = sum(1 for ln in lines
847 if re.match(r"^### BUG-([HML]|[0-9])[0-9]*", ln))
848 wrong_headings = sum(1 for ln in lines
849 if re.match(r"^## BUG-", ln)
850 and not re.match(r"^### BUG-", ln))
851 deep_headings = sum(1 for ln in lines
852 if re.match(r"^#{4,} BUG-([HML]|[0-9])", ln))
853 bold_headings = sum(1 for ln in lines
854 if re.match(r"^\*\*BUG-([HML]|[0-9])", ln))
855 bullet_headings = sum(1 for ln in lines
856 if re.match(r"^- BUG-([HML]|[0-9])", ln))
857
858 bug_count = correct_headings
859
860 if (correct_headings > 0 and wrong_headings == 0 and deep_headings == 0
861 and bold_headings == 0 and bullet_headings == 0):
862 pass_(f"All {correct_headings} bug headings use ### BUG-NNN format")
863 else:
864 if wrong_headings > 0:
865 fail(f"{wrong_headings} heading(s) use ## instead of ###")
866 if deep_headings > 0:
867 fail(f"{deep_headings} heading(s) use #### or deeper instead of ###")
868 if bold_headings > 0:
869 fail(f"{bold_headings} heading(s) use **BUG- format")
870 if bullet_headings > 0:
871 fail(f"{bullet_headings} heading(s) use - BUG- format")
872 if correct_headings == 0 and wrong_headings == 0:
873 if re.search(r"^##\s+(No confirmed bugs|Zero confirmed bugs)\s*$",
874 bugs_content, re.MULTILINE | re.IGNORECASE):
875 pass_("Zero-bug run — no headings expected")
876 else:
877 bug_count = wrong_headings + deep_headings + bold_headings + bullet_headings
878 warn("No ### BUG-NNN headings found in BUGS.md")
879 else:
880 bug_count = correct_headings + wrong_headings + bold_headings + bullet_headings
881
882 # Extract canonical bug IDs: BUG-NNN or BUG-HNN / BUG-MNN / BUG-LNN
883 raw = re.findall(r"BUG-(?:[HML][0-9]+|[0-9]+)", bugs_content)
884 filtered = [b for b in raw if re.fullmatch(r"BUG-(?:[HML][0-9]+|[0-9]+)", b)]
885 bug_ids = sorted(set(filtered))
886

Callers 1

check_repoFunction · 0.85

Calls 4

failFunction · 0.85
pass_Function · 0.85
searchMethod · 0.80
warnFunction · 0.70

Tested by

no test coverage detected