Repository navigation
Fix remaining Error Prone findings: API-shape + mechanical cleanup - #3604
Conversation
API-shape findings (NonApiType, InvalidParam, EffectivelyPrivate, ImmutableEnumChecker) - verified none touch @publicapi or the oshi.hardware/oshi.software.os semver surface before fixing: - WindowsFileSystemJNA/FFM.getLocalVolumes: package-private, return List instead of ArrayList. - LinuxOSProcess/LinuxOSThread: dropped the pointless `public` on a method of a private nested enum. - AbstractCentralProcessor.CpuidFeature.names: String[] -> unmodifiable List; LinuxHWDiskStore.UdevStat.order: added missing final. - LibKstatFunctions/IOReport javadoc: suppressed InvalidParam - "name"/ "null" in the doc text is unrelated to the similarly-spelled parameter it was flagged against. Mechanical cleanup (StatementSwitchToExpressionSwitch, UnnecessaryLambda, UnnecessaryParentheses, AssignmentExpression, UnusedVariable): - Converted 6 statement switches to arrow-style switch statements/expressions (oshi-core-ffm, Java 25). - Replaced 5 lambdas stored in test constants/returned from helper methods with method references to a directly-implemented method. - WhoJNA's assignment-in-while-condition is the standard "loop while getutxent() returns non-null" idiom; suppressed rather than changed. - Removed a redundant parenthesized subexpression, a dead initial value that was unconditionally overwritten before any read, and an orphaned test field that was assigned but never read anywhere. - OperatingSystemTest's descendantNotLessThanChild dead initializer: moved the declaration to where it's actually first used; traced all three call sites to confirm this isn't a missing assertion. - DiskMetrics.diskStores was already correctly explained as an intentional GC anchor, but only suppressed Sonar's rule id, not Error Prone's; added the missing key.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (22)
💤 Files with no reviewable changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (9)
🧰 Additional context used📓 Path-based instructions (6)**/*.{java,properties}📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-common/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*Test.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-core-ffm/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-core/src/test/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (29)📓 Common learnings📚 Learning: 2026-04-05T05:40:45.797ZApplied to files:
📚 Learning: 2026-04-06T04:45:51.516ZApplied to files:
📚 Learning: 2026-07-30T00:35:22.638ZApplied to files:
📚 Learning: 2026-04-05T05:39:21.126ZApplied to files:
📚 Learning: 2026-06-26T05:09:03.075ZApplied to files:
📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
📚 Learning: 2026-07-06T19:25:59.225ZApplied to files:
📚 Learning: 2026-08-03T00:46:14.953ZApplied to files:
📚 Learning: 2026-05-31T04:49:19.668ZApplied to files:
📚 Learning: 2026-07-26T23:06:49.011ZApplied to files:
📚 Learning: 2026-05-04T04:58:36.843ZApplied to files:
📚 Learning: 2026-08-02T23:56:23.866ZApplied to files:
📚 Learning: 2026-04-18T22:53:56.149ZApplied to files:
📚 Learning: 2026-03-29T20:03:00.830ZApplied to files:
📚 Learning: 2026-08-12T22:15:37.668ZApplied to files:
📚 Learning: 2026-04-18T23:21:43.993ZApplied to files:
📚 Learning: 2026-04-19T01:28:47.155ZApplied to files:
📚 Learning: 2026-04-03T02:07:49.467ZApplied to files:
📚 Learning: 2026-04-10T22:44:36.786ZApplied to files:
📚 Learning: 2026-04-08T00:58:10.736ZApplied to files:
📚 Learning: 2026-04-06T04:45:47.644ZApplied to files:
📚 Learning: 2026-03-29T20:01:06.452ZApplied to files:
📚 Learning: 2026-04-03T18:44:48.200ZApplied to files:
📚 Learning: 2026-07-28T18:20:41.673ZApplied to files:
📚 Learning: 2026-04-12T19:34:59.050ZApplied to files:
📚 Learning: 2026-04-15T04:56:18.352ZApplied to files:
📚 Learning: 2026-04-18T03:18:06.205ZApplied to files:
📚 Learning: 2026-04-11T05:51:52.684ZApplied to files:
🔇 Additional comments (21)
📝 WalkthroughWalkthroughThis pull request applies behavior-preserving Java cleanup across OSHI modules. It modernizes switch syntax, narrows visibility and collection types, documents native interop suppressions, and updates test helpers and formatting. ChangesJava modernization and cleanup
Estimated code review effort: 2 (Simple) | ~15 minutes Mergeability Score: ⚪ Minimal · up to This PR makes localized API-shape and mechanical cleanup changes, with the reported validation checks passing; no actionable merge-blocking risk remains beyond normal review. 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 #3604 +/- ##
============================================
+ Coverage 79.89% 79.90% +0.01%
- Complexity 76 4240 +4164
============================================
Files 710 710
Lines 24255 24242 -13
Branches 4057 4057
============================================
- Hits 19378 19371 -7
+ Misses 2720 2714 -6
Partials 2157 2157
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:
|
Summary
Combines two lower-risk tail groups per triage discussion on #3600-3603: API-shape findings that only look like public API (verified none touch
@PublicApior theoshi.hardware/oshi.software.ossemver surface), plus purely mechanical syntax modernization.API-shape (
NonApiType,InvalidParam,EffectivelyPrivate,ImmutableEnumChecker) — checked each site's actual visibility before fixing:WindowsFileSystemJNA/WindowsFileSystemFFM'sgetLocalVolumes: package-private (not even accessible outside the package), returnsArrayListwhere onlyListinterface methods are ever used on the result — narrowed toList.LinuxOSProcess/LinuxOSThread:public int getOrder()on aprivatenested enum — thepublicmodifier is a no-op since the enum itself can't be referenced outside the enclosing class. Dropped it.AbstractCentralProcessor.CpuidFeature.names:String[]→Collections.unmodifiableList(Arrays.asList(...)), suppressed the one further warning aboutListnot being a nominally-immutable type (no Guava dependency to satisfy that literally).LinuxHWDiskStore.UdevStat.order: added the missingfinal— assigned once, in the constructor, never reassigned.LibKstatFunctions/IOReportjavadoc: suppressed —{@code name}/{@code null}in the doc text refer to a native struct field name and a value-to-pass respectively, unrelated to the similarly-spelled parameter (named/null3) the checker flagged them against.Mechanical cleanup (
StatementSwitchToExpressionSwitch,UnnecessaryLambda,UnnecessaryParentheses,AssignmentExpression,UnusedVariable):oshi-core-ffm, Java 25 — no fallthrough existed before, so no behavior change).WhoJNA'swhile (nonNull(ut = LIBC.getutxent()))is the standard C-iterator-style idiom; suppressed rather than restructured.AbstractCentralProcessor), a dead initial value unconditionally overwritten before any read (WmiQueryHandler.initCOM), and a test field assigned in@BeforeAllbut never read anywhere (OshiMetricsTest).OperatingSystemTest.descendantNotLessThanChild: traced all three per-category blocks before touching this — the variable is correctly used and asserted on in two of the three blocks; only its very first initializer (before an unrelated block that never touches it) was dead. Moved the declaration to where it's first actually needed rather than leaving a redundant reset.DiskMetrics.diskStoreswas already correctly documented as an intentional GC anchor (holds a strong reference so Micrometer'sWeakReferencedoesn't get collected), but the existing@SuppressWarningsonly carried Sonar's rule id (java:S1068), not Error Prone's own check name — added it.Test plan
./mvnw clean install -Perror-prone -DskipTests: 0 ERROR; all listed categories → 0./mvnw -pl oshi-common,oshi-core,oshi-core-ffm,oshi-metrics -am test: 0 tests failed./mvnw checkstyle:check,forbiddenapis:check,clean compile javadoc:javadoc: all passSummary by CodeRabbit
Refactor
Tests
Chores