Skip to content

Sonar backlog cleanup: clear remaining Maintainability findings (per-rule) - #3398

Merged
dbwiddis merged 15 commits into
oshi:masterfrom
dbwiddis:sonar-backlog-cleanup
Jun 15, 2026
Merged

dbwiddis merged 15 commits into
oshi:masterfrom
dbwiddis:sonar-backlog-cleanup

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jun 15, 2026 •

Copy link
Copy Markdown
Member

Clears the remaining open SonarCloud findings (all Maintainability; 0 Reliability / 0 Security throughout). Each rule is its own commit; tiny one-off rules are grouped into a final singleton sweep.

Fixed in code

Rule What
S2589 Remove dead/redundant conditions (BSD power-rate derive branch; Mac display release null-check)
S3252 Static-import inherited JNA constants instead of subclass access (preserves platform-specific RLIMIT_NOFILE values)
S5786 Drop redundant public on JUnit5 test classes/methods
S5778 Hoist non-throwing setup out of assertThrows lambdas
S3457 SLF4J {} placeholders / hoist runtime-built format strings
S2386 Make public static collections immutable (SMC_KEYS_*, NON_UNIQUE_UUIDS)
S3358 Extract nested ternaries into if/else
S1123 Add @deprecated javadoc to JMX MBeanServer conformance stubs
S117 camelCase local offset variables
S1172 Drop unused Class<T> params in WMI test mocks
S1450 Localize JMX address; keep NetworkMetrics.networkIFs as a GC-root field (@SuppressWarnings)
S5993 Make abstract-class constructors protected
S6395 Drop redundant non-capturing regex groups
S8491 Remove duplicate dangling javadoc
singleton sweep S1125, S115, S1161, S1163 (no throw-in-finally), S1171, S1700, S6213, S4030

Triaged as not-a-code-change (handled in SonarCloud)

  • Accepted (intentional): S5961, S2925 (timing tests), S5976 (oshi-common checkstyle forbids junit.jupiter.params), S5785 (equals()-branch tests), S1133 (JMX deprecated-interface stubs), S3400, S1135, S1479, S1871, plus partials of S3358/S1172/S3358.
  • False positive: S125 (7 — prose/GUID comments, not commented-out code), S3626 (forEach…Until early return is contractual, not redundant).

Notable

A few were more than mechanical: S2386 was genuine public static mutable-state exposure; NetworkMetrics.networkIFs / DiskMetrics.diskStores are deliberate Micrometer GC roots (kept, not localized); only DragonFly's RLIMIT_NOFILE was S3252-flagged because FreeBSD/OpenBSD/Solaris redefine it locally.

Verification

Clean full-reactor mvnw clean install: BUILD SUCCESS, 1321 tests, 0 failures / 0 errors (platform-conditional skips on macOS).

Summary by CodeRabbit

  • Refactoring

    • Improved code clarity with explicit conditional logic in disk type detection and power source capacity calculations.
    • Reorganized imports and simplified logging patterns across platform-specific utilities.
    • Enhanced test code organization and visibility modifiers for better encapsulation.
  • New Features

    • Added WmiNoComInitQueryHandler for COM initialization control in demo applications.
    • Added REFRESH_SLOWER timing constant for GUI refresh configuration.
  • Bug Fixes

    • Improved registry access error handling and logging on Windows platforms.

dbwiddis added 15 commits June 14, 2026 21:08
…splay release)

BsdPowerSource: the apm path only sources amperage; psPowerUsageRate is
never assigned, so the second derive branch (and its == 0 / > 0 guards)
was dead. Keep only the live amperage -> power derivation, matching the
one-directional data flow (Linux/FreeBSD/Solaris source a rate and keep
their bidirectional logic live).

MacDisplayJNA: propertySource != null was redundant inside an existing
if (propertySource != null) block; gate release on childEntryName != null
only, matching the MacDisplayFFM sibling.
…s access

The JNA process/memory classes reference constants through oshi's local
*Libc / SystemB subtypes (which exist only to add a few extra native
methods), but the constants are declared in the JNA supertypes. Replace
the subclass-qualified access with static imports of each constant from
its true declaring type, preserving platform-specific values:

- RLIMIT_NOFILE: from com.sun.jna...Resource (Linux, AIX) and from
  oshi FreeBsdLibc for DragonFly (inherits FreeBSD's 8, not JNA's 7).
- RUSAGE_SELF: from oshi CLibrary (Linux, Mac).
- Mac SystemB constants (INT_SIZE, PROC_*, RUSAGE_INFO_V2, HOST_VM_INFO):
  from com.sun.jna...SystemB.

Also drops gratuitous fully-qualified SystemB references in the Mac
getrusage block.
JUnit 5 discovers package-private test classes and methods, so the
public modifier is unnecessary. Remove it from the flagged test classes
(ProcUtilsTest, GlobalMemoryFFMTest, OperatingSystemFFMTest,
VirtualMemoryFFMTest, ApplicationInfoTest) and @test methods. The
SystemInfoTest classes keep their public modifier (they expose a main
demo); only their test methods are de-scoped.
assertThrows lambdas should contain only the single invocation expected
to throw. Pull the non-throwing setup calls (createProcessor(),
MemorySegment.ofAddress(), CFxxxRef.segment()) into locals before the
assertion so each lambda body is the method under test alone.
Replace concatenation passed directly to printf-style/logger calls:
- RegistryUtil, Advapi32UtilFFM, InstalledAppsDataFFM: SLF4J {} placeholders
  instead of '+' concatenation in LOG calls.
- SystemInfoHelper, PollGpuStats: the format string is built at runtime
  (conditional [%s]/%s, dynamic column width '%-'+nameWidth+'s'), which
  S3457 cannot analyze inline; hoist it into a local. PollGpuStats also
  DRYs the header/row formats (colFmt/rowFmt) reused at both call sites.
Public static mutable state is exposed to callers. Convert the public
static constants to immutable lists instead of Sonar's 'make protected'
(meaningless on these final utility classes):
- SmcUtil/SmcUtilFFM SMC_KEYS_*_AS: String[] -> unmodifiable List<String>;
  smcGetFirstFloat now takes List<String> (callers pass these constants).
- ComputerID.NON_UNIQUE_UUIDS: wrap Arrays.asList in unmodifiableList
  (Arrays.asList is fixed-size but element-mutable).
LinuxHWDiskStoreNF (diskType), WindowsPowerSourceJNA/FFM (maxCapacitySafe)
nested ternaries replaced with if/else chains. LinuxLibc.SYS_GETTID left
as-is and accepted in SonarCloud: it's an interface field initializer (no
statements) whose 3-value platform syscall table is documented in the
adjacent javadoc and cannot be de-nested without adding a public static
helper to a non-API JNA interface.
The three deserialize() overrides implement deprecated MBeanServer
interface methods and carry @deprecated; add the matching @deprecated
javadoc tag describing them as conformance stubs. (S1133 'remove deprecated
code someday' accepted in SonarCloud — these required interface overrides
cannot be removed.)
The three locals copying WinNTFFM.OFFSET_* constants used SCREAMING_CASE;
rename to offsetEventId/offsetTimeGenerated/offsetLength to match local
variable naming (the WinNTFFM constants keep their native-style names).
MockWmiResult ctor (WmiUtilTest) and emptyResult() (WindowsComputerSystemTest)
took a Class<T> arg only the diamond/target-type inference already provides;
removed it and the redundant TestProp.class arguments. The FFM SystemInfoTest
main(String[] args) is accepted in SonarCloud (mandatory main signature).
JMXOshiAgentServer.address was only used within initilizeMbeanServer;
make it a local. NetworkMetrics.networkIFs must stay a field — it is a
deliberate strong reference keeping NetworkIF objects alive for Micrometer
FunctionCounters (which hold them weakly); annotated @SuppressWarnings(
"java:S1450") rather than localized, matching the DiskMetrics.diskStores
GC-root pattern.
MacPowerSource and LinuxOSProcess are abstract; their constructors are
only called via super() from subclasses. Reduce visibility from public
to protected.
DOUBLE_QUOTES (?:(?:^")|(?:"$)) -> (?:^"|"$); the inner groups were
unnecessary inside the alternation (non-capturing, no backreferences).
WmiNoComInitQueryHandler had two class javadoc blocks; Config had a
leftover duplicate field comment. Keep one each.
- S1125: WindowsOperatingSystemJNA — h != null && isWow(h) instead of ?: false
- S115:  MemoizerTest — numberOfThreads -> NUMBER_OF_THREADS (constant naming)
- S1161: WindowsInternetProtocolStatsFFM — add @OverRide on getConnections
- S1163: Advapi32UtilFFM — log instead of throwing from finally (would mask the
         try-body exception); matches the RegistryUtil close-failure pattern
- S1171: WindowsCentralProcessor — move instance initializer block into the ctor
- S1700: Baseboard MBean — rename field baseboard -> hwBaseboard (shadowed class)
- S6213: Advapi32UtilFFM — rename local 'record' (restricted identifier) -> eventRecord
- S4030: DisksTest — remove unused partList copy loop (partitions asserted later)
@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

A broad housekeeping PR spanning multiple modules: public SMC temperature key constants changed from String[] to List<String> with matching method signatures; several constructors narrowed from public to protected; power-source capacity and rate logic simplified from nested ternaries to if/else chains; static imports consolidated across OS process files; logging switched to SLF4J parameterized form; demo classes gain a new WmiNoComInitQueryHandler, a REFRESH_SLOWER constant, and various refactors; test classes receive visibility reductions and minor structural cleanups.

Changes

Code Quality and API Housekeeping

Layer / File(s) Summary
SMC temperature key API: String[] → List<String>
oshi-core/src/main/java/oshi/util/platform/mac/SmcUtil.java, oshi-core-ffm/src/main/java/oshi/ffm/util/platform/mac/SmcUtilFFM.java
Public fields SMC_KEYS_CPU_TEMP_AS and SMC_KEYS_GPU_TEMP_AS changed from String[] to unmodifiable List<String>; smcGetFirstFloat updated to accept List<String> instead of varargs in both JNA and FFM implementations.
Constructor and initializer visibility tightening
oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacPowerSource.java, oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java, oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java
MacPowerSource and LinuxOSProcess constructors narrowed to protected. WindowsCentralProcessor moves utility-counter initialization from an instance initializer block into the constructor body.
Power source capacity and rate logic simplification
oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdPowerSource.java, oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java, oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java
BsdPowerSource power-rate derivation simplified to a single amperage×voltage guard. Both WindowsPowerSourceFFM and WindowsPowerSourceJNA replace nested ternary maxCapacitySafe assignments with equivalent if/else chains.
Static import consolidation in OS process and hardware files
oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java, oshi-core/src/main/java/oshi/software/os/mac/MacOSProcessJNA.java, oshi-core/src/main/java/oshi/software/os/unix/aix/AixOSProcessJNA.java, oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcessJNA.java, oshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.java
RLIMIT_NOFILE, RUSAGE_SELF, INT_SIZE, PROC_PIDTASKALLINFO, and related constants replaced with statically imported forms, removing class-qualified references throughout.
Logging, formatting, and code clarity
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java, oshi-core-ffm/src/main/java/oshi/driver/windows/registry/InstalledAppsDataFFM.java, oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/Advapi32UtilFFM.java, oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.java, oshi-common/src/main/java/oshi/util/SystemInfoHelper.java, oshi-common/src/main/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNF.java, oshi-core/src/main/java/oshi/hardware/platform/mac/MacDisplayJNA.java, oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java, oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsFFM.java
SLF4J string-concatenation logging replaced with parameterized form in three files. Advapi32UtilFFM.registryGetKeys changes RegCloseKey failure from thrown exception to logged warning. LinuxOperatingSystem regex simplified. SystemInfoHelper format string extracted to local variable. LinuxHWDiskStoreNF disk-type mapping converted to if/else. MacDisplayJNA removes the propertySource != null null guard. WindowsOperatingSystemJNA.isCurrentWow uses short-circuit &&. WindowsInternetProtocolStatsFFM gains @Override.
Demo and metrics additions and refactors
oshi-demo/src/main/java/oshi/demo/WmiNoComInitQueryHandler.java, oshi-demo/src/main/java/oshi/demo/gui/Config.java, oshi-demo/src/main/java/oshi/demo/ComputerID.java, oshi-demo/src/main/java/oshi/demo/PollGpuStats.java, oshi-demo/src/main/java/oshi/demo/jmx/JMXOshiAgentServer.java, oshi-demo/src/main/java/oshi/demo/jmx/mbeans/Baseboard.java, oshi-metrics/src/main/java/oshi/metrics/NetworkMetrics.java
New WmiNoComInitQueryHandler skips COM initialization. Config gains REFRESH_SLOWER constant. ComputerID.NON_UNIQUE_UUIDS wrapped as unmodifiable list. PollGpuStats introduces reusable colFmt/rowFmt format strings. JMXOshiAgentServer moves JMXServiceURL from field to local variable. Baseboard renames internal field to hwBaseboard. NetworkMetrics adds suppression annotation documenting intentional strong reference.
Test visibility, mock cleanup, and structural tidying
oshi-common/src/test/java/oshi/driver/common/windows/wmi/WmiUtilTest.java, oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java, oshi-core-ffm/src/test/java/oshi/ffm/platform/mac/CoreFoundationTest.java, oshi-core/src/test/java/oshi/hardware/platform/shared/DisksTest.java, oshi-common/src/test/java/oshi/util/MemoizerTest.java, oshi-common/src/test/java/oshi/hardware/common/platform/windows/WindowsComputerSystemTest.java, oshi-core/src/test/java/oshi/software/os/shared/ApplicationInfoTest.java, oshi-core-ffm/src/test/java/oshi/ffm/..., oshi-common/src/test/java/oshi/...
MockWmiResult constructor drops unused enum-class parameter. AbstractCentralProcessorTest and CoreFoundationTest extract inline expressions to local variables before assertThrows. DisksTest removes intermediate partition-copy block. MemoizerTest renames thread-count to uppercase constant. Multiple test classes and methods converted from public to package-private.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • oshi/oshi#3389: Modifies WindowsCentralProcessor to refactor the CPU-utility tick memoization and initial-counter bootstrap logic, overlapping with this PR's move of setInitialUtilityCounters from an initializer block into the constructor.
  • oshi/oshi#3271: Introduces WmiUtilTest and the MockWmiResult helper that this PR simplifies by removing the unused enum-class constructor parameter.
  • oshi/oshi#3396: Both PRs touch JMXOshiAgentServer.java, specifically the deprecated deserialize(...) stub handling and documentation.

Poem

🐇 Hoppity-hop through the code we go,
Swapping arrays for Lists, high and low.
Protected constructors, if/else in a row,
Static imports tidy up the show.
Logging with placeholders, clean as a hutch —
This rabbit approves, not changing too much! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.92% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Sonar backlog cleanup: clear remaining Maintainability findings (per-rule)' clearly and accurately summarizes the main objective of the PR—addressing SonarCloud maintainability findings systematically by rule.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 48.71795% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.05%. Comparing base (747d76c) to head (a1490e4).

Files with missing lines Patch % Lines
...ain/java/oshi/software/os/mac/MacOSProcessJNA.java 37.50% 0 Missing and 5 partials ⚠️
.../platform/linux/nativefree/LinuxHWDiskStoreNF.java 40.00% 2 Missing and 1 partial ⚠️
...java/oshi/software/os/linux/LinuxOSProcessJNA.java 0.00% 0 Missing and 3 partials ⚠️
.../hardware/common/platform/unix/BsdPowerSource.java 0.00% 2 Missing ⚠️
...mmon/src/main/java/oshi/util/SystemInfoHelper.java 50.00% 0 Missing and 2 partials ⚠️
...shi/ffm/util/platform/windows/Advapi32UtilFFM.java 77.77% 2 Missing ⚠️
...java/oshi/hardware/platform/mac/MacDisplayJNA.java 0.00% 1 Missing ⚠️
...software/os/windows/WindowsOperatingSystemJNA.java 0.00% 0 Missing and 1 partial ⚠️
.../java/oshi/util/platform/windows/RegistryUtil.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3398      +/-   ##
============================================
- Coverage     75.06%   75.05%   -0.02%     
  Complexity       76       76              
============================================
  Files           579      579              
  Lines         21351    21353       +2     
  Branches       3555     3554       -1     
============================================
- Hits          16028    16027       -1     
- Misses         3301     3304       +3     
  Partials       2022     2022              
Flag Coverage Δ
freebsd 26.32% <5.12%> (+<0.01%) ⬆️
linux 30.90% <10.25%> (+0.01%) ⬆️
macos 31.25% <17.94%> (+<0.01%) ⬆️
openbsd 25.81% <5.12%> (+0.02%) ⬆️
solaris 27.87% <5.12%> (+<0.01%) ⬆️
windows 39.54% <30.76%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
oshi-core/src/main/java/oshi/util/platform/mac/SmcUtil.java (1)

66-70: Consider List.of(...) for consistency with the FFM implementation.

The FFM counterpart in SmcUtilFFM.java (lines 75-77) uses List.of(...) which is more concise. Both approaches achieve immutability, but List.of(...) is the modern idiomatic choice since Java 9 and aligns the two implementations.

♻️ Suggested alignment
-    public static final List<String> SMC_KEYS_CPU_TEMP_AS = Collections
-            .unmodifiableList(Arrays.asList("Tp09", "Tp0T", "Tp01", "Tp05", "Tp0D"));
+    public static final List<String> SMC_KEYS_CPU_TEMP_AS = List.of("Tp09", "Tp0T", "Tp01", "Tp05", "Tp0D");
     /** Apple Silicon GPU temperature keys, tried in order until one returns a positive value. */
-    public static final List<String> SMC_KEYS_GPU_TEMP_AS = Collections
-            .unmodifiableList(Arrays.asList("Tg05", "Tg0D", "Tg0f", "Tg0j"));
+    public static final List<String> SMC_KEYS_GPU_TEMP_AS = List.of("Tg05", "Tg0D", "Tg0f", "Tg0j");
🤖 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-core/src/main/java/oshi/util/platform/mac/SmcUtil.java` around lines 66
- 70, Replace the verbose immutable list creation pattern in the
SMC_KEYS_CPU_TEMP_AS and SMC_KEYS_GPU_TEMP_AS list definitions with the more
concise and modern List.of(...) syntax. Instead of wrapping Arrays.asList(...)
with Collections.unmodifiableList(...), use List.of(...) directly which provides
immutability by default and aligns with the approach used in SmcUtilFFM.java for
consistency across the codebase.
oshi-demo/src/main/java/oshi/demo/ComputerID.java (1)

33-35: Consider List.of(...) for modern immutable list creation.

Similar to the suggestion for SmcUtil.java, List.of(...) is more concise and idiomatic since Java 9.

♻️ Suggested simplification
-    public static final List<String> NON_UNIQUE_UUIDS = Collections
-            .unmodifiableList(Arrays.asList("03000200-0400-0500-0006-000700080009",
-                    "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF", "00000000-0000-0000-0000-000000000000"));
+    public static final List<String> NON_UNIQUE_UUIDS = List.of(
+            "03000200-0400-0500-0006-000700080009",
+            "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
+            "00000000-0000-0000-0000-000000000000");
🤖 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-demo/src/main/java/oshi/demo/ComputerID.java` around lines 33 - 35,
Replace the verbose immutable list creation pattern in the NON_UNIQUE_UUIDS
field definition. Instead of using
Collections.unmodifiableList(Arrays.asList(...)), use the more concise and
idiomatic List.of(...) method which is available since Java 9. Simply replace
the entire Collections.unmodifiableList(Arrays.asList(...)) wrapper with
List.of(...) containing the same UUID strings, and remove any now-unused imports
for Collections and Arrays if they are not used elsewhere in the file.
🤖 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.

Nitpick comments:
In `@oshi-core/src/main/java/oshi/util/platform/mac/SmcUtil.java`:
- Around line 66-70: Replace the verbose immutable list creation pattern in the
SMC_KEYS_CPU_TEMP_AS and SMC_KEYS_GPU_TEMP_AS list definitions with the more
concise and modern List.of(...) syntax. Instead of wrapping Arrays.asList(...)
with Collections.unmodifiableList(...), use List.of(...) directly which provides
immutability by default and aligns with the approach used in SmcUtilFFM.java for
consistency across the codebase.

In `@oshi-demo/src/main/java/oshi/demo/ComputerID.java`:
- Around line 33-35: Replace the verbose immutable list creation pattern in the
NON_UNIQUE_UUIDS field definition. Instead of using
Collections.unmodifiableList(Arrays.asList(...)), use the more concise and
idiomatic List.of(...) method which is available since Java 9. Simply replace
the entire Collections.unmodifiableList(Arrays.asList(...)) wrapper with
List.of(...) containing the same UUID strings, and remove any now-unused imports
for Collections and Arrays if they are not used elsewhere in the file.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5d019104-7fac-426c-8b42-8bc4e5f1a840

📥 Commits

Reviewing files that changed from the base of the PR and between 747d76c and a1490e4.

📒 Files selected for processing (44)
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdPowerSource.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.java
  • oshi-common/src/main/java/oshi/util/SystemInfoHelper.java
  • oshi-common/src/test/java/oshi/driver/common/windows/wmi/WmiUtilTest.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/windows/WindowsComputerSystemTest.java
  • oshi-common/src/test/java/oshi/nativefree/SystemInfoTest.java
  • oshi-common/src/test/java/oshi/util/MemoizerTest.java
  • oshi-common/src/test/java/oshi/util/ProcUtilsTest.java
  • oshi-core-ffm/src/main/java/oshi/driver/windows/registry/InstalledAppsDataFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/mac/SmcUtilFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/Advapi32UtilFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsFFM.java
  • oshi-core-ffm/src/test/java/oshi/ffm/GlobalMemoryFFMTest.java
  • oshi-core-ffm/src/test/java/oshi/ffm/NativeHandleTest.java
  • oshi-core-ffm/src/test/java/oshi/ffm/OperatingSystemFFMTest.java
  • oshi-core-ffm/src/test/java/oshi/ffm/SystemInfoTest.java
  • oshi-core-ffm/src/test/java/oshi/ffm/VirtualMemoryFFMTest.java
  • oshi-core-ffm/src/test/java/oshi/ffm/platform/mac/CoreFoundationTest.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacDisplayJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/mac/MacOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/aix/AixOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
  • oshi-core/src/main/java/oshi/util/platform/mac/SmcUtil.java
  • oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
  • oshi-core/src/test/java/oshi/SystemInfoTest.java
  • oshi-core/src/test/java/oshi/hardware/platform/shared/DisksTest.java
  • oshi-core/src/test/java/oshi/software/os/shared/ApplicationInfoTest.java
  • oshi-demo/src/main/java/oshi/demo/ComputerID.java
  • oshi-demo/src/main/java/oshi/demo/PollGpuStats.java
  • oshi-demo/src/main/java/oshi/demo/WmiNoComInitQueryHandler.java
  • oshi-demo/src/main/java/oshi/demo/gui/Config.java
  • oshi-demo/src/main/java/oshi/demo/jmx/JMXOshiAgentServer.java
  • oshi-demo/src/main/java/oshi/demo/jmx/mbeans/Baseboard.java
  • oshi-metrics/src/main/java/oshi/metrics/NetworkMetrics.java
💤 Files with no reviewable changes (3)
  • oshi-demo/src/main/java/oshi/demo/WmiNoComInitQueryHandler.java
  • oshi-demo/src/main/java/oshi/demo/gui/Config.java
  • oshi-core/src/test/java/oshi/hardware/platform/shared/DisksTest.java
📜 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). (11)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 26, 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: Analyze (java)
🧰 Additional context used
🧠 Learnings (4)
📚 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/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNF.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacPowerSource.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdPowerSource.java
  • oshi-common/src/main/java/oshi/util/SystemInfoHelper.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java
📚 Learning: 2026-04-08T00:58:07.212Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3125
File: oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java:131-133
Timestamp: 2026-04-08T00:58:07.212Z
Learning: Do not flag `getPowerSources()` as incorrect when it returns a singleton list that wraps `getPowerSource("System Battery")` and/or short-circuits the enumeration after the first eligible battery pack in the Windows power source JNA/FFM implementations. This is intentional for longstanding JNA behavior; a refactor to support zero-or-more batteries is planned later, so the current single-battery behavior should be treated as by-design rather than a bug.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java
  • oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/aix/AixOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/mac/MacOSProcessJNA.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcessJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/mac/MacDisplayJNA.java
📚 Learning: 2026-04-12T19:34:56.879Z
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:34:56.879Z
Learning: In OSHI’s Java platform implementations, `PhysicalProcessor.getEfficiency()` / `EfficiencyClass` follow the same convention as Windows `PROCESSOR_RELATIONSHIP.EfficiencyClass`: a *higher* numeric efficiency class value represents *greater performance* and *less efficiency* (typically P-cores higher than E-cores). When reviewing, do not treat cases where P-cores are assigned higher efficiency/class values as a bug—this is intentional cross-platform consistency.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java
🔇 Additional comments (44)
oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsFFM.java (1)

28-29: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdPowerSource.java (1)

108-111: LGTM!

oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java (1)

210-217: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java (1)

171-177: LGTM!

oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java (1)

68-68: LGTM!

oshi-core-ffm/src/main/java/oshi/driver/windows/registry/InstalledAppsDataFFM.java (1)

154-154: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/Advapi32UtilFFM.java (3)

172-174: LGTM!


245-245: LGTM!


406-435: LGTM!

oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOperatingSystem.java (1)

59-59: LGTM!

oshi-common/src/main/java/oshi/util/SystemInfoHelper.java (1)

398-406: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNF.java (1)

63-68: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/mac/MacDisplayJNA.java (1)

92-94: LGTM!

oshi-core/src/main/java/oshi/software/os/windows/WindowsOperatingSystemJNA.java (1)

546-546: LGTM!

oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcessJNA.java (1)

7-8: LGTM!

Also applies to: 37-37, 65-65, 74-74

oshi-core/src/main/java/oshi/software/os/mac/MacOSProcessJNA.java (1)

7-12: LGTM!

Also applies to: 119-119, 190-191, 195-196, 235-236, 253-253, 261-261

oshi-core/src/main/java/oshi/software/os/unix/aix/AixOSProcessJNA.java (1)

7-7: LGTM!

Also applies to: 71-71, 82-82

oshi-core/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryJNA.java (1)

7-8: LGTM!

Also applies to: 49-50

oshi-core-ffm/src/test/java/oshi/ffm/SystemInfoTest.java (1)

60-60: LGTM!

Also applies to: 66-66

oshi-core-ffm/src/test/java/oshi/ffm/VirtualMemoryFFMTest.java (1)

24-24: LGTM!

oshi-core/src/test/java/oshi/SystemInfoTest.java (1)

61-61: LGTM!

oshi-common/src/test/java/oshi/driver/common/windows/wmi/WmiUtilTest.java (1)

33-33: LGTM!

Also applies to: 39-39, 45-45, 51-51, 57-57, 63-63, 69-69, 75-75, 91-95

oshi-common/src/test/java/oshi/hardware/common/platform/windows/WindowsComputerSystemTest.java (1)

26-26: LGTM!

Also applies to: 34-34

oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java (1)

107-108: LGTM!

Also applies to: 325-325, 328-328, 331-331

oshi-core-ffm/src/test/java/oshi/ffm/GlobalMemoryFFMTest.java (1)

33-33: LGTM!

oshi-core-ffm/src/test/java/oshi/ffm/OperatingSystemFFMTest.java (1)

31-31: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcessJNA.java (1)

7-7: No change needed; this code is correct as-is.

DragonFlyBsdLibc extends FreeBsdLibc without defining its own RLIMIT_NOFILE constant. Both FreeBSD and DragonFly BSD use the same constant value (8) in their respective sys/resource.h headers. The current import from FreeBsdLibc.RLIMIT_NOFILE provides the correct constant for both platforms, and using DragonFlyBsdLibc.INSTANCE.getrlimit() correctly applies the inherited constant value. The premise that "DragonFly's constant differs" is not supported by evidence.

oshi-core-ffm/src/test/java/oshi/ffm/platform/mac/CoreFoundationTest.java (1)

154-155: LGTM!

Also applies to: 454-455, 462-463, 470-471, 478-479, 486-487

oshi-core-ffm/src/test/java/oshi/ffm/NativeHandleTest.java (1)

76-77: LGTM!

oshi-common/src/test/java/oshi/util/MemoizerTest.java (1)

37-37: LGTM!

Also applies to: 43-43, 111-111, 187-187

oshi-common/src/test/java/oshi/util/ProcUtilsTest.java (1)

20-20: LGTM!

oshi-common/src/test/java/oshi/nativefree/SystemInfoTest.java (1)

57-57: LGTM!

oshi-core/src/test/java/oshi/software/os/shared/ApplicationInfoTest.java (1)

25-25: LGTM!

Also applies to: 82-82, 89-89, 96-96, 112-112, 122-122

oshi-core/src/main/java/oshi/util/platform/mac/SmcUtil.java (1)

155-163: LGTM!

oshi-core-ffm/src/main/java/oshi/ffm/util/platform/mac/SmcUtilFFM.java (2)

75-77: LGTM!


173-181: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacPowerSource.java (1)

51-61: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsCentralProcessor.java (1)

33-37: LGTM!

oshi-common/src/main/java/oshi/software/common/os/linux/LinuxOSProcess.java (1)

100-100: LGTM!

oshi-demo/src/main/java/oshi/demo/PollGpuStats.java (1)

52-55: LGTM!

Also applies to: 92-92

oshi-demo/src/main/java/oshi/demo/jmx/JMXOshiAgentServer.java (2)

101-102: LGTM!


315-349: LGTM!

oshi-demo/src/main/java/oshi/demo/jmx/mbeans/Baseboard.java (1)

32-32: LGTM!

Also applies to: 39-39, 49-49, 62-62, 72-78

oshi-metrics/src/main/java/oshi/metrics/NetworkMetrics.java (1)

61-63: LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant