Repository navigation
Triage Error Prone EnumOrdinal warnings - #3598
Conversation
AixCentralProcessor's ticksFromRow used TickType.ordinal() where the existing TickType.getIndex() is the intended stable index. Fixed. The rest are self-contained lookup tables or documented native-order contracts (PlatformEnum matching JNA's Platform.getOSType(), PDH property enums' first-element-is-instance-filter convention, cache Type sort weighting) where declaration order is intentional; suppressed with a comment explaining why. Also fixed a latent bug found along the way: LogicalProcessorInformation (JNA) indexed ProcessorCache.Type by a raw native cache-type int with no bounds check, unlike its FFM twin which already guards it with a fallback to UNIFIED.
|
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 (10)
📜 Recent review details⏰ Context from checks skipped due to timeout. (11)
🧰 Additional context used📓 Path-based instructions (9)oshi-common/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{java,md}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{java,xml}📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-core/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-core-ffm/src/main/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/src/test/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/src/test/java/**/*Test.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (27)📓 Common learnings📚 Learning: 2026-07-28T18:20:41.673ZApplied to files:
📚 Learning: 2026-07-26T23:06:49.011ZApplied to files:
📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
📚 Learning: 2026-07-06T19:25:59.225ZApplied to files:
📚 Learning: 2026-07-30T00:35:22.638ZApplied to files:
📚 Learning: 2026-08-03T00:46:14.953ZApplied to files:
📚 Learning: 2026-04-12T19:34:56.879ZApplied to files:
📚 Learning: 2026-04-03T18:44:48.200ZApplied to files:
📚 Learning: 2026-08-05T23:44:09.936ZApplied to files:
📚 Learning: 2026-03-29T20:01:06.452ZApplied to files:
📚 Learning: 2026-04-06T04:45:51.516ZApplied to files:
📚 Learning: 2026-04-18T22:53:56.149ZApplied to files:
📚 Learning: 2026-04-12T19:34:59.050ZApplied to files:
📚 Learning: 2026-04-17T23:56:46.416ZApplied to files:
📚 Learning: 2026-04-17T23:43:35.860ZApplied to files:
📚 Learning: 2026-04-19T01:28:47.155ZApplied to files:
📚 Learning: 2026-03-29T20:03:00.830ZApplied to files:
📚 Learning: 2026-04-18T03:18:06.205ZApplied to files:
📚 Learning: 2026-04-18T23:21:43.993ZApplied to files:
📚 Learning: 2026-08-02T23:56:23.866ZApplied to files:
📚 Learning: 2026-04-10T22:44:36.786ZApplied to files:
📚 Learning: 2026-05-04T04:58:36.843ZApplied to files:
📚 Learning: 2026-05-31T04:49:19.668ZApplied to files:
📚 Learning: 2026-06-26T09:54:54.556ZApplied to files:
📚 Learning: 2026-04-05T05:40:45.797ZApplied to files:
📚 Learning: 2026-04-05T05:39:21.126ZApplied to files:
🔇 Additional comments (10)
📝 WalkthroughWalkthroughThe changes document intentional enum ordinal usage, replace AIX ordinal lookups with explicit indexes, centralize Linux lookup-table construction, and add fallback handling for invalid Windows cache type values. ChangesOrdinal indexing and cache validation
Estimated code review effort: 2 (Simple) | ~10 minutes Mergeability Score: ⚪ Minimal · up to The changes address enum-index warnings and add a defensive native-value fallback, with the listed validation checks passing; no actionable merge-blocking risk remains beyond normal checks and review. Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 #3598 +/- ##
============================================
- Coverage 79.90% 79.81% -0.09%
+ Complexity 3864 217 -3647
============================================
Files 710 710
Lines 24249 24256 +7
Branches 4056 4057 +1
============================================
- Hits 19376 19361 -15
- Misses 2715 2734 +19
- Partials 2158 2161 +3
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
AixCentralProcessor.ticksFromRowusedTickType.ordinal()whereTickType.getIndex()(already used everywhere else, e.g.CpuStat) is the intended stable index — real fix, no behavior change since the values are currently identical by construction.EnumOrdinalfindings are self-contained lookup tables (UdevStat,ProcPidStat,ThreadPidStat— private enums whose ordinal only indexes a same-sized array built by the same class) or documented native-order contracts (PlatformEnum's declaration order matching JNA'sPlatform.getOSType(),PdhCounterWildcardProperty's "first enum element is the instance filter" contract,ProcessorCache.Type's declaration-order sort weight). Suppressed with@SuppressWarnings("EnumOrdinal")plus a one-line comment explaining why, scoped to the narrowest enclosing method (two static-initializer sites were refactored into small private builder methods since a static block can't itself carry an annotation).LogicalProcessorInformation(JNA) indexedProcessorCache.TypewithType.values()[cache.type]and no bounds check, so an unexpected native cache-type value would throwArrayIndexOutOfBoundsException. Its FFM twin already guards this with a bounds check +UNIFIEDfallback; brought JNA in line with it.Test plan
./mvnw clean install -Perror-prone -DskipTests: 0 ERROR,EnumOrdinalfindings 39 → 0, total WARNING count 223 → 184 (matches)./mvnw -pl oshi-common,oshi-core,oshi-core-ffm -am test: 0 tests failed./mvnw checkstyle:check,forbiddenapis:check,javadoc:javadoc: all passSummary by CodeRabbit
Bug Fixes
Refactor
Documentation