Skip to content

SLCORE-2411 fix: use isZero() assertion in VersionTests#2096

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260527-075029-a5cae38e
Open

SLCORE-2411 fix: use isZero() assertion in VersionTests#2096
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260527-075029-a5cae38e

Conversation

@sonarqube-agent
Copy link
Copy Markdown
Contributor

This PR was created because a team member assigned these issues to the Remediation Agent.

Replace generic isEqualTo(0) with AssertJ's dedicated isZero() assertion method for improved error messages and better code clarity. This addresses a SonarQube recommendation to follow AssertJ best practices.

View Project in SonarCloud


Fixed Issues

java:S5838 - Use isZero() instead. • MINORView issue

Location: sonarlint-core-parent:backend/commons/src/test/java/org/sonarsource/sonarlint/core/commons/VersionTests.java:34

Why is this an issue?

AssertJ contains many assertions methods specific to common types. Both versions will test the same things, but the dedicated one will provide a better error message, simplifying the debugging process.

What changed

Replaces assertThat(version.getBuild()).isEqualTo(0) with assertThat(version.getBuild()).isZero(), which uses the dedicated AssertJ assertion method for checking zero values. This provides better error messages on failure and follows AssertJ best practices as recommended by the static analysis rule.

--- a/backend/commons/src/test/java/org/sonarsource/sonarlint/core/commons/VersionTests.java
+++ b/backend/commons/src/test/java/org/sonarsource/sonarlint/core/commons/VersionTests.java
@@ -34,1 +34,1 @@ class VersionTests {
-    assertThat(version.getBuild()).isEqualTo(0);
+    assertThat(version.getBuild()).isZero();

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZjRnl1RCue1PWb8I6bp for java:S5838 rule

Generated by SonarQube Agent (task: 5c3f9d2f-71e5-445b-a5b6-9ae245273b4c)
@sonarqube-agent sonarqube-agent AI requested a review from henryju May 27, 2026 07:51
@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title fix: use isZero() assertion in VersionTests SLCORE-2411 fix: use isZero() assertion in VersionTests May 27, 2026
@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod Bot commented May 27, 2026

SLCORE-2411

@henryju henryju removed their request for review May 27, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant