11"""
22Automated Bug Triage Tool
3- This script scans markdown bug reports, classifies them by severity based on
3+ This script scans markdown bug reports, classifies them by severity based on
44keywords, and generates a summarized triage report in Markdown format.
55"""
66
1515BUG_PATH = str (BASE_DIR / "production" / "qa" / "bugs" / "*.md" )
1616OUTPUT_PATH = str (BASE_DIR / "production" / "qa" )
1717
18+
1819def classify_severity (content : str ) -> str :
1920 """
2021 Classifies bug severity based on specific keywords found in the content.
2122 Returns S1 (Critical) through S4 (Minor).
2223 >>> classify_severity("The application had a fatal crash on startup.")
2324 'S1'
2425 >>> classify_severity("The UI is a bit slow today.")
25- 'S3'
26+ 'S3'
2627 """
2728 content = content .lower ()
2829
@@ -43,11 +44,7 @@ def classify_priority(severity: str) -> str:
4344 >>> classify_priority("S4")
4445 'P4'
4546 """
46- priority_map = {
47- "S1" : "P1" ,
48- "S2" : "P2" ,
49- "S3" : "P3"
50- }
47+ priority_map = {"S1" : "P1" , "S2" : "P2" , "S3" : "P3" }
5148 return priority_map .get (severity , "P4" )
5249
5350
@@ -67,14 +64,16 @@ def read_bugs() -> List[Dict]:
6764 severity = classify_severity (content )
6865 priority = classify_priority (severity )
6966
70- bugs .append ({
71- "id" : f"BUG-{ i + 1 :03} " ,
72- "file" : file_path ,
73- "severity" : severity ,
74- "priority" : priority ,
75- # Extract first line as summary, capped at 80 chars
76- "summary" : content .strip ().split ("\n " )[0 ][:80 ]
77- })
67+ bugs .append (
68+ {
69+ "id" : f"BUG-{ i + 1 :03} " ,
70+ "file" : file_path ,
71+ "severity" : severity ,
72+ "priority" : priority ,
73+ # Extract first line as summary, capped at 80 chars
74+ "summary" : content .strip ().split ("\n " )[0 ][:80 ],
75+ }
76+ )
7877 except IOError as e :
7978 print (f"⚠️ Could not read file { file_path } : { e } " )
8079
@@ -86,11 +85,11 @@ def generate_report(bugs: List[Dict]) -> None:
8685 Groups bugs by priority and writes a summarized Markdown report.
8786 """
8887 date = datetime .now ().strftime ("%Y-%m-%d" )
89-
88+
9089 # Ensure the output directory exists
9190 if not os .path .exists (OUTPUT_PATH ):
9291 os .makedirs (OUTPUT_PATH )
93-
92+
9493 output_file = os .path .join (OUTPUT_PATH , f"bug-triage-{ date } .md" )
9594
9695 # Filter bugs into priority buckets
@@ -112,7 +111,7 @@ def generate_report(bugs: List[Dict]) -> None:
112111 f"| P3 | { len (p3 )} |" ,
113112 f"| P4 | { len (p4 )} |" ,
114113 "\n ---\n " ,
115- "## P1 Bugs (Critical)"
114+ "## P1 Bugs (Critical)" ,
116115 ]
117116
118117 for b in p1 :
0 commit comments