| 88 | |
| 89 | |
| 90 | def write_report(findings: List[Finding], report_file: Path) -> None: |
| 91 | report_file.parent.mkdir(parents=True, exist_ok=True) |
| 92 | lines = [] |
| 93 | lines.append(f"Total findings: {len(findings)}") |
| 94 | by_kind: dict[str, int] = {} |
| 95 | for f in findings: |
| 96 | by_kind[f.kind] = by_kind.get(f.kind, 0) + 1 |
| 97 | for kind in sorted(by_kind): |
| 98 | lines.append(f"- {kind}: {by_kind[kind]}") |
| 99 | lines.append("") |
| 100 | for f in findings: |
| 101 | lines.append( |
| 102 | f"{f.kind} {f.file}:{f.line_no} :: {f.url} :: suggestion={f.suggestion}" |
| 103 | ) |
| 104 | report_file.write_text("\n".join(lines) + "\n", encoding="utf-8") |
| 105 | |
| 106 | |
| 107 | def main() -> int: |