Resolve SonarQube naming conflicts and code smell issues - #187
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
Resolve SonarQube naming conflicts and code smell issues#187sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZUnUZfqU1G2OajCqWoj for python:S3516 rule - AZUnUZjWU1G2OajCqWpA for python:S1845 rule - AZUnUZjWU1G2OajCqWpB for python:S1845 rule - AZUnUZjWU1G2OajCqWo- for python:S1845 rule - AZUnUZjWU1G2OajCqWo_ for python:S1845 rule Generated by SonarQube Agent (task: bf7ac9ba-30b8-4e35-9b8e-587dcc6c1caa)
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 5 SonarQube blocker issues in discord/app_commands by renaming class fields GUILD and USER to _GUILD_TYPE and _USER_TYPE to eliminate capitalization-only naming clashes with property methods, and refactored a cooldown decorator predicate to remove redundant return statements. These changes improve code clarity and eliminate false positives in static analysis.
View Project in SonarCloud
Fixed Issues
python:S1845 - Rename method "guild" to prevent any misunderstanding/clash with field "GUILD" defined on line 53 • BLOCKER • View issue
Location:
discord/app_commands/installs.py:61Why is this an issue?
Looking at the set of methods and fields in a
classand finding two that differ only by capitalization is confusing to users of the class.What changed
Renames the class-level fields
GUILDandUSERto_GUILD_TYPEand_USER_TYPErespectively. This eliminates all capitalization-only naming clashes: theguildproperty getter and setter methods clashed with theGUILDfield, and theuserproperty getter and setter methods clashed with theUSERfield. By renaming the fields to_GUILD_TYPEand_USER_TYPE, the names are now sufficiently distinct from theguildanduserproperty methods, resolving all five capitalization-only naming conflicts including theguildsetter which also conflicted withGUILD.python:S1845 - Rename method "guild" to prevent any misunderstanding/clash with field "GUILD" defined on line 53 • BLOCKER • View issue
Location:
discord/app_commands/installs.py:66Why is this an issue?
Looking at the set of methods and fields in a
classand finding two that differ only by capitalization is confusing to users of the class.What changed
Renames the class-level fields
GUILDandUSERto_GUILD_TYPEand_USER_TYPErespectively. This eliminates all capitalization-only naming clashes: theguildproperty getter and setter methods clashed with theGUILDfield, and theuserproperty getter and setter methods clashed with theUSERfield. By renaming the fields to_GUILD_TYPEand_USER_TYPE, the names are now sufficiently distinct from theguildanduserproperty methods, resolving all five capitalization-only naming conflicts including theguildsetter which also conflicted withGUILD.python:S1845 - Rename method "user" to prevent any misunderstanding/clash with field "USER" defined on line 54 • BLOCKER • View issue
Location:
discord/app_commands/installs.py:70Why is this an issue?
Looking at the set of methods and fields in a
classand finding two that differ only by capitalization is confusing to users of the class.What changed
Renames the class-level fields
GUILDandUSERto_GUILD_TYPEand_USER_TYPErespectively. This eliminates all capitalization-only naming clashes: theguildproperty getter and setter methods clashed with theGUILDfield, and theuserproperty getter and setter methods clashed with theUSERfield. By renaming the fields to_GUILD_TYPEand_USER_TYPE, the names are now sufficiently distinct from theguildanduserproperty methods, resolving all five capitalization-only naming conflicts including theguildsetter which also conflicted withGUILD.python:S1845 - Rename method "user" to prevent any misunderstanding/clash with field "USER" defined on line 54 • BLOCKER • View issue
Location:
discord/app_commands/installs.py:75Why is this an issue?
Looking at the set of methods and fields in a
classand finding two that differ only by capitalization is confusing to users of the class.What changed
Renames the class-level fields
GUILDandUSERto_GUILD_TYPEand_USER_TYPErespectively. This eliminates all capitalization-only naming clashes: theguildproperty getter and setter methods clashed with theGUILDfield, and theuserproperty getter and setter methods clashed with theUSERfield. By renaming the fields to_GUILD_TYPEand_USER_TYPE, the names are now sufficiently distinct from theguildanduserproperty methods, resolving all five capitalization-only naming conflicts including theguildsetter which also conflicted withGUILD.python:S3516 - Refactor this method to not always return the same value. • BLOCKER • View issue
Location:
discord/app_commands/checks.py:398Why is this an issue?
When a function is designed to return an invariant value, it may be poor design, but it shouldn’t adversely affect the outcome of your program. However, when it happens on all paths through the logic, it is surely a bug.
What changed
This hunk refactors the predicate function in
_create_cooldown_decoratorto have only a singlereturn Truestatement instead of two separate ones. The original code had two code paths both returningTrue(whenbucket is Noneand whenretry_after is None), which triggered the code smell about a function always returning the same value on all return paths. By inverting the conditions and consolidating the logic, the function now has only onereturn Trueat the end, eliminating the redundant return statements while preserving the same behavior (raisingCommandOnCooldownwhen appropriate, otherwise returningTrue).SonarQube Remediation Agent uses AI. Check for mistakes.