Repository navigation
Triage Error Prone ReferenceEquality and numeric boxing/narrowing warnings - #3601
Conversation
…nings ReferenceEquality (4): all intentional, suppressed with justification - memoized-supplier identity checks in a test, JNA's own singleton TypeMapper comparison idiom, and a Swing component-identity check. BoxingComparator (8): Comparator.comparing(...) boxing an int/long key extractor; switched to comparingInt/comparingLong. NarrowCalculation (9): products of small, OS-bounded int quantities (fd counts, process counts, tiny struct-offset constants) that can't realistically overflow; suppressed with the bound documented. LongDoubleConversion (5) and IntLiteralCast (3): missing explicit casts on long-to-double widening and int-literal-to-long casts; made explicit or replaced with a typed literal, no behavior change. UnnecessaryLongToIntConversion (4): removed pointless (int) casts on long values immediately passed to a long-typed parameter. IntLongMath (1): MacOSProcessJNA computed pti_faults - pti_pageins in int arithmetic before widening to the long minorFaults field. Its FFM twin already avoids this by subtracting from the already-long majorFaults field instead of the raw int; changed JNA to match rather than suppress, since it removes the pattern entirely.
|
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 (18)
📜 Recent review details⏰ Context from checks skipped due to timeout. (7)
🧰 Additional context used📓 Path-based instructions (6)**/*.{java,properties}📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-core-ffm/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*Test.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-common/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
oshi-core/src/test/java/**/*.java📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (28)📓 Common learnings📚 Learning: 2026-04-17T23:43:35.860ZApplied to files:
📚 Learning: 2026-05-18T23:38:59.650ZApplied to files:
📚 Learning: 2026-08-02T23:56:23.866ZApplied 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-07-26T23:06:49.011ZApplied to files:
📚 Learning: 2026-08-12T22:15:37.668ZApplied to files:
📚 Learning: 2026-08-12T22:15:37.668ZApplied to files:
📚 Learning: 2026-04-18T03:18:06.205ZApplied to files:
📚 Learning: 2026-04-19T01:28:47.155ZApplied to files:
📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
📚 Learning: 2026-07-28T18:20:41.673ZApplied to files:
📚 Learning: 2026-04-03T02:07:49.467ZApplied to files:
📚 Learning: 2026-05-31T04:49:19.668ZApplied to files:
📚 Learning: 2026-04-15T04:56:18.352ZApplied to files:
📚 Learning: 2026-04-20T03:07:05.660ZApplied to files:
📚 Learning: 2026-04-06T04:45:47.644ZApplied to files:
📚 Learning: 2026-04-12T19:34:59.050ZApplied to files:
📚 Learning: 2026-04-03T18:44:48.200ZApplied to files:
📚 Learning: 2026-04-10T22:44:36.786ZApplied to files:
📚 Learning: 2026-04-03T18:43:51.290ZApplied to files:
📚 Learning: 2026-04-18T22:53:56.149ZApplied to files:
📚 Learning: 2026-04-08T00:58:07.212ZApplied to files:
📚 Learning: 2026-06-12T16:33:11.703ZApplied to files:
📚 Learning: 2026-05-04T04:58:36.843ZApplied to files:
📚 Learning: 2026-03-29T20:01:06.452ZApplied to files:
🔇 Additional comments (18)
📝 WalkthroughWalkthroughThe changes standardize comparator typing, document intentional narrowing and reference comparisons, remove redundant casts, adjust CPU tick assertions, correct minor-fault calculation, preserve long buffer sizes, and make demo dataset conversions explicit. ChangesNumeric and warning cleanup
Estimated code review effort: 2 (Simple) | ~15 minutes Mergeability Score: ⚪ Minimal · up to This PR makes localized warning-cleanup and minor performance-oriented code changes with no reported behavior regressions; it is merge-ready after normal checks and review, with no actionable merge-blocking risk remaining. 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 #3601 +/- ##
============================================
- Coverage 79.84% 79.80% -0.05%
- Complexity 3872 4231 +359
============================================
Files 710 710
Lines 24254 24254
Branches 4057 4057
============================================
- Hits 19366 19355 -11
- Misses 2724 2733 +9
- Partials 2164 2166 +2
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
Per-category breakdown:
Setinstance. One isW32APITypeMapper.DEFAULT == W32APITypeMapper.UNICODEinWindowsPowerSourceJNA— confirmed against JNA's own source thatDEFAULTis a direct reference to one of theUNICODE/ASCIIsingleton constants, so==is exactly JNA's documented idiom. One is a SwingComponentidentity check in the demo GUI (contentPane.getComponent(0) != panel) — checking whether this exact panel instance is already displayed, not a value comparison.Comparator.comparing(...)with anint/long-returning key extractor was boxing unnecessarily on every comparison. Switched tocomparingInt/comparingLonginLspv,AbstractCentralProcessor.orderedProcCaches, and bothLogicalProcessorInformation/LogicalProcessorInformationFFMtwins.CP_USER * UINT64_SIZEwhere both operands are ≤8) that cannot realistically approachintoverflow. Suppressed with the specific bound documented at each site rather than guessed at generically.long→doublewidening (test tolerance comparisons, demo GUI chart values) andint-literal-cast-to-longin a test; made the cast explicit or replaced with a typed literal (0Linstead of(long) 0). No behavior change.(int)casts onlongvalues immediately passed to along-typed parameter (MemorySegment.get's offset,Arena.allocate's size) — the narrowing served no purpose and the widen-back was implicit anyway.MacOSProcessJNA.updateAttributescomputedpti_faults - pti_pageinsinintarithmetic (both are nativeint32_tstruct fields) before assigning to thelong minorFaultsfield. Its FFM twin already avoids this shape by subtracting fromthis.majorFaults(alreadylong) instead of re-reading the rawintfield — changed JNA to match, which removes the pattern entirely rather than suppressing it.Test plan
./mvnw clean install -Perror-prone -DskipTests: 0 ERROR;ReferenceEquality/BoxingComparator/NarrowCalculation/LongDoubleConversion/UnnecessaryLongToIntConversion/IntLiteralCast/IntLongMathall → 0./mvnw -pl oshi-common,oshi-core,oshi-core-ffm -am test: 0 tests failed./mvnw checkstyle:check,forbiddenapis:check,clean compile javadoc:javadoc: all passSummary by CodeRabbit
Bug Fixes
Improvements