Skip to content

Fix SonarCloud test-binaries config and clear two code smells - #3485

Merged
dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:sonar-config-and-cleanup
Jul 18, 2026
Merged

dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:sonar-config-and-cleanup

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jul 18, 2026 •

Copy link
Copy Markdown
Member

Small pre-7.4.1 cleanup from a SonarCloud review. The analysis is otherwise clean — 0 bugs, 0 vulnerabilities, 0 reliability, 0 security issues; the remaining code smells are pre-existing or covered by the accept-all cognitive-complexity policy.

SonarCloud config

Declare sonar.java.test.binaries (each module's target/test-classes). SonarCloud was warning Missing 'sonar.java.test.binaries' property. You might end up with less precise analysis results. — the sonar-maven-plugin wasn't auto-detecting the compiled test classes (verified they compile: 221/60/23/8 classes). Resolves per-module via ${project.build.testOutputDirectory}. Validated on the next master SonarCloud run.

Two flagged code smells (introduced by the audit PRs)

  • AdlUtilFFM.adlMalloc — catch (Throwable t) where t is unused → catch (Throwable _) (java:S7467), matching the unnamed-variable convention already used elsewhere.
  • RegistryValueUtilTest — LocalDate.of(2020, 1, 1) → LocalDate.of(2020, Month.JANUARY, 1) (java:S8694).

No CHANGELOG entry — build config and code-smell cleanup with no user-observable change.

Summary by CodeRabbit

  • Build & Quality

    • Improved SonarCloud analysis by explicitly identifying compiled test classes.
    • Updated date handling in automated test validation for clearer, more reliable expectations.
  • Bug Fixes

    • Improved exception handling in graphics memory allocation without changing user-visible behavior.

dbwiddis added 2 commits July 18, 2026 13:25
SonarCloud warned "Missing sonar.java.test.binaries" (less precise test-code
analysis). The sonar-maven-plugin was not auto-detecting the compiled test
classes, so declare each module's target/test-classes explicitly.
Use an unnamed variable for the unused Throwable in AdlUtilFFM.adlMalloc
(java:S7467), and a java.time.Month constant instead of an int literal in
RegistryValueUtilTest (java:S8694).
@coderabbitai

coderabbitai Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f4d4eb21-5cba-43d2-b46e-82c5462d8d2b

📥 Commits

Reviewing files that changed from the base of the PR and between d148fec and 6a3080e.

📒 Files selected for processing (3)
  • oshi-common/src/test/java/oshi/driver/common/windows/registry/RegistryValueUtilTest.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/gpu/AdlUtilFFM.java
  • pom.xml
📜 Recent review details
⏰ Context from checks skipped due to timeout. (15)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, ubuntu-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
🧰 Additional context used
🧠 Learnings (1)
📚 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.java
🔇 Additional comments (3)
oshi-common/src/test/java/oshi/driver/common/windows/registry/RegistryValueUtilTest.java (1)

12-12: LGTM!

Also applies to: 40-41

oshi-core-ffm/src/main/java/oshi/ffm/util/gpu/AdlUtilFFM.java (1)

168-170: LGTM!

pom.xml (1)

80-82: LGTM!


📝 Walkthrough

Walkthrough

The changes update a registry date test to use Month.JANUARY, remove an unused exception variable in FFM GPU allocation, and configure Maven’s SonarCloud analysis with the compiled test binary directory.

Changes

Maintenance updates

Layer / File(s) Summary
Date expectation update
oshi-common/src/test/java/oshi/driver/common/windows/registry/RegistryValueUtilTest.java
The date expectation uses Month.JANUARY when constructing the January 2020 value.
FFM exception binding
oshi-core-ffm/src/main/java/oshi/ffm/util/gpu/AdlUtilFFM.java
adlMalloc catches an unnamed Throwable while retaining its MemorySegment.NULL fallback.
Sonar test binary configuration
pom.xml
Adds sonar.java.test.binaries using ${project.build.testOutputDirectory}.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • oshi/oshi#3481: Introduces RegistryValueUtil and related parsing tests referenced by the updated date expectation.

Poem

A rabbit hops through tests today,
With January named the proper way.
Unused names are tucked from sight,
Sonar finds test classes right.
“Clean little changes!” we cheer—
Springing through the build with cheer!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main SonarCloud config fix and code-smell cleanup.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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.

@codecov

codecov Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.08%. Comparing base (d148fec) to head (6a3080e).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3485      +/-   ##
============================================
+ Coverage     75.05%   75.08%   +0.02%     
  Complexity       76       76              
============================================
  Files           590      590              
  Lines         21559    21559              
  Branches       3610     3610              
============================================
+ Hits          16182    16187       +5     
+ Misses         3406     3401       -5     
  Partials       1971     1971              
Flag Coverage Δ
freebsd 27.74% <ø> (-0.01%) ⬇️
linux 32.32% <ø> (+<0.01%) ⬆️
macos 32.85% <ø> (-0.05%) ⬇️
openbsd 27.06% <ø> (+0.01%) ⬆️
solaris 29.57% <ø> (ø)
windows 40.90% <ø> (+0.02%) ⬆️

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.

@dbwiddis
dbwiddis merged commit 0e7ffaa into oshi:master Jul 18, 2026
19 checks passed
@dbwiddis
dbwiddis deleted the sonar-config-and-cleanup branch July 18, 2026 21:18
dbwiddis added a commit that referenced this pull request Jul 18, 2026
oshi-benchmark is not published and its comparison tests only compile under the
native-comparison profile, so the default Sonar build finds no test binaries for
it -- the source of the residual "sonar.java.test.binaries" warning after
#3485. It contributes no findings; exclude it from analysis with sonar.skip.
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