Skip to content

Rename gateway methods to avoid opcode name clashes - #189

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260622-010127-b7f90fa6
Open

Rename gateway methods to avoid opcode name clashes#189
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260622-010127-b7f90fa6

Conversation

@sonarqube-agent

Copy link
Copy Markdown

This PR was automatically created by the Remediation Agent's Scheduled backlog remediation feature.

Why these issues? These fixes are tightly scoped to one file and one rule family, so they are easy to review and low risk to merge together. Addressing all five capitalization-only method/constant conflicts in the gateway layer provides a clean, coherent improvement with immediate static-analysis payoff.

Renamed several Discord gateway methods to remove capitalization-only clashes with opcode constants: voice_state, resume, identify, select_protocol, and client_connect. This makes the code clearer and resolves the five SonarQube blocker issues flagged by the naming rule.

View Project in SonarCloud


Fixed Issues

python:S1845 - Rename method "voice_state" to prevent any misunderstanding/clash with field "VOICE_STATE" defined on line 302 • BLOCKERView issue

Location: discord/gateway.py:735

Why is this an issue?

Looking at the set of methods and fields in a class and finding two that differ only by capitalization is confusing to users of the class.

What changed

This hunk renames the voice_state method to update_voice_state, removing the name clash with the VOICE_STATE field that differed only by capitalization. The new name is also more action-oriented, which is exactly what the static analysis warning was asking for.

--- a/discord/gateway.py
+++ b/discord/gateway.py
@@ -735,1 +735,1 @@ class DiscordWebSocket:
-    async def voice_state(
+    async def update_voice_state(
python:S1845 - Rename method "resume" to prevent any misunderstanding/clash with field "RESUME" defined on line 812 • BLOCKERView issue

Location: discord/gateway.py:843

Why is this an issue?

Looking at the set of methods and fields in a class and finding two that differ only by capitalization is confusing to users of the class.

What changed

This hunk renames the resume method to send_resume, which resolves the capitalization-only clash with the RESUME field. Adding send_ makes the method name clearly describe an action instead of looking like the opcode constant.

--- a/discord/gateway.py
+++ b/discord/gateway.py
@@ -843,1 +843,1 @@ class DiscordVoiceWebSocket:
-    async def resume(self) -> None:
+    async def send_resume(self) -> None:
python:S1845 - Rename method "identify" to prevent any misunderstanding/clash with field "IDENTIFY" defined on line 805 • BLOCKERView issue

Location: discord/gateway.py:855

Why is this an issue?

Looking at the set of methods and fields in a class and finding two that differ only by capitalization is confusing to users of the class.

What changed

This hunk renames the identify method to send_identify, fixing the capitalization-only naming conflict with the IDENTIFY field. The new name makes it clear this is the method that sends that payload.

--- a/discord/gateway.py
+++ b/discord/gateway.py
@@ -855,1 +855,1 @@ class DiscordVoiceWebSocket:
-    async def identify(self) -> None:
+    async def send_identify(self) -> None:
python:S1845 - Rename method "select_protocol" to prevent any misunderstanding/clash with field "SELECT_PROTOCOL" defined on line 806 • BLOCKERView issue

Location: discord/gateway.py:894

Why is this an issue?

Looking at the set of methods and fields in a class and finding two that differ only by capitalization is confusing to users of the class.

What changed

This hunk renames select_protocol to select_voice_protocol, eliminating the confusing capitalization-only overlap with the SELECT_PROTOCOL field. The new name is more descriptive and clearly indicates this is a method performing an action.

--- a/discord/gateway.py
+++ b/discord/gateway.py
@@ -894,1 +894,1 @@ class DiscordVoiceWebSocket:
-    async def select_protocol(self, ip: str, port: int, mode: int) -> None:
+    async def select_voice_protocol(self, ip: str, port: int, mode: int) -> None:
python:S1845 - Rename method "client_connect" to prevent any misunderstanding/clash with field "CLIENT_CONNECT" defined on line 815 • BLOCKERView issue

Location: discord/gateway.py:909

Why is this an issue?

Looking at the set of methods and fields in a class and finding two that differ only by capitalization is confusing to users of the class.

What changed

This hunk renames client_connect to send_client_connect, which resolves the clash with the CLIENT_CONNECT field whose name differed only by capitalization. The renamed method now reads as an action rather than a constant-like identifier.

--- a/discord/gateway.py
+++ b/discord/gateway.py
@@ -909,1 +909,1 @@ class DiscordVoiceWebSocket:
-    async def client_connect(self) -> None:
+    async def send_client_connect(self) -> None:

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZUnUZllU1G2OajCqWpt for python:S1845 rule
- AZUnUZllU1G2OajCqWpw for python:S1845 rule
- AZUnUZllU1G2OajCqWpu for python:S1845 rule
- AZUnUZllU1G2OajCqWpv for python:S1845 rule
- AZUnUZllU1G2OajCqWpq for python:S1845 rule

Generated by SonarQube Agent (task: 5df7083c-bf1d-40c6-b868-afa45307715e)
@sonarqube-agent

Copy link
Copy Markdown
Author

⚠️ This repository does not have a CODEOWNERS file. The PR has been created but has not been automatically assigned to any reviewer. To ensure PRs are reviewed promptly, consider adding a CODEOWNERS file to your repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant