Commit a8ef6b6
committed
fix(np-null): eliminate all 26 NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE findings
All 26 SpotBugs NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE findings shared
the same shape: calling `.toString()` on `Path.getFileName()` (or once
on `Path.getParent()`) where the result can legitimately be null for
root-like paths (e.g. `/`, a bare filename with no parent).
Uniform fix: wrap every `path.getFileName().toString()` with
`java.util.Objects.toString(path.getFileName(), fallback)`, choosing a
sensible per-site fallback:
- `""` where the string is then substring-matched against a known
set (filenames, extensions, excluded-dir names); empty never
matches those sets, preserving existing semantics.
- `"unknown"` for human-facing project names in TopologyCommand,
EnrichCommand service detection, StatsCommand output header.
- `"bundle"` for BundleCommand's project-name derivation.
- `"flow"` for FlowCommand's html project name.
- `PROP_ROOT` (existing constant) in Analyzer.
One non-`getFileName` case: AnalysisCache's constructor called
`Files.createDirectories(dbPath.getParent())` unconditionally; rewrote
as a null-guarded block so a bare-filename dbPath (no directory
component) doesn't NPE.
Files touched (12):
analyzer/Analyzer.java (5 edits — incl. 1 replace_all
that covered 3 triplicated blocks
in analyzeFileWithRegistry /
analyzeFile / createInventoryNode)
analyzer/ConfigScanner.java (1)
analyzer/FileClassifier.java (1)
analyzer/FileDiscovery.java (2)
analyzer/ServiceDetector.java (3)
cache/AnalysisCache.java (1 — getParent null-guard)
cli/BundleCommand.java (1)
cli/EnrichCommand.java (2)
cli/FlowCommand.java (1)
cli/PluginsCommand.java (2)
cli/StatsCommand.java (1)
cli/TopologyCommand.java (1)
Verified:
- `mvn compile` clean.
- `mvn spotbugs:spotbugs` re-run: NP_NULL count 26 -> 0.
- `mvn test` (full suite): 3,059 tests, 0 failures, 0 errors.
No behavior change for the common case: for any non-root path,
`path.getFileName() != null` and Objects.toString returns the same
value as the old `.toString()`. The fallback string is only observed
if callers hand in a root-like path — previously an NPE, now a safe
sentinel that flows through existing logic.1 parent ecc224b commit a8ef6b6
13 files changed
Lines changed: 45 additions & 28 deletions
File tree
- docs/superpowers/baselines/2026-04-17
- src/main/java/io/github/randomcodespace/iq
- analyzer
- cache
- cli
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| 234 | + | |
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
| |||
Lines changed: 15 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
| 363 | + | |
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| |||
885 | 885 | | |
886 | 886 | | |
887 | 887 | | |
| 888 | + | |
888 | 889 | | |
889 | | - | |
| 890 | + | |
890 | 891 | | |
891 | | - | |
| 892 | + | |
892 | 893 | | |
893 | 894 | | |
894 | 895 | | |
| |||
1130 | 1131 | | |
1131 | 1132 | | |
1132 | 1133 | | |
1133 | | - | |
| 1134 | + | |
1134 | 1135 | | |
1135 | 1136 | | |
1136 | 1137 | | |
| |||
1235 | 1236 | | |
1236 | 1237 | | |
1237 | 1238 | | |
| 1239 | + | |
1238 | 1240 | | |
1239 | | - | |
| 1241 | + | |
1240 | 1242 | | |
1241 | | - | |
| 1243 | + | |
1242 | 1244 | | |
1243 | 1245 | | |
1244 | 1246 | | |
| |||
1351 | 1353 | | |
1352 | 1354 | | |
1353 | 1355 | | |
1354 | | - | |
| 1356 | + | |
1355 | 1357 | | |
1356 | 1358 | | |
1357 | 1359 | | |
| |||
1434 | 1436 | | |
1435 | 1437 | | |
1436 | 1438 | | |
| 1439 | + | |
1437 | 1440 | | |
1438 | | - | |
| 1441 | + | |
1439 | 1442 | | |
1440 | | - | |
| 1443 | + | |
1441 | 1444 | | |
1442 | 1445 | | |
1443 | 1446 | | |
| |||
1520 | 1523 | | |
1521 | 1524 | | |
1522 | 1525 | | |
| 1526 | + | |
1523 | 1527 | | |
1524 | | - | |
| 1528 | + | |
1525 | 1529 | | |
1526 | | - | |
| 1530 | + | |
1527 | 1531 | | |
1528 | 1532 | | |
1529 | 1533 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
| 189 | + | |
189 | 190 | | |
190 | 191 | | |
191 | 192 | | |
| |||
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
246 | | - | |
| 247 | + | |
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
346 | | - | |
| 346 | + | |
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
| 355 | + | |
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
130 | 135 | | |
131 | 136 | | |
132 | 137 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
| |||
180 | 184 | | |
181 | 185 | | |
182 | 186 | | |
183 | | - | |
| 187 | + | |
184 | 188 | | |
185 | 189 | | |
186 | 190 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
0 commit comments