Replace try-catch-fail patterns with AssertJ assertions in ExplodedGraphWalkerTest#114
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
Replace try-catch-fail patterns with AssertJ assertions in ExplodedGraphWalkerTest#114sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZ6v0pMz6JKQzmjWaPz_ for java:S8714 rule - AZ6v0pMz6JKQzmjWaP0F for java:S8714 rule - AZ6v0pMz6JKQzmjWaP0G for java:S8714 rule - AZ6v0pMz6JKQzmjWaP0H for java:S8714 rule - AZ6v0pMz6JKQzmjWaP0I for java:S8714 rule Generated by SonarQube Agent (task: 6e2bc1c1-aa9c-43b2-9b2a-a3cd8f680fff)
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.
Replaces five instances of try-catch-fail patterns with proper AssertJ assertion methods (
assertThatCode().doesNotThrowAnyException()andassertThatThrownBy()) in the test file. This improves test code readability and maintainability by using modern assertion APIs that more clearly express intent.View Project in SonarCloud
Fixed Issues
java:S8714 - Use assertDoesNotThrow() instead of try/catch and fail() in the catch block. • MINOR • View issue
Location:
sonar-java-symbolic-execution:java-symbolic-execution/java-symbolic-execution-plugin/src/test/java/org/sonar/java/se/ExplodedGraphWalkerTest.java:302Why is this an issue?
Modern assertion libraries have made the clunky
try-fail-catchpattern obsolete by introducing cleaner alternatives. For example, starting with JUnit 5, JUnit Jupiter providesassertThrowsandassertDoesNotThrow. AssertJ offers similar methods.What changed
Adds the import for
assertThatCodefrom AssertJ, which is needed by other hunks that replace try-catch-fail patterns withassertThatCode(...).doesNotThrowAnyException(). This directly supports fixing the issue at line 302 where a try-catch with fail() in the catch block was used to verify no exception is thrown.java:S8714 - Use assertThrows() instead of try/catch and fail() in the try block. • MINOR • View issue
Location:
sonar-java-symbolic-execution:java-symbolic-execution/java-symbolic-execution-plugin/src/test/java/org/sonar/java/se/ExplodedGraphWalkerTest.java:362Why is this an issue?
Modern assertion libraries have made the clunky
try-fail-catchpattern obsolete by introducing cleaner alternatives. For example, starting with JUnit 5, JUnit Jupiter providesassertThrowsandassertDoesNotThrow. AssertJ offers similar methods.What changed
Removes the import of
failfrom AssertJ, since all usages offail()in try-catch blocks have been replaced with proper assertion methods (assertThatCodeandassertThatThrownBy). This cleanup supports all five issues where try-catch-fail patterns were flagged as code smells.java:S8714 - Use assertThrows() instead of try/catch and fail() in the try block. • MINOR • View issue
Location:
sonar-java-symbolic-execution:java-symbolic-execution/java-symbolic-execution-plugin/src/test/java/org/sonar/java/se/ExplodedGraphWalkerTest.java:362Why is this an issue?
Modern assertion libraries have made the clunky
try-fail-catchpattern obsolete by introducing cleaner alternatives. For example, starting with JUnit 5, JUnit Jupiter providesassertThrowsandassertDoesNotThrow. AssertJ offers similar methods.What changed
Removes the import of
failfrom AssertJ, since all usages offail()in try-catch blocks have been replaced with proper assertion methods (assertThatCodeandassertThatThrownBy). This cleanup supports all five issues where try-catch-fail patterns were flagged as code smells.java:S8714 - Use assertThrows() instead of try/catch and fail() in the try block. • MINOR • View issue
Location:
sonar-java-symbolic-execution:java-symbolic-execution/java-symbolic-execution-plugin/src/test/java/org/sonar/java/se/ExplodedGraphWalkerTest.java:392Why is this an issue?
Modern assertion libraries have made the clunky
try-fail-catchpattern obsolete by introducing cleaner alternatives. For example, starting with JUnit 5, JUnit Jupiter providesassertThrowsandassertDoesNotThrow. AssertJ offers similar methods.What changed
Removes the import of
failfrom AssertJ, since all usages offail()in try-catch blocks have been replaced with proper assertion methods (assertThatCodeandassertThatThrownBy). This cleanup supports all five issues where try-catch-fail patterns were flagged as code smells.java:S8714 - Use assertThrows() instead of try/catch and fail() in the try block. • MINOR • View issue
Location:
sonar-java-symbolic-execution:java-symbolic-execution/java-symbolic-execution-plugin/src/test/java/org/sonar/java/se/ExplodedGraphWalkerTest.java:392Why is this an issue?
Modern assertion libraries have made the clunky
try-fail-catchpattern obsolete by introducing cleaner alternatives. For example, starting with JUnit 5, JUnit Jupiter providesassertThrowsandassertDoesNotThrow. AssertJ offers similar methods.What changed
Removes the import of
failfrom AssertJ, since all usages offail()in try-catch blocks have been replaced with proper assertion methods (assertThatCodeandassertThatThrownBy). This cleanup supports all five issues where try-catch-fail patterns were flagged as code smells.SonarQube Remediation Agent uses AI. Check for mistakes.