Repository navigation
Sonar cleanup: demo MBean stubs (S1168), deprecations (S1874), duplicated literals (S1192) - #3396
Conversation
These demo MBeanServer/DynamicMBean stubs returned null from interface methods that contractually return collections; return empty collections instead (S1168), which is the correct interface behavior and has no sentinel meaning to preserve. The three deserialize(...) overrides implement deprecated JMX MBeanServer methods; mark them @deprecated (S1874). That's the truthful fix -- the overrides are deprecated-by-inheritance -- and it also silences the javac deprecation warning that suppressing the Sonar rule alone would leave behind.
MacGlobalMemoryJNA.queryPageSize used the deprecated SystemB.host_page_size(int, LongByReference) overload. JNA 5.19 (already on OSHI's classpath) added a non-deprecated host_page_size(int, NativeLongByReference) variant that uses the native-width type for the vm_size_t out-param instead of a fixed 64-bit LongByReference; switch to it via the existing CloseableNativeLongByReference. NetBsdOperatingSystem.getThreadId uses the deprecated Thread.getId(). The replacement Thread.threadId() requires Java 19, but this module compiles to Java 8, so the deprecation can't be removed here; suppress it in code with an explanatory comment.
Hoist the repeated plist XML tags (<string>/</string>/<array>/</array>) in MacInstalledApps and the '0x0000' default PCI id in BsdGraphicsCard into named constants. No behavior change. The remaining S1192 findings (native struct field-name strings, per-platform messages) are left as-is -- a shared constant there would couple unrelated code for no readability gain.
|
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)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
🧰 Additional context used🧠 Learnings (2)📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
📚 Learning: 2026-04-06T04:45:47.644ZApplied to files:
🔇 Additional comments (6)
📝 WalkthroughWalkthroughMultiple small code quality improvements across six files: ChangesCode Quality and Correctness Fixes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 #3396 +/- ##
=========================================
Coverage 75.05% 75.05%
Complexity 76 76
=========================================
Files 579 579
Lines 21355 21356 +1
Branches 3556 3557 +1
=========================================
+ Hits 16028 16029 +1
+ Misses 3301 3300 -1
- Partials 2026 2027 +1
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:
|
Targeted Sonar fixes, one commit per concern. No behavior change to production query results; verified locally with a clean
install -P aggregate-coverage,native-comparison(full unit suite + NativeComparisonTest green — the latter exercises the page-size path on macOS) plus checkstyle/forbiddenapis/javadoc.Fixed
JMXOshiAgentServer/Baseboarddemo MBean stubs returnednullfrom interface methods that contractually return collections; return empty collections instead. No sentinel meaning to preserve.MacGlobalMemoryJNA.queryPageSize→ the non-deprecatedSystemB.host_page_size(int, NativeLongByReference)overload (JNA 5.19, already on the classpath) — native-widthvm_size_tout-param instead of a fixed 64-bitLongByReference.deserialize(...)overrides implement deprecated JMXMBeanServermethods → marked@Deprecated(truthful, and silences the javac warning too).NetBsdOperatingSystem.getThreadIdusesThread.getId(); the replacementThread.threadId()needs Java 19 but this module compiles to Java 8, so it's suppressed in code with a comment.MacInstalledApps) and0x0000default PCI id (BsdGraphicsCard).Context: the rest of these rules were triaged separately
The bulk of S1168 (19), all of S107 (8), and 23 S1192 were evaluated and accepted as won't-fix with reasons — notably, OSHI's native code deliberately uses
null= "native call failed/unavailable" vs. empty = "succeeded, zero results" to drive retry/fallback logic (e.g.AdlUtil/NvmlUtilreturn null on driver error butemptyMapfor zero adapters;LinuxFileSystemnull triggers the JavaFilefallback). Returning empty there would break that logic, so those are intentional sentinels, not bugs.Summary by CodeRabbit
Refactor
Deprecations