Repository navigation
Clear the open SonarQube findings - #3540
Conversation
Eight are fixed in code and ten are suppressed with an inline reason. Fixed: - S1128 x2: DxgiFFM and Shell32FFM extend ForeignFunctions and WindowsForeignFunctions respectively, so they inherit callInArenaOrDefault and the static import is redundant. Spotless cannot detect this because the bare name is textually referenced. - S135 x2: restructure the SmcKeyIndex scan loop and parseConfiguredKeys as if/else. Behaviour is unchanged. - S6353: write the GPU key mask as ^Tg\d[\dA-Za-z]$. Without UNICODE_CHARACTER_CLASS this is identical to the [0-9] form. - S1192: SysctlFFM concatenated its failure message eagerly at all five call sites, formatting the sysctl name on every call whether or not it failed. Use the parameterized callInArena*OrDefault overloads with a single shared constant so the name is only formatted on failure. - S1602: add the block-lambda guard comment to AdlUtilFFM.adlUninit, matching BStrFFM. Collapsing the block would reintroduce #3422. Suppressed: - S1168 x5: null and empty are different answers. Empty is a cacheable "this machine has no GPU temperature keys"; returning it after a failed read would cache the failure and disable GPU temperature for the lifetime of the JVM. - S3077 x2: gpuTemperatureKeys is only ever assigned an unmodifiable copy of a completed discovery, so the volatile write safely publishes an immutable value. Memoizer carries the same suppression. - S5786 x3: the module system only opens public types to the JUnit platform, so public on these test classes is required rather than redundant. SystemInfoTest carries the same suppression. The four remaining S3776 findings are accepted in SonarCloud rather than refactored. Three of them are an artifact of the ExceptionUtil and callInArena conversions in #3528 and #3530: moving a method body into a callInArenaOrDefault lambda adds a nesting level that Sonar scores, without changing the logic.
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (5)
📝 WalkthroughWalkthroughSMC GPU key discovery and caching semantics were refined, FFM utility handling was consolidated, ADL teardown invocation was adjusted, and macOS JPMS test visibility documentation was expanded. ChangesSMC discovery updates
FFM utility updates
JPMS test discovery documentation
Estimated code review effort: 3 (Moderate) | ~20 minutes 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@oshi-common/src/main/java/oshi/util/common/platform/mac/SmcKeyIndex.java`:
- Around line 97-104: Update the candidate-read loop in SmcKeyIndex so an
uncertain read followed by a non-matching key does not produce a cacheable empty
list. Track whether any matching Tg key was successfully established, return
null when reads failed and none was found, and preserve an empty result only for
a confirmed absence; add a regression test covering a failed sole Tg key
followed by Th00.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4c222fdc-9247-49da-81c9-1146b676c510
📒 Files selected for processing (10)
oshi-common/src/main/java/oshi/util/common/platform/mac/SmcKeyIndex.javaoshi-common/src/test/java/oshi/util/common/platform/mac/SmcKeyIndexTest.javaoshi-core-ffm/src/main/java/oshi/ffm/platform/windows/DxgiFFM.javaoshi-core-ffm/src/main/java/oshi/ffm/platform/windows/Shell32FFM.javaoshi-core-ffm/src/main/java/oshi/ffm/util/SysctlFFM.javaoshi-core-ffm/src/main/java/oshi/ffm/util/gpu/AdlUtilFFM.javaoshi-core-ffm/src/main/java/oshi/ffm/util/platform/mac/SmcUtilFFM.javaoshi-core-ffm/src/test/java/oshi/ffm/MacSensorsPlausibilityFFMTest.javaoshi-core/src/main/java/oshi/util/platform/mac/SmcUtil.javaoshi-core/src/test/java/oshi/util/platform/mac/MacSensorsPlausibilityTest.java
💤 Files with no reviewable changes (2)
- oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/Shell32FFM.java
- oshi-core-ffm/src/main/java/oshi/ffm/platform/windows/DxgiFFM.java
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.
Applied to files:
oshi-core-ffm/src/main/java/oshi/ffm/util/gpu/AdlUtilFFM.javaoshi-core-ffm/src/main/java/oshi/ffm/util/platform/mac/SmcUtilFFM.javaoshi-core/src/main/java/oshi/util/platform/mac/SmcUtil.javaoshi-core-ffm/src/main/java/oshi/ffm/util/SysctlFFM.javaoshi-common/src/main/java/oshi/util/common/platform/mac/SmcKeyIndex.java
📚 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/util/common/platform/mac/SmcKeyIndex.java
🔇 Additional comments (11)
oshi-core-ffm/src/main/java/oshi/ffm/util/SysctlFFM.java (1)
37-42: LGTM!Also applies to: 59-63, 83-83, 108-108, 132-132, 148-148, 173-173
oshi-core-ffm/src/main/java/oshi/ffm/util/gpu/AdlUtilFFM.java (1)
201-204: LGTM!oshi-core-ffm/src/test/java/oshi/ffm/MacSensorsPlausibilityFFMTest.java (1)
34-39: LGTM!oshi-core/src/test/java/oshi/util/platform/mac/MacSensorsPlausibilityTest.java (1)
36-41: LGTM!oshi-common/src/main/java/oshi/util/common/platform/mac/SmcKeyIndex.java (4)
45-45: LGTM!
79-83: LGTM!
113-113: LGTM!
200-204: LGTM!oshi-common/src/test/java/oshi/util/common/platform/mac/SmcKeyIndexTest.java (1)
26-30: LGTM!oshi-core-ffm/src/main/java/oshi/ffm/util/platform/mac/SmcUtilFFM.java (1)
121-125: LGTM!Also applies to: 380-380
oshi-core/src/main/java/oshi/util/platform/mac/SmcUtil.java (1)
106-110: LGTM!Also applies to: 352-352
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3540 +/- ##
============================================
- Coverage 78.92% 78.86% -0.07%
- Complexity 76 3649 +3573
============================================
Files 699 699
Lines 24082 24083 +1
Branches 3985 3986 +1
============================================
- Hits 19006 18992 -14
- Misses 2884 2895 +11
- Partials 2192 2196 +4
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:
|
findKeys distinguishes null ("could not read, ask again later") from an
empty list ("this machine has no such keys"), because the caller caches
the empty list and would otherwise disable the sensor for the lifetime
of the JVM. Two paths could reach empty after a failed read.
In the forward scan, readAny was satisfied by the key that ends the
block rather than by a match, so an index of [TB0T, Tg0f, Th00] whose
Tg0f is unreadable returned an empty list: the scan read Th00, set
readAny, and broke out having matched nothing.
In the binary search, probe substitutes a neighbouring key for an
unreadable one so a single bad index cannot abort discovery. That
substitution can move the landing point past the block, so for
[TB0T, TCMb, Tg0f, Th00] with Tg0f unreadable the scan never attempted
the only matching key, and no scan-side check could have caught it.
Track failed reads through a single wrapper around the lookup function
so both paths are covered, and return null when nothing matched and any
read failed. An empty result from a run with no failed read is still
returned and still cacheable, and a partial result is still returned,
so the existing skip-rather-than-stop behaviour is unchanged.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In
`@oshi-common/src/test/java/oshi/util/common/platform/mac/SmcKeyIndexTest.java`:
- Around line 130-137: Update
testFailedSearchProbeThatSkipsTheBlockIsNotReportedAsAbsent so the flaky reader
returns null only on the first read of index 2, then returns keys[2] on
subsequent reads. Track that read state within the test’s IntFunction,
preserving the existing assertion so an incorrect forward-scan retry exposes the
regression.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5a29b0f0-5533-47ba-9498-5983ddb8e1e0
📒 Files selected for processing (2)
oshi-common/src/main/java/oshi/util/common/platform/mac/SmcKeyIndex.javaoshi-common/src/test/java/oshi/util/common/platform/mac/SmcKeyIndexTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
- oshi-common/src/main/java/oshi/util/common/platform/mac/SmcKeyIndex.java
📜 Review details
⏰ Context from checks skipped due to timeout. (8)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Analyze (java)
- GitHub Check: Test JDK 21, ubuntu-latest
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
- GitHub Check: Test JDK 26, ubuntu-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🔇 Additional comments (3)
oshi-common/src/test/java/oshi/util/common/platform/mac/SmcKeyIndexTest.java (3)
26-30: LGTM!
120-128: LGTM!
140-146: LGTM!
testFailedSearchProbeThatSkipsTheBlockIsNotReportedAsAbsent failed the sole matching index permanently, so a null result did not distinguish the case it names -- the binary search substituting a neighbour and landing past the block -- from the scan reaching that index and failing both its reads. Both produce null. Fail only the first read, which the search consumes. A null result now proves the scan never attempted the index, because the scan retries once and would have recovered Tg0f and returned a non-empty list. This also separates the test from testFailedSoleMatchIsNotReportedAsAbsent, which keeps a permanently failing index.
Clears the SonarCloud backlog: 8 findings fixed in code, 10 suppressed with an inline reason, and the 4 remaining
S3776complexity findings accepted in SonarCloud rather than refactored.Fixed
S1128×2DxgiFFM,Shell32FFMForeignFunctions/WindowsForeignFunctionsand inheritcallInArenaOrDefault; spotless can't detect this because the bare name is textually referenced.S135×2SmcKeyIndexscan loop,parseConfiguredKeysS6353SmcKeyIndexGPU key mask^Tg[0-9][0-9A-Za-z]$→^Tg\d[\dA-Za-z]$. Identical withoutUNICODE_CHARACTER_CLASS.S1192SysctlFFM×5callInArena*OrDefaultoverloads (#3530) with one shared constant, so the name is only formatted on the failure path.S1602AdlUtilFFM.adlUninitBStrFFM. Collapsing the block would reintroduce #3422;VoidInvokeExactSourceTestalready guards the code, this stops the rule nagging toward the bug.Suppressed
Each carries
// NOSONAR squid:Sxxxxplus the reason, and a javadoc note where one wasn't already present.S1168×5 (SmcKeyIndex×3, bothSmcUtiltwins) —nulland empty are different answers. Empty is a cacheable "this machine has no GPU temperature keys"; returning it after a failed read would cache the failure and disable GPU temperature for the lifetime of the JVM.S3077×2 (gpuTemperatureKeys) — false positive. Only ever assigned an unmodifiable copy of a completed discovery, so the volatile write safely publishes an immutable value.Memoizercarries the same suppression.S5786×3 (test classes) — the module system only opens public types to the JUnit platform, sopublicis required, not redundant.SystemInfoTestcarries the same suppression.Accepted in SonarCloud, not refactored
The four
S3776cognitive-complexity findings, per the project's standing policy. Three are an artifact of theExceptionUtil/callInArenaconversions in #3528 and #3530 — moving a method body into acallInArenaOrDefaultlambda adds a nesting level Sonar scores, with no change to the logic.Shell32FFM.CommandLineToArgvwent from roughly at-threshold to 18 that way.Verification
Pre-commit gate clean on
oshi-common,oshi-core,oshi-core-ffm(spotless, checkstyle, install, forbiddenapis, javadoc), plus a clean full-reactorinstallfrom root. All tests pass.NativeComparisonTestunder-Pnative-comparisonpasses on an M2 Max includingsensors(), so JNA/FFM parity is intact.No CHANGELOG entry: no user-observable behaviour changes.
Summary by CodeRabbit