fix: resolve SonarQube issues in pokedex helper exception handling#3
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
fix: resolve SonarQube issues in pokedex helper exception handling#3sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZWCTWBhfksiPFt2jGS_ for python:S112 rule - AZWCTWBhfksiPFt2jGS- for python:S1045 rule - AZWCTWBhfksiPFt2jGTC for python:S3984 rule - AZWCTWBhfksiPFt2jGTA for python:S2772 rule Generated by SonarQube Agent (task: d81195d0-e5a4-4ebd-927f-993618debd9e)
SonarQube reviewer guide
|
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 4 SonarQube code quality issues in pokedex/helper.py: removed generic exception raising and dead code from exception handlers, added missing raise keyword for ValueError, and eliminated redundant pass statement. These changes improve exception specificity, code clarity, and prevent unreachable code paths.
View Project in SonarCloud
Fixed Issues
python:S112 - Replace this generic exception class with a more specific one. • MAJOR • View issue
Location:
pokedex/helper.py:20Why is this an issue?
Raising instances of
ExceptionandBaseExceptionwill have a negative impact on any code trying to catch these exceptions.What changed
Removes the original
except sqlite3.DatabaseErrorblock that raised a genericException(a code smell because generic exceptions should not be raised) and that also caused the subsequentexcept sqlite3.IntegrityErrorclause to be dead code, sinceIntegrityErroris a subclass ofDatabaseErrorand would never be reached after theDatabaseErrorhandler.python:S1045 - Catch this exception only once; it is already handled by a previous except clause. • MAJOR • View issue
Location:
pokedex/helper.py:21Why is this an issue?
Exceptions handlers (
except) are evaluated in the order they are written. Once a match is found, the evaluation stops.What changed
Removes the original
except sqlite3.DatabaseErrorblock that raised a genericException(a code smell because generic exceptions should not be raised) and that also caused the subsequentexcept sqlite3.IntegrityErrorclause to be dead code, sinceIntegrityErroris a subclass ofDatabaseErrorand would never be reached after theDatabaseErrorhandler.python:S3984 - Raise this exception or remove this useless statement. • MAJOR • View issue
Location:
pokedex/helper.py:36Why is this an issue?
Creating a new
Exceptionwithout actually raising it has no effect and is probably due to a mistake.What changed
Adds the missing
raisekeyword beforeValueError("Invalid email!"). Withoutraise, the exception was being created but never raised, making the statement a no-op. Now the exception is properly raised when an invalid email is encountered.python:S2772 - Remove this unneeded "pass". • MINOR • View issue
Location:
pokedex/helper.py:38Why is this an issue?
The use of a
passstatement where it is not required by the syntax is redundant. It makes the code less readable and its intent confusing.What changed
Removes the redundant
passstatement that served no purpose since there was already other code in the block. This eliminates the code smell of having an unnecessarypassthat reduces readability.SonarQube Remediation Agent uses AI. Check for mistakes.