fix: resolve 3 SonarQube code quality issues in TransformationService#50
Open
sonarqube-agent[bot] wants to merge 1 commit intomainfrom
Open
fix: resolve 3 SonarQube code quality issues in TransformationService#50sonarqube-agent[bot] wants to merge 1 commit intomainfrom
sonarqube-agent[bot] wants to merge 1 commit intomainfrom
Conversation
Fixed issues: - AZZjJ298STHyJcTACtyF for java:S125 rule - AZZjJ298STHyJcTACtyA for java:S1141 rule - AZZjJ298STHyJcTACtyB for java:S112 rule Generated by SonarQube Agent (task: 56119646-0ae0-4a14-9ba2-d3fc0a996bc1)
Author
|
|
|
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 three SonarQube violations in TransformationService: replaced generic RuntimeException with specific IllegalStateException, extracted nested try block into separate fetchNextPage() method to improve readability, and removed dead commented code. These improvements enhance code maintainability and follow Java best practices for exception handling and code clarity.
View Project in SonarCloud
Fixed Issues
java:S112 - Replace generic exceptions with specific library exceptions or a custom exception. • MAJOR • View issue
Location:
src/main/java/fr/ans/psc/pscextract/service/TransformationService.java:400Why is this an issue?
Throwing generic exceptions such as
Error,RuntimeException,Throwable, andExceptionwill have a negative impact on any code trying to catch these exceptions.What changed
Replaces the generic
RuntimeExceptionwith the more specificIllegalStateException. This addresses the code smell about throwing generic exceptions, sinceIllegalStateExceptionis a specific exception that better communicates the nature of the error (the JVM is in an unexpected state where SHA256 digest is not available).java:S1141 - Extract this nested try block into a separate method. • MAJOR • View issue
Location:
src/main/java/fr/ans/psc/pscextract/service/TransformationService.java:344Why is this an issue?
Nesting
try/catchblocks severely impacts the readability of source code because it makes it too difficult to understand which block will catch which exception.What changed
Extracts the nested try block into a separate method call
fetchNextPage(), which eliminates the nested try/catch structure that severely impacted readability. Instead of having a try/catch nested inside another try block, the inner logic is now delegated to a helper method, and the result is checked via a simple null comparison.java:S125 - This block of commented-out lines of code should be removed. • MAJOR • View issue
Location:
src/main/java/fr/ans/psc/pscextract/service/TransformationService.java:78Why is this an issue?
Commented-out code distracts the focus from the actual executed code. It creates a noise that increases maintenance code. And because it is never executed, it quickly becomes out of date and invalid.
What changed
Removes the commented-out line of code
if (s.charAt(1) == '0') return s+','+'MSSante'+','+'1';which was flagged as a block of commented-out code that should be removed. The line is replaced with just a blank comment, eliminating the dead code that was distracting from the actual executed code.SonarQube Remediation Agent uses AI. Check for mistakes.