Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@
## 2024-06-16 - Parallelize Subprocess CLI Calls
**Learning:** Sequential, synchronous execution of `subprocess.run` (like calling the GitHub CLI) across multiple items (like PRs) is a significant I/O bottleneck.
**Action:** Use `concurrent.futures.ThreadPoolExecutor` with `functools.partial` and `executor.map` to safely parallelize I/O-bound subprocess executions, significantly reducing overall script runtime.

## 2024-05-16 - Module-level Constants for Performance
**Learning:** Recreating static dictionaries (like severity mappings and icons) inside frequently called functions causes unnecessary memory allocations and slight performance overhead on every call.
**Action:** Extract static dictionaries to module-level constants to ensure they are instantiated only once when the module is loaded.
23 changes: 13 additions & 10 deletions scanner/cli/vibesec.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,21 +602,24 @@ def _scan_file(file_path: Path, base_path: Path):

return findings


# ⚡ Bolt: Move severity mappings to module level to avoid redundant
# dictionary allocations on every call to print scan results.
SEVERITY_ORDER = {"CRITICAL": 0, "HIGH": 1, "WARNING": 2, "INFO": 3}
SEVERITY_ICONS = {
"CRITICAL": "🔴 CRITICAL",
"HIGH": "🟠 HIGH",
"WARNING": "🟡 WARNING",
"INFO": "🔵 INFO",
}

def _print_scan_results(findings, files_scanned):
severity_order = {"CRITICAL": 0, "HIGH": 1, "WARNING": 2, "INFO": 3}
findings.sort(key=lambda f: severity_order.get(f["severity"], 99))

severity_icons = {
"CRITICAL": "🔴 CRITICAL",
"HIGH": "🟠 HIGH",
"WARNING": "🟡 WARNING",
"INFO": "🔵 INFO",
}
findings.sort(key=lambda f: SEVERITY_ORDER.get(f["severity"], 99))

counts = {"CRITICAL": 0, "HIGH": 0, "WARNING": 0, "INFO": 0}
for f in findings:
counts[f["severity"]] += 1
icon = severity_icons.get(f["severity"], f["severity"])
icon = SEVERITY_ICONS.get(f["severity"], f["severity"])
print(f"[{icon}] {f['file']}:{f['line']}")
print(f" Rule: {f['rule_id']}")
print(f" {f['message']}")
Expand Down
Loading