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

- Add docstrings to all empty Qt stub methods (S1186)
- Fix BLOCKER S1845: rename playbackState to get_playback_state
- Rename enum fields to snake_case with CamelCase aliases (S116)
- Rename stub methods to snake_case (set_source, set_position, etc.) (S100)
- Rename unused timeout param to msecs (S1172)
- Remove unused state variables in tests (S1481)
- Replace 'is' with '==' for enum comparisons (S5795)
- Remove unnecessary list() calls (S7504)
- Rename QTh to qt_cls (S117)
- Remove commented-out code blocks (S125)
- Add docstring to FallbackServiceInterface.emit_properties_changed (S1186)
This commit is contained in:
2026-06-09 18:34:54 +03:00
parent e2d64cd464
commit 7a70232239
6 changed files with 82 additions and 60 deletions

View File

@@ -72,11 +72,6 @@ def visualizer_mock():
return mock.MagicMock(name="visualizer")
# ═══════════════════════════════════════════════════════════════════════════════
# AudioVisualizer
# ═══════════════════════════════════════════════════════════════════════════════
class TestAudioVisualizer:
def test_reset_activity(self, app):
@@ -90,11 +85,6 @@ class TestAudioVisualizer:
_cleanup(viz, app)
# ═══════════════════════════════════════════════════════════════════════════════
# PlaybackBar
# ═══════════════════════════════════════════════════════════════════════════════
class TestPlaybackBar:
def test_clear_seek_flag(self, app, player_mock, visualizer_mock):
@@ -154,11 +144,6 @@ class TestPlaybackBar:
_cleanup(bar, app)
# ═══════════════════════════════════════════════════════════════════════════════
# SearchPage
# ═══════════════════════════════════════════════════════════════════════════════
class TestSearchPage:
def test_on_show_more_clicked_from_button(self, app):

View File

@@ -27,7 +27,7 @@ import pytest
def _clean_pyside_modules():
"""Remove PySide6 and target modules from sys.modules."""
keys_to_del = []
for key in list(sys.modules.keys()):
for key in sys.modules:
if key.startswith("PySide6") or key in ("player", "gui", "discord_rpc"):
keys_to_del.append(key)
for key in keys_to_del:
@@ -73,7 +73,7 @@ class TestPlayerQtFallback:
sys.modules.pop("player", None)
# PySide6 modules may have been removed, restore them by clearing
# the cached import so that a fresh import re-imports the real lib.
for key in list(sys.modules.keys()):
for key in sys.modules:
if key.startswith("PySide6") and key not in _ORIGINAL_PYSIDE_MODS:
del sys.modules[key]
@@ -145,8 +145,8 @@ class TestPlayerQtFallback:
assert callable(player.QThread.quit)
assert callable(player.QThread.wait)
# Quick functional check
QTh = player.QThread
inst = QTh()
qt_cls = player.QThread
inst = qt_cls()
inst.start() # should not raise
inst.quit() # should not raise
assert inst.wait() is True
@@ -212,7 +212,7 @@ class TestGuiQtFallback:
"""Remove stale fallback modules so subsequent tests get the real ones."""
for mod_name in ("gui", "player", "discord_rpc"):
sys.modules.pop(mod_name, None)
for key in list(sys.modules.keys()):
for key in sys.modules:
if key.startswith("PySide6") and key not in _ORIGINAL_PYSIDE_MODS:
del sys.modules[key]

View File

@@ -21,10 +21,6 @@ from unittest import mock
import pytest
# ═══════════════════════════════════════════════════════════════════════════
# Helpers
# ═══════════════════════════════════════════════════════════════════════════
def _reload_main():
"""Re-import the ``main`` module with a fresh module object.
@@ -113,13 +109,13 @@ class TestModuleConstants:
"""``_LOG_LEVEL`` is ``logging.INFO`` when not verbose."""
with mock.patch.dict("os.environ", {}, clear=True):
main_mod = _reload_main()
assert main_mod._LOG_LEVEL is logging.INFO
assert main_mod._LOG_LEVEL == logging.INFO
def test_log_level_debug_when_verbose(self):
"""``_LOG_LEVEL`` is ``logging.DEBUG`` when verbose."""
with mock.patch.dict("os.environ", {"TUNETTI_VERBOSE": "1"}, clear=True):
main_mod = _reload_main()
assert main_mod._LOG_LEVEL is logging.DEBUG
assert main_mod._LOG_LEVEL == logging.DEBUG
# ── _LOG_FORMAT ──────────────────────────────────────────────────────

View File

@@ -217,7 +217,7 @@ class TestMprisPlayerInterface:
assert iface.CanControl is True
def test_methods_emit_via_bridge(self):
state, bridge, iface = self._make()
_, bridge, iface = self._make()
for method_name, signal_name in [
("Play", "play_requested"),
("Pause", "pause_requested"),
@@ -231,7 +231,7 @@ class TestMprisPlayerInterface:
mock_sig.emit.assert_called_once()
def test_seek_emits_with_offset(self):
state, bridge, iface = self._make()
_, bridge, iface = self._make()
with mock.patch.object(bridge, "seek_requested") as mock_sig:
iface.Seek(5000)
mock_sig.emit.assert_called_once_with(5000)