UNPKG

pi-lens

Version:

Real-time code feedback for pi — LSP, linters, formatters, type-checking, structural analysis & booboo

59 lines (47 loc) • 1.09 kB
# Infinite Loop # Detects potentially infinite while(true) loops without break id: infinite-loop-java name: Loops Should Not Be Infinite severity: error category: reliability defect_class: correctness inline_tier: blocking language: java message: "Loop appears to be infinite with no break condition" description: | while(true) or for(;;) without a break condition creates an infinite loop. Ensure there's an exit condition with break, return, or System.exit(). ✅ FIX: Add break condition or use scheduled executor ```java while (running) { // GOOD - control flag if (shouldStop()) break; } ``` query: | (while_statement condition: (condition (true) @COND) body: (block) @BODY) (for_statement !condition (block) @BODY) metavars: - COND - BODY post_filter: no_break_or_return tags: - reliability - java - cert - bugs examples: bad: | while (true) { // BAD - infinite doWork(); } good: | while (true) { // GOOD - has exit if (shouldStop()) break; doWork(); } has_fix: false