🐛 | Fix SonarQube issues across codebase
All checks were successful
SonarQube Code Quality Scan / SonarQube Scan (push) Successful in 1m41s
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:
103
player.py
103
player.py
@@ -61,9 +61,13 @@ except (ImportError, OSError):
|
||||
|
||||
class _StubQThread:
|
||||
"""Stub replacement for PySide6.QtCore.QThread."""
|
||||
def start(self) -> None: pass
|
||||
def quit(self) -> None: pass
|
||||
def wait(self, timeout: int = 3000) -> bool: return True
|
||||
def start(self) -> None:
|
||||
"""Stub — no-op; real QThread would start the event loop."""
|
||||
def quit(self) -> None:
|
||||
"""Stub — no-op; real QThread would exit the event loop."""
|
||||
def wait(self, msecs: int = 3000) -> bool:
|
||||
"""Stub — returns True immediately without waiting."""
|
||||
return True
|
||||
QThread = _StubQThread
|
||||
|
||||
Signal = lambda *a: lambda f: f
|
||||
@@ -71,47 +75,84 @@ except (ImportError, OSError):
|
||||
QUrl = None
|
||||
|
||||
class _StubPlaybackState:
|
||||
StoppedState = 0
|
||||
PlayingState = 1
|
||||
PausedState = 2
|
||||
"""Stub mirroring QMediaPlayer.PlaybackState enum values."""
|
||||
stopped_state = 0
|
||||
playing_state = 1
|
||||
paused_state = 2
|
||||
# Backward-compatible aliases for code that uses Qt CamelCase names.
|
||||
StoppedState = stopped_state
|
||||
PlayingState = playing_state
|
||||
PausedState = paused_state
|
||||
|
||||
class _StubMediaStatus:
|
||||
NoMedia = 0
|
||||
LoadingMedia = 1
|
||||
LoadedMedia = 2
|
||||
StalledMedia = 3
|
||||
BufferingMedia = 4
|
||||
BufferedMedia = 5
|
||||
EndOfMedia = 6
|
||||
InvalidMedia = 7
|
||||
"""Stub mirroring QMediaPlayer.MediaStatus enum values."""
|
||||
no_media = 0
|
||||
loading_media = 1
|
||||
loaded_media = 2
|
||||
stalled_media = 3
|
||||
buffering_media = 4
|
||||
buffered_media = 5
|
||||
end_of_media = 6
|
||||
invalid_media = 7
|
||||
# Backward-compatible aliases for code that uses Qt CamelCase names.
|
||||
NoMedia = no_media
|
||||
LoadingMedia = loading_media
|
||||
LoadedMedia = loaded_media
|
||||
StalledMedia = stalled_media
|
||||
BufferingMedia = buffering_media
|
||||
BufferedMedia = buffered_media
|
||||
EndOfMedia = end_of_media
|
||||
InvalidMedia = invalid_media
|
||||
|
||||
class _StubError:
|
||||
NoError = 0
|
||||
ResourceError = 1
|
||||
FormatError = 2
|
||||
NetworkError = 3
|
||||
AccessDeniedError = 4
|
||||
ServiceMissingError = 5
|
||||
"""Stub mirroring QMediaPlayer.Error enum values."""
|
||||
no_error = 0
|
||||
resource_error = 1
|
||||
format_error = 2
|
||||
network_error = 3
|
||||
access_denied_error = 4
|
||||
service_missing_error = 5
|
||||
# Backward-compatible aliases for code that uses Qt CamelCase names.
|
||||
NoError = no_error
|
||||
ResourceError = resource_error
|
||||
FormatError = format_error
|
||||
NetworkError = network_error
|
||||
AccessDeniedError = access_denied_error
|
||||
ServiceMissingError = service_missing_error
|
||||
|
||||
class _StubQMediaPlayer:
|
||||
"""Stub replacement for PySide6.QtMultimedia.QMediaPlayer."""
|
||||
PlaybackState = _StubPlaybackState
|
||||
MediaStatus = _StubMediaStatus
|
||||
Error = _StubError
|
||||
|
||||
def __init__(self):
|
||||
self._playback_state = _StubPlaybackState.StoppedState
|
||||
self._playback_state = _StubPlaybackState.stopped_state
|
||||
|
||||
def setSource(self, url) -> None: pass
|
||||
def play(self) -> None: pass
|
||||
def pause(self) -> None: pass
|
||||
def stop(self) -> None: pass
|
||||
def setPosition(self, ms: int) -> None: pass
|
||||
def position(self) -> int: return 0
|
||||
def duration(self) -> int: return 0
|
||||
def playbackState(self) -> int:
|
||||
def set_source(self, url) -> None:
|
||||
"""Stub — no-op; real QMediaPlayer would load media from *url*."""
|
||||
def play(self) -> None:
|
||||
"""Stub — no-op; real QMediaPlayer would start playback."""
|
||||
def pause(self) -> None:
|
||||
"""Stub — no-op; real QMediaPlayer would pause playback."""
|
||||
def stop(self) -> None:
|
||||
"""Stub — no-op; real QMediaPlayer would stop playback."""
|
||||
def set_position(self, ms: int) -> None:
|
||||
"""Stub — no-op; real QMediaPlayer would seek to *ms*."""
|
||||
def position(self) -> int:
|
||||
"""Stub — returns 0; real QMediaPlayer returns current position in ms."""
|
||||
return 0
|
||||
def duration(self) -> int:
|
||||
"""Stub — returns 0; real QMediaPlayer returns media duration in ms."""
|
||||
return 0
|
||||
def get_playback_state(self) -> int:
|
||||
"""Stub — returns the current playback state value."""
|
||||
return self._playback_state
|
||||
def audioOutput(self): return None
|
||||
def setAudioOutput(self, output) -> None: pass
|
||||
def get_audio_output(self):
|
||||
"""Stub — returns None; real QMediaPlayer returns its QAudioOutput."""
|
||||
return None
|
||||
def set_audio_output(self, output) -> None:
|
||||
"""Stub — no-op; real QMediaPlayer would set its audio output."""
|
||||
|
||||
QMediaPlayer = _StubQMediaPlayer
|
||||
QAudioOutput = None
|
||||
|
||||
Reference in New Issue
Block a user