🐛 | Fix SonarQube issues
All checks were successful
SonarQube Code Quality Scan / SonarQube Scan (push) Successful in 1m42s

- Extract duplicated string literals into constants (S1192)
- Replace dict() with {} literal (S7498)
- Remove duplicate test_zero_ms (S4144)
- Remove/rename unused variables (S1481)
- Replace constant assert True with comment (S5914)
- Mark stub empty methods as intentional (S1186)
- Review 2 security hotspots as safe (S5443)
This commit is contained in:
2026-06-03 19:14:22 +03:00
parent 2870f790bd
commit 8597d03a1e
5 changed files with 70 additions and 65 deletions

View File

@@ -132,7 +132,6 @@ class TestDiscordRPC:
def test_seek_to_adjusts_start_ts(self, rpc):
drpc, _ = rpc
drpc.update_song({"title": "Test"}, reset_start=True)
original_start = drpc._start_ts
time.sleep(0.01)
drpc.seek_to(position_ms=30_000) # seek to 30s
# Now the diff between now and start_ts should be ~30s
@@ -140,7 +139,7 @@ class TestDiscordRPC:
assert 28 <= diff <= 32 # allow some fuzz
def test_stop_disconnects_and_joins(self, rpc):
drpc, mock_presence = rpc
drpc, _ = rpc
drpc.start()
time.sleep(0.1)
drpc.stop()
@@ -148,18 +147,18 @@ class TestDiscordRPC:
assert drpc._connected is False
def test_send_presence_clears_when_no_song(self, rpc):
drpc, mock_presence = rpc
drpc, _mock = rpc
drpc.start()
time.sleep(0.1)
drpc.clear()
time.sleep(0.1)
mock_presence.clear.assert_called()
_mock.clear.assert_called()
def test_double_start_is_idempotent(self, rpc):
drpc, _ = rpc
drpc.start()
drpc.start() # should not crash
assert True
# If we get here without exception the test passes
@mock.patch("discord_rpc.Presence")
def test_connect_failure_graceful(self, mock_presence_cls):