Skip to content

Commit e3a934e

Browse files
committed
chore(baseline): add SpotBugs baseline capture
1 parent 2ea1b41 commit e3a934e

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

scripts/baseline/run-spotbugs.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
# Run SpotBugs and capture XML + summary JSON.
3+
set -euo pipefail
4+
OUT="docs/superpowers/baselines/2026-04-17/raw"
5+
mkdir -p "$OUT"
6+
mvn -B spotbugs:spotbugs 2>&1 | tee "$OUT/spotbugs.log"
7+
# spotbugsXml.xml default location
8+
if [[ -f target/spotbugsXml.xml ]]; then
9+
cp target/spotbugsXml.xml "$OUT/spotbugs.xml"
10+
fi
11+
12+
python3 - <<'PY' > "$OUT/spotbugs-summary.json"
13+
import xml.etree.ElementTree as ET, json, collections, os
14+
path="docs/superpowers/baselines/2026-04-17/raw/spotbugs.xml"
15+
if not os.path.exists(path):
16+
print(json.dumps({"error":"no spotbugs.xml produced"}, indent=2)); raise SystemExit
17+
root=ET.parse(path).getroot()
18+
by_priority=collections.Counter()
19+
by_category=collections.Counter()
20+
by_pattern =collections.Counter()
21+
for b in root.iter("BugInstance"):
22+
by_priority[b.attrib.get("priority","?")] += 1
23+
by_category[b.attrib.get("category","?")] += 1
24+
by_pattern [b.attrib.get("type","?")] += 1
25+
print(json.dumps({
26+
"total_bugs": sum(by_priority.values()),
27+
"by_priority": dict(by_priority),
28+
"by_category": dict(by_category),
29+
"top_patterns": by_pattern.most_common(20),
30+
}, indent=2))
31+
PY
32+
cat "$OUT/spotbugs-summary.json"

0 commit comments

Comments
 (0)