Suppression Comments
Suppression comments allow you to exclude specific functions from policy violations while keeping them tracked in reports. This is useful for handling false positives, legacy code, and intentionally complex algorithms.
Quick Start
Place a comment immediately before the function:
// hotspots-ignore: legacy code, refactor planned for Q2 2026
function complexLegacyParser(input: string) {
// High complexity code...
}Comment Format
Required format:
// hotspots-ignore: <reason>Rules:
- Comment must be on the line immediately before the function
- Format starts with
// hotspots-ignore: - Reason is required after the colon (warning if missing)
- Blank lines between comment and function break the suppression
Examples
Valid Suppressions
// hotspots-ignore: complex algorithm with proven test coverage
function fibonacci(n: number): number {
// ...
}
// hotspots-ignore: generated code from protocol buffers
class MessageHandler {
handle() { /* ... */ }
}
// hotspots-ignore: legacy parser, migration to new implementation in progress
const parse = (input: string) => {
// ...
};Invalid Suppressions
// hotspots-ignore: reason here
function foo() { } // ❌ Blank line breaks suppression
// This is a comment
// hotspots-ignore: reason
function bar() { } // ❌ Other comment in between
// hotspots-ignore
function baz() { } // ⚠️ Missing colon - treated as missing reason
// hotspots-ignore:
function qux() { } // ⚠️ Warning: suppression without reasonWhat Suppressions Affect
Excluded From (Policy Filtering)
Suppressed functions are excluded from:
- Critical Introduction - Won't fail if function becomes critical
- Excessive Risk Regression - Won't fail if LRS increases by ≥1.0
- Watch Threshold - No warning when entering watch range
- Attention Threshold - No warning when entering attention range
- Rapid Growth - No warning for rapid LRS increases
Included In (Still Tracked)
Suppressed functions are included in:
- Analysis Reports - Visible with
suppression_reasonfield - Net Repo Regression - Counted in total repository LRS
- Snapshots - Persisted to
.hotspots/snapshots/ - HTML Reports - Displayed with suppression indicator
- JSON Output - Contains
suppression_reasonfield
Validation
Missing Reason Warning
Functions suppressed without a reason trigger a warning:
// hotspots-ignore:
function foo() { }Policy output:
{
"warnings": [
{
"id": "suppression-missing-reason",
"severity": "warning",
"function_id": "src/foo.ts::foo",
"message": "Function src/foo.ts::foo suppressed without reason"
}
]
}This is a warning only (non-blocking), but encourages documenting suppressions.
JSON Output
Suppressed functions include a suppression_reason field:
{
"file": "src/legacy.ts",
"function": "oldParser",
"line": 42,
"metrics": { "cc": 15, "nd": 5, "fo": 8, "ns": 3 },
"lrs": 12.5,
"band": "critical",
"suppression_reason": "legacy code, refactor planned for Q2 2026"
}Notes:
- Functions without suppressions omit this field (not
null) - Empty reason shows as
"suppression_reason": ""
Best Practices
When to Suppress
✅ Good reasons to suppress:
- Complex algorithms with established test coverage
- Legacy code pending scheduled migration
- Generated code (protocol buffers, GraphQL, etc.)
- Intentionally complex code (e.g., optimized parsers, state machines)
- Well-documented algorithms (e.g., cryptographic functions)
When NOT to Suppress
❌ Bad reasons to suppress:
- New code that should be refactored
- "I'll fix it later" without a concrete plan
- Code that could be simplified but you don't want to
- Avoiding code review feedback
- Hiding poor design choices
Documentation Guidelines
Good suppression reasons include:
- What - What makes this complex
- Why - Why it's intentionally complex or not being fixed now
- When - When it will be addressed (if applicable)
Examples:
// ✅ Good: Specific, actionable, dated
// hotspots-ignore: RSA encryption algorithm, well-tested, cannot be simplified
// ✅ Good: Clear plan
// hotspots-ignore: legacy parser, migration to TreeSitter in Q2 2026
// ❌ Bad: Vague, no plan
// hotspots-ignore: TODO fix this later
// ❌ Bad: No reason
// hotspots-ignore:Code Review Guidelines
Require review for suppressions:
- All new suppressions should be reviewed
- Ensure reason is documented and valid
- Verify suppression is the right choice (vs. refactoring)
- Consider adding a tracking issue/ticket
Periodic audits:
- Review suppressed functions quarterly
- Check if reasons are still valid
- Remove suppressions when code is refactored
- Update reasons if plans change
Technical Details
Determinism
Suppression extraction is fully deterministic:
- Pure function of (source code, function span, source map)
- No I/O, randomness, or timestamps
- Same source → same suppression → same results
- Byte-for-byte identical snapshots
Persistence
Suppressions are persisted in snapshots:
FunctionSnapshot.suppression_reasonfieldFunctionDeltaEntry.suppression_reasonfield- Tracked across commits in delta mode
- Auditable in git history
Schema Compatibility
Suppression fields are backward compatible:
- Optional fields with
skip_serializing_if = "Option::is_none" - Old snapshots work with new code (field is
None) - New snapshots work with old code (field is ignored)
- No schema version bump required
Examples in Different Contexts
CI/CD Integration
# .github/workflows/complexity.yml
- name: Check complexity
run: |
hotspots analyze . --mode delta --policies --format json > delta.json
# Exit code 1 if any blocking policies failed
# Suppressed functions won't cause failuresDelta Mode
When comparing commits, suppression status comes from the current version:
// Commit A
function foo() { } // Not suppressed
// Commit B
// hotspots-ignore: newly suppressed
function foo() { } // Now suppressed - won't trigger policiesRefactoring Workflow
# 1. Suppress complex function before refactor
# Add: // hotspots-ignore: refactoring in progress
# 2. Refactor the function
# ... make changes ...
# 3. Remove suppression comment
# Function now subject to policies againTroubleshooting
Suppression Not Working
Check:
- Comment is immediately before function (no blank lines)
- Format is correct:
// hotspots-ignore: reason - Running in delta mode with
--policiesflag - Verify in JSON output:
suppression_reasonfield present
Warning About Missing Reason
Fix:
// Before (warning)
// hotspots-ignore:
function foo() { }
// After (no warning)
// hotspots-ignore: legacy code, refactor planned
function foo() { }Suppression Applies to Wrong Function
Cause: Comment on wrong line or blank line in between
Fix:
// Wrong
// hotspots-ignore: reason
function foo() { } // Suppression not applied
// Correct
// hotspots-ignore: reason
function foo() { } // Suppression applied