Correct assertion argument order in NotebookParsingDataTest#2291
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
Correct assertion argument order in NotebookParsingDataTest#2291sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZ6nl5xRqzNTKShd3hv1 for java:S3415 rule Generated by SonarQube Agent (task: fb8437fe-faca-4ed6-8d4e-cd07f854132e)
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.
Fixed a SonarQube issue by swapping the arguments of an assertNotEquals call to follow the correct convention of (expected, actual). This ensures that assertion failure messages will be clear and meaningful, with the expected value appearing first as intended.
View Project in SonarCloud
Fixed Issues
java:S3415 - Swap these 2 arguments so they are in the correct order: expected value, actual value. • MAJOR • View issue
Location:
python-commons/src/test/java/org/sonar/plugins/python/NotebookParsingDataTest.java:103Why is this an issue?
The standard assertions library methods such as
org.junit.Assert.assertEquals, andorg.junit.Assert.assertSameexpect the first argument to be the expected value and the second argument to be the actual value. For AssertJ instead, the argument oforg.assertj.core.api.Assertions.assertThatis the actual value, and the subsequent calls contain the expected values.What changed
This hunk swaps the arguments of
assertNotEqualsso that the hard-coded expected value ("test") comes first and the actual value (empty) comes second. The static analysis rule flags cases where the expected and actual arguments are in the wrong order in assertion methods, which would produce misleading error messages on test failure. By changingassertNotEquals(empty, "test")toassertNotEquals("test", empty), the arguments now follow the correct convention of (expected, actual). This also addresses the related flow indicating that the other argument needed to be swapped, as both arguments are now in their proper positions.SonarQube Remediation Agent uses AI. Check for mistakes.