[Misc] Use dedicated assertions instead of boolean assertions in tests (SonarCloud java:S5785)#5834
Open
vmassol wants to merge 1 commit into
Open
[Misc] Use dedicated assertions instead of boolean assertions in tests (SonarCloud java:S5785)#5834vmassol wants to merge 1 commit into
vmassol wants to merge 1 commit into
Conversation
…s (SonarCloud java:S5785) * Replace assertTrue/assertFalse on equals(), ==, != and null checks with assertEquals/assertNotEquals/assertSame/assertNotNull across 11 test classes. Co-Authored-By: Vincent Massol <vincent@massol.net>
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.
Fixes 25 SonarCloud java:S5785 issues ("Use the assertions dedicated to the comparison, not
assertTrue/assertFalse") across 11 test classes.The boolean assertions are replaced with the assertion Sonar recommends for each site:
assertTrue(a.equals(b))/assertFalse(a.equals(b))→assertEquals(a, b)/assertNotEquals(a, b)(receiver kept first so the exact sameequalscall is reproduced)assertTrue(x == y)/assertFalse(x == y)reference identity →assertSame/ (assertNotSame)assertTrue(LIT == x)→assertEquals(LIT, x)assertTrue(x != null)→assertNotNull(x)Static imports are adjusted accordingly (unused
assertTrue/assertFalseremoved, new ones added).Behaviour-preserving; the affected test classes were run and pass.
SonarCloud rule: https://sonarcloud.io/organizations/xwiki/rules?open=java%3AS5785&rule_key=java%3AS5785
Generated by Claude Code