SLCORE-2411 fix: use isZero() assertion in VersionTests#2096
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
SLCORE-2411 fix: use isZero() assertion in VersionTests#2096sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZjRnl1RCue1PWb8I6bp for java:S5838 rule Generated by SonarQube Agent (task: 5c3f9d2f-71e5-445b-a5b6-9ae245273b4c)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. • MINOR • View issue
Location:
sonarlint-core-parent:backend/commons/src/test/java/org/sonarsource/sonarlint/core/commons/VersionTests.java:34Why 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)withassertThat(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.SonarQube Remediation Agent uses AI. Check for mistakes.