Repository navigation
Extract testable inode parsers from Unix FileSystem classes - #3499
Conversation
Extract the df/df-g inode-parsing loops from all five Unix FileSystem implementations into package-private static methods returning Pair<Map, Map>. Also extract the FreeBSD `geom part list` UUID parser. These are the pure text-to-data portions of getFileStores — the mount- table iteration that interacts with File and config filtering remains in the caller. Extractions: - FreeBsdFileSystem: parseGeomPartList (geom part list → UUID map), parseDfInodes (df -i → free/total maps keyed by mount point) - NetBsdFileSystem: parseDfInodes (df -i → free/used maps keyed by volume) - OpenBsdFileSystem: parseDfInodes (df -i → free/used maps keyed by volume) - AixFileSystem: parseDfInodes (df -F %n %l → free/total maps keyed by filesystem, regex-filtered) - SolarisFileSystem: parseDfgInodes (df -g multi-line stateful → free/total maps keyed by mount path)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (4)
📜 Recent review details⏰ Context from checks skipped due to timeout. (13)
🔇 Additional comments (2)
📝 WalkthroughWalkthroughRefactors AIX, FreeBSD, NetBSD, OpenBSD, and Solaris command-output parsing into reusable helpers returning inode maps, with FreeBSD also extracting partition UUID parsing. Adds unit tests for typical and edge-case inputs. ChangesUnix filesystem parser refactoring
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3499 +/- ##
============================================
- Coverage 76.24% 76.19% -0.05%
Complexity 76 76
============================================
Files 591 591
Lines 21679 21693 +14
Branches 3611 3611
============================================
+ Hits 16529 16530 +1
- Misses 3207 3210 +3
- Partials 1943 1953 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java (1)
55-57: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueCorrect typographical error in variable name.
Both files share a typographical error where the variable is named
inodeUsedlMapwith an extral.
oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java#L55-L57: renameinodeUsedlMaptoinodeUsedMap.oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java#L98-L100: renameinodeUsedlMaptoinodeUsedMap.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java` around lines 55 - 57, Rename the inode usage map variable from inodeUsedlMap to inodeUsedMap in NetBsdFileSystem.java lines 55-57 and OpenBsdFileSystem.java lines 98-100, updating all references within each affected method.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@oshi-common/src/main/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystem.java`:
- Around line 160-170: Update parseDfInodes in FreeBsdFileSystem.java (160-170),
NetBsdFileSystem.java (141-147), and OpenBsdFileSystem.java (67-73) to stop
requiring df -i filesystem fields to start with “/”; instead skip the header
explicitly or rely on sufficient parsed fields before reading inode values.
Preserve mount-point mapping while including ZFS, mfs, tmpfs, and other
non-device filesystems.
In
`@oshi-common/src/test/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystemTest.java`:
- Around line 65-74: Update FreeBsdFileSystem.parseDfInodes to skip only the df
header while parsing valid entries regardless of whether the filesystem name
starts with “/”, including devfs, zroot, and tmpfs. Revise
testParseDfInodesSkipsHeaderAndNonSlash to assert the expected inode and
free-inode mappings for devfs, while retaining verification that the header is
ignored.
In
`@oshi-common/src/test/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystemTest.java`:
- Around line 46-55: Update testParseDfInodesSkipsNonDeviceLines and its
expectations to reflect that valid mfs/tmpfs entries are parsed even when their
filesystem field does not start with '/'. Add representative valid filesystem
input and assert the corresponding inode statistics are present, while retaining
the header-skipping coverage.
---
Nitpick comments:
In
`@oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java`:
- Around line 55-57: Rename the inode usage map variable from inodeUsedlMap to
inodeUsedMap in NetBsdFileSystem.java lines 55-57 and OpenBsdFileSystem.java
lines 98-100, updating all references within each affected method.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: de45bf5d-f626-4612-88a5-e14cf7a134a9
📒 Files selected for processing (11)
oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.javaoshi-common/src/test/java/module-info.testoshi-common/src/test/java/oshi/software/common/os/unix/aix/AixFileSystemTest.javaoshi-common/src/test/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystemTest.javaoshi-common/src/test/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystemTest.javaoshi-common/src/test/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystemTest.javaoshi-common/src/test/java/oshi/software/common/os/unix/solaris/SolarisFileSystemTest.java
📜 Review details
⏰ Context from checks skipped due to timeout. (12)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Analyze (java)
- GitHub Check: Test JDK 26, windows-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 26, macos-latest
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
- GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
- GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.
Applied to files:
oshi-common/src/main/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.
Applied to files:
oshi-common/src/main/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.javaoshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
🔇 Additional comments (9)
oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java (1)
116-118: Correct typographical error in variable name.(Follow-up to the typo in the variable declaration.)
oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java (1)
147-149: Correct typographical error in variable name.(Follow-up to the typo in the variable declaration.)
oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java (1)
22-22: LGTM!Also applies to: 57-62, 137-174
oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java (1)
21-21: LGTM!Also applies to: 58-63, 119-154
oshi-common/src/main/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystem.java (1)
1-4: It emits the per-file comment for file 4 and 5, but wait, the example'sconsolidated_commentssection says:
<!-- review_comment_start ~ line_ranges: coderabbit_concurrency.py#L4-L7, coderabbit_consumer.py#L1-L4, coderabbit_worker.py#L1-L4 -->
Wait, does the tool filter out the per-site comments if they are in the consolidated block? Yes, the prompt says "each replacing the prior per-site comment at that exact file+range". This means I emit the per-site comment normally, and then the consolidated block replaces them during processing.
So I will emit the per-site comment now forFreeBsdFileSystem.
[scratchpad_end] -->oshi-common/src/test/java/module-info.test (1)
69-70: LGTM!oshi-common/src/test/java/oshi/software/common/os/unix/aix/AixFileSystemTest.java (1)
21-70: LGTM!oshi-common/src/test/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystemTest.java (1)
21-57: LGTM!oshi-common/src/test/java/oshi/software/common/os/unix/solaris/SolarisFileSystemTest.java (1)
21-65: LGTM!
The parseDfInodes methods in FreeBSD, NetBSD, and OpenBSD filtered lines
by startsWith("/"), which excluded ZFS pools, tmpfs, devfs, and mfs
entries that don't begin with a slash. Replace with a header-skip check
(!startsWith("Filesystem")) so all valid df output lines are parsed.
Also fix the inodeUsedlMap typo in NetBSD and OpenBSD (→ inodeUsedMap).
Summary
Pair<Map, Map>geom part listUUID parsergetFileStores— the mount-table iteration that interacts withFileand config filtering remains in the callerTest plan
./mvnw clean install— 1215 tests, 0 failures)@EnabledOnOsgating on parse tests — they run on every platformSummary by CodeRabbit
/(e.g., ZFS, tmpfs, devfs, mfs).