1) Rule selection (what to turn on, when)
A. Start from outcomes, not rule catalogs
Group rules by intent and adopt in this order (highest signal first):
- Correctness / crashers
- Null deref, use-after-free, out-of-bounds, resource leaks, uninitialized values, race conditions.
- Security
- Injection, path traversal, unsafe deserialization, crypto misuse, authz/authn mistakes, secrets, SSRF.
- Reliability / maintainability
- Dead code, exception swallowing, logging misuse, error handling.
- Style / formatting
- Only after the program is stable; these are best handled by formatters/linters with autofix.
B. Choose a “core rule set” and an “extended rule set”
- Core: must-fix, enforced in CI (gates merges).
- Extended: advisory; runs in CI but doesn’t block, or blocks only on “new violations”.
C. Calibrate for signal-to-noise
For each candidate rule:
- Run on a representative slice of repos/modules.
- Estimate:
- True positive rate (TP / (TP+FP))
- Developer effort (minutes per fix)
- Likelihood of regression (fix risk)
- Adopt rules with:
- High TP rate
- Clear, actionable messages
- Low “refactoring required” burden (at least initially)
D. Rollout strategy that doesn’t stall teams
- Baseline existing findings (don’t demand fixing historical debt immediately).
- Enforce “no new debt”:
- Block PRs that introduce new issues (diff-aware scanning).
- Then do targeted “debt paydown” sprints per category (e.g., security first).
2) Suppression (how to allow exceptions without losing control)
A. Provide 3 suppression scopes (prefer smallest scope)
- Inline suppression (preferred)
- Per-line / per-statement annotation/comment.
- File-level suppression
- For generated files, vendor code, or known noisy modules.
- Rule-level suppression
- Only for clearly-broken rules in a specific context; time-box it.
B. Require metadata on suppressions
Each suppression should include:
- Reason (why it’s safe or not applicable)
- Owner (team or username)
- Expiration (date or version) or “review by” date
- Tracking link (ticket/issue)
Example policy (tool-agnostic):
- Inline suppressions must include a reason and ticket.
- File-level suppressions need security review approval.
- Any suppression without an expiration triggers an alert after N days.
C. Measure suppression health
- Suppression count and growth rate
- % suppressions without ticket/owner/expiry (should trend to 0)
- “Suppression churn” (same issue repeatedly suppressed)
D. Don’t allow suppressions to hide new issues by default
Prefer “suppress this instance” over “disable the rule entirely”.
3) Autofix (how to automate fixes safely)
A. Split autofixes into “safe” and “unsafe”
Safe autofix characteristics
- Purely local changes (single statement/file)
- Deterministic formatting, imports, trivial API migration
- Mechanical fix with no behavior change (or behavior change is clearly correct)
Unsafe autofix characteristics
- Requires semantic knowledge, refactoring across files, concurrency logic, security logic changes
Policy:
- Autofix enabled by default only for safe fixes
- Unsafe fixes produce suggestions + remediation guidance, not automatic edits.
B. How to operationalize autofix
- Run autofix in CI as a separate job that:
- Creates a PR (or attaches a patch)
- Includes tool output and before/after diff context
- Require:
- Tests passing
- Formatter run after autofix (to minimize diff noise)
- Per-rule opt-in (don’t enable every autofix blindly)
C. Guardrails
- Cap PR size (e.g., max lines changed); split by module
- Don’t autofix in generated/vendor directories
- Maintain a “known risky autofix rules” denylist
- Track regression rate from autofix PRs (bugs or rollbacks)
4) Metrics (what to track to prove progress and steer decisions)
A. Core health metrics (program level)
- New issues introduced per week (goal: near zero for core rules)
- Open issues by severity (Critical/High/Med/Low)
- MTTR (mean time to remediate) by severity
- Fix rate (issues closed / week)
- Backlog trend (should go down for targeted debt paydown)
B. Quality-of-signal metrics (tool effectiveness)
- False positive rate (sampled via triage labels)
- Actionability rate (% findings that lead to a code change)
- Suppression rate (high can indicate noisy rules)
- Reopen rate (issue “fixed” but returns)
C. Developer experience / cost metrics
- CI time added by static analysis
- Time-to-first-feedback (minutes from PR open to results)
- % PRs blocked and reasons
- Autofix acceptance rate (% autofix PRs merged)
D. Security-oriented metrics (if applicable)
- Findings mapped to CWE/OWASP categories
- Time-to-fix by severity and exploitability
- Coverage: % repos/services scanned; % code covered (where measurable)
A practical “first 90 days” implementation plan
Weeks 1–2
- Pick tools per language and define severity taxonomy.
- Enable scanning in CI in “report-only”.
- Create baseline + “new issues only” mode.
Weeks 3–6
- Turn on a small core set (10–30 rules) for correctness/security.
- Add suppression format + review/expiry requirements.
- Start tracking metrics dashboard.
Weeks 7–10
- Enable safe autofix for formatting/imports/trivial issues.
- Start blocking merges on new Critical/High core issues.
Weeks 11–13
- Expand core rules based on triage data.
- Run focused backlog reduction for one category (e.g., injection or null safety).
- Publish quarterly program report using the metrics above.
If you tell me the languages (e.g., Java/Kotlin, C/C++, Go, Python, JS/TS), repo count, and whether you want PR gating on “new issues only” or “all issues,” I can propose a concrete rule set, suppression format examples for your tools, and a metrics dashboard schema.