fix: remove redundant boolean check in discord/abc.py - #185
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
fix: remove redundant boolean check in discord/abc.py#185sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZUnUZZxU1G2OajCqWod for pythonbugs:S2589 rule Generated by SonarQube Agent (task: 74494d6e-a1f5-4be8-97a0-68ebb663d635)
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.
Removed an unnecessary ternary expression that always evaluated to true due to prior validation of the
aroundparameter. This fixes a SonarQube MAJOR issue (S2589) by simplifying the conditional logic and improving code clarity.View Project in SonarCloud
Fixed Issues
pythonbugs:S2589 - Fix this expression which always evaluates to "true". • MAJOR • View issue
Location:
discord/abc.py:1787Why is this an issue?
Control flow constructs like
if-statements allow the programmer to direct the flow of a program depending on a boolean expression. However, if the condition is always true or always false, only one of the branches will ever be executed. In that case, the control flow construct and the condition no longer serve a purpose; they become gratuitous.What changed
This hunk removes the gratuitous boolean expression
if around else Noneon line 1787 of discord/abc.py. At this point in the code, thearoundparameter has already been confirmed to be truthy (line 1783 checksnot aroundand this code is in the else branch), so the conditionalaround if around else Nonealways evaluates toaround— making the ternary expression always true and unnecessary. The fix simplifies the expression to justaround.id, removing the redundant check.SonarQube Remediation Agent uses AI. Check for mistakes.