Commit ecc224b
authored
phase a/fixups spotbugs (#43)
* build(spotbugs): add exclude filter for generated parsers and known noise rules
Reduces SpotBugs findings 1,492 -> 51 (96.6%) by excluding:
- ANTLR-generated parser/lexer/listener/visitor classes (regenerated from .g4)
- NM_METHOD_NAMING_CONVENTION (noise from generated code and ANTLR hooks)
- SF_SWITCH_NO_DEFAULT (stylistic; SF_SWITCH_FALLTHROUGH still enforced)
- EI_EXPOSE_REP / EI_EXPOSE_REP2 (internal DTOs, no trust boundary crossed)
- MS_PKGPROTECT / MS_FINAL_PKGPROTECT (no same-package attacker model)
Each exclusion carries a rationale comment in spotbugs-exclude.xml.
* fix(spotbugs): address 4 priority-1 findings in core code
- Analyzer.getGitHead: decode `git rev-parse HEAD` bytes as UTF-8
instead of platform default (DM_DEFAULT_ENCODING).
- IndexCommand.call: narrow the cache-delete catch from blanket
`Exception ignored` to `IOException` with a debug log line so
silent data-loss is traceable (DE_MIGHT_IGNORE).
- PluginsCommand.categoryDescription: remove dead `Set<String>
frameworks` local that was assigned and never read
(DLS_DEAD_LOCAL_STORE).
- AntlrParserFactory.parse: replace identity-compare (`==`) of cache
key with `.equals()`; cache behavior is unchanged because the
parse tree is a deterministic function of content, so equal
content yields an equivalent tree (ES_COMPARING_PARAMETER_STRING_WITH_EQ).
Verified `mvn compile` clean on phase-a/fixups-spotbugs.
* fix(spotbugs): concurrency and correctness priority-2 findings
- AnalysisCache.removeFile: guarantee rwLock.writeLock().unlock() on all
exception paths by wrapping the finally's conn.setAutoCommit(true) in its
own try-finally. Previously, a non-SQLException thrown by setAutoCommit
(RuntimeException/Error) would escape the finally block before unlock ran,
leaking the write lock. (UL_UNRELEASED_LOCK_EXCEPTION_PATH)
Note: the same setAutoCommit-in-finally-then-unlock pattern appears in two
other methods in this class; SpotBugs only flagged removeFile, but they
likely share the same risk. Out of scope for this PR; file a follow-up.
- CodeIqApplication.main: collapse three identical else-if branches (isIndex /
isEnrich / default) into one else with a combined rationale comment.
(DB_DUPLICATE_BRANCHES)
- BundleCommand: remove unused private 4-arg writeEntry(zos, name, content,
lineEnding) that delegated to the 3-arg overload and silently discarded
lineEnding. (UPM_UNCALLED_PRIVATE_METHOD)
- PluginsCommand.SuggestSubcommand: iterate languageCounts.entrySet() instead
of keySet() + get(). (WMI_WRONG_MAP_ITERATOR)
- GitLabCiDetector.detect: iterate data.entrySet() instead of keySet() + get().
(WMI_WRONG_MAP_ITERATOR)
- CSharpPreprocessorParserBase: replace reference-compare (== / !=) on
expression values with Objects.equals(). The compared values are String
literals 'true'/'false' produced by sibling methods, so logical equality is
the intended semantic; using == only worked coincidentally via string
interning. (ES_COMPARING_STRINGS_WITH_EQ x2)
- VersionCommand.resolveVersion: narrow the outer catch from Exception to
IOException since that is the only checked exception props.load can throw.
Updated comment to document that the branch is an intentional fallthrough
to the manifest-based lookup. (REC_CATCH_EXCEPTION)
Verified mvn compile clean.
* build(spotbugs): narrow-suppress 2 parser-base RCN + 1 BX finding, record triage result
Added narrow exclude rules (class + pattern pair, not global) for:
- RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE in CSharpParserBase and
GoParserBase — hand-written ANTLR parser support classes carried over
from antlr/grammars-v4. Defensive null checks are harmless; touching
them risks divergence if we re-sync upstream.
- BX_UNBOXING_IMMEDIATELY_REBOXED in CSharpPreprocessorParserBase —
same origin, micro-perf, not correctness.
Updated BASELINE.md to mark the SpotBugs gap as RESOLVED with final
counts (1,492 -> 38; priority-1: 8 -> 0) and a pointer to the
post-triage summary JSON.
* fix(cache): extend nested-try-finally lock release to remaining AnalysisCache methods
Follow-up to 798bccf. That commit fixed UL_UNRELEASED_LOCK_EXCEPTION_PATH
in AnalysisCache.removeFile and flagged the same lock-leak pattern in
two other methods that SpotBugs did not surface (likely because they
differ subtly in what's inside the outer try body).
Both methods — storeResults (the INSERT nodes/edges path) and the
replace-with-enriched-data path — had:
} finally {
try { conn.setAutoCommit(true); } catch (SQLException ignored) {}
rwLock.writeLock().unlock();
}
If conn.setAutoCommit(true) throws anything other than SQLException
(RuntimeException or Error), execution exits the finally before
rwLock.writeLock().unlock() runs, leaving the write lock held and
freezing all subsequent cache writers.
Wrap setAutoCommit in a nested try-finally so unlock is always reached:
} finally {
try {
try { conn.setAutoCommit(true); } catch (SQLException ignored) {}
} finally {
rwLock.writeLock().unlock();
}
}
All three lock-holding paths (removeFile, storeResults, replace-with-
enriched) now share the same exception-safe pattern. mvn test -Dtest=
AnalysisCacheTest passes.1 parent caabd1d commit ecc224b
13 files changed
Lines changed: 152 additions & 37 deletions
File tree
- docs/superpowers/baselines/2026-04-17
- src/main/java/io/github/randomcodespace/iq
- analyzer
- cache
- cli
- detector/config
- grammar
- csharp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
326 | 329 | | |
327 | 330 | | |
328 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
Lines changed: 4 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
108 | 104 | | |
109 | | - | |
110 | 105 | | |
111 | 106 | | |
112 | 107 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
1608 | 1609 | | |
1609 | 1610 | | |
1610 | 1611 | | |
1611 | | - | |
| 1612 | + | |
1612 | 1613 | | |
1613 | 1614 | | |
1614 | 1615 | | |
| |||
Lines changed: 27 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
376 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
377 | 384 | | |
378 | | - | |
379 | 385 | | |
380 | 386 | | |
381 | 387 | | |
| |||
453 | 459 | | |
454 | 460 | | |
455 | 461 | | |
456 | | - | |
457 | | - | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
458 | 471 | | |
459 | | - | |
460 | 472 | | |
461 | 473 | | |
462 | 474 | | |
| |||
599 | 611 | | |
600 | 612 | | |
601 | 613 | | |
602 | | - | |
603 | | - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
604 | 623 | | |
605 | | - | |
606 | 624 | | |
607 | 625 | | |
608 | 626 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | 467 | | |
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
88 | 89 | | |
89 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
90 | 97 | | |
91 | 98 | | |
92 | 99 | | |
| |||
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
105 | 103 | | |
106 | 104 | | |
107 | 105 | | |
| |||
406 | 404 | | |
407 | 405 | | |
408 | 406 | | |
409 | | - | |
410 | | - | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
411 | 410 | | |
412 | 411 | | |
413 | 412 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
| 41 | + | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
0 commit comments