Fix SAT errors#2027
Conversation
Signed-off-by: Kai Kreuzer <kai@openhab.org>
There was a problem hiding this comment.
Pull request overview
This PR targets Static Analysis Tool (SAT) findings across the Z-Wave binding by cleaning up test code (logging, imports) and applying small production code refactors (collection emptiness checks, logging format fixes, exception type refinement).
Changes:
- Replace
printStackTrace()/System.out.println()usage in tests with SLF4J logging and narrow wildcard static imports. - Refactor some collection empty checks to
isEmpty()and adjust several logging statements to passThrowablecorrectly. - Update
ZWaveTransactionManagertransaction comparisons and refine an exception type inZWaveSecurityCommandClass.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 25 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/org/openhab/binding/zwave/internal/protocol/ZWaveTransactionManagerTestSync.java | Replace stack traces with SLF4J logging; narrow static imports. |
| src/test/java/org/openhab/binding/zwave/internal/protocol/ZWaveTransactionManagerTestBasic.java | Add SLF4J logging for interrupted sleep; import changes. |
| src/test/java/org/openhab/binding/zwave/internal/protocol/serialmessage/ZWaveCommandProcessorTest.java | Replace stack trace printing with logging. |
| src/test/java/org/openhab/binding/zwave/internal/protocol/serialmessage/IdentifyNodeMessageClassTest.java | Replace stack trace printing with logging. |
| src/test/java/org/openhab/binding/zwave/internal/protocol/serialmessage/ApplicationUpdateMessageClassTest.java | Narrow assertions import; replace stack trace printing with logging. |
| src/test/java/org/openhab/binding/zwave/internal/protocol/serialmessage/AddNodeMessageClassTest.java | Remove System.out.println; add logging in exception path; adjust imports. |
| src/test/java/org/openhab/binding/zwave/internal/protocol/commandclass/ZWaveCommandClassPayloadTest.java | Narrow assertions import; replace stack trace printing with logging. |
| src/test/java/org/openhab/binding/zwave/internal/converter/ZWaveThermostatSetpointConverterTest.java | Replace reflection exception stack traces with logging; add SLF4J imports. |
| src/test/java/org/openhab/binding/zwave/handler/ZWaveThingHandlerTest.java | Replace reflection exception stack traces with logging; add SLF4J imports. |
| src/main/java/org/openhab/binding/zwave/internal/protocol/ZWaveTransactionManager.java | Replace some == comparisons with equals(); use isEmpty() for collection check. |
| src/main/java/org/openhab/binding/zwave/internal/protocol/initialization/ZWaveNodeInitStageAdvancer.java | Replace size check with isEmpty(). |
| src/main/java/org/openhab/binding/zwave/internal/protocol/commandclass/ZWaveSecurityCommandClass.java | Throw IllegalArgumentException on parse error; adjust error logging format. |
| src/main/java/org/openhab/binding/zwave/internal/protocol/commandclass/ZWaveMultiInstanceCommandClass.java | Replace size check with isEmpty(). |
| src/main/java/org/openhab/binding/zwave/internal/protocol/commandclass/ZWaveMeterTblMonitorCommandClass.java | Fix SLF4J logging to include exception properly. |
| src/main/java/org/openhab/binding/zwave/internal/protocol/commandclass/ZWaveAssociationGroupInfoCommandClass.java | Replace size check with isEmpty(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Kai Kreuzer <kai@openhab.org>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Kai Kreuzer <kai@openhab.org>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Kai Kreuzer <kai@openhab.org>
…ransaction Agent-Logs-Url: https://github.com/openhab/org.openhab.binding.zwave/sessions/7ca6782b-e102-4f27-8f0d-d0234743fd43 Co-authored-by: kaikreuzer <3244965+kaikreuzer@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Kai Kreuzer <kai@openhab.org>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Kai Kreuzer <kai@openhab.org>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Kai Kreuzer <kai@openhab.org>
|
Don't know the preference of maintainers, but on the firmware PR (unmerged) I replaced the e.printStackTrace(); with fail(e); Just a thought |
|
@apella12 Fair enough as well. I opted for merely switching out the printing method and thus not changing anything about the test's flow. With |
No description provided.