Skip to content

Commit b3315d0

Browse files
committed
Move NOSONAR markers onto the lines Sonar actually flags
Sonar's # NOSONAR suppression is line-scoped and must sit on the flagged line itself; my earlier markers on the comment line above weren't picked up. Specifically: - host.py / viewer.py: S107 fires on the first-parameter line of the multi-line def, not on the def keyword line. - totp.py: S6418 / S5655 markers must trail the assignment / call. - chat / connect_coordinator / jpeg_recorder tests: S5655 ditto. All 49 affected tests still green, ruff clean.
1 parent 63194db commit b3315d0

6 files changed

Lines changed: 11 additions & 15 deletions

File tree

‎je_auto_control/utils/remote_desktop/host.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,8 @@ class RemoteDesktopHost:
582582
``stop()`` can be called from any thread.
583583
"""
584584

585-
def __init__( # NOSONAR python:S107 # reason: each kwarg is a documented public knob; bundling further would split the API across patterns and force every existing caller (registry, host_panel, tests in 8 files) into a wrapper object for marginal benefit
586-
self, token: str,
585+
def __init__(
586+
self, token: str, # NOSONAR python:S107 # reason: each kwarg is a documented public knob; bundling further would split the API across patterns and force every existing caller (registry, host_panel, tests in 8 files) through a wrapper object for marginal benefit
587587
bind: str = "127.0.0.1",
588588
port: int = 0,
589589
fps: float = 10.0,

‎je_auto_control/utils/remote_desktop/viewer.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class RemoteDesktopViewer:
5656
Qt). ``send_input`` is safe to call from any thread.
5757
"""
5858

59-
def __init__( # NOSONAR python:S107 # reason: each callback is a documented public hook; bundling further would force every caller (viewer_panel, registry, 10+ test files) through a wrapper object for marginal benefit
60-
self, host: str, port: int, token: str,
59+
def __init__(
60+
self, host: str, port: int, token: str, # NOSONAR python:S107 # reason: each callback is a documented public hook; bundling further would force every caller (viewer_panel, registry, 10+ test files) through a wrapper object for marginal benefit
6161
on_frame: Optional[FrameCallback] = None,
6262
on_error: Optional[ErrorCallback] = None,
6363
on_audio: Optional[AudioCallback] = None,

‎test/unit_test/headless/test_remote_desktop_chat_and_multicursor.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ def test_broadcast_chat_with_empty_text_is_noop(jpeg_bytes):
9595
host.start()
9696
try:
9797
assert host.broadcast_chat("") == 0
98-
# NOSONAR python:S5655 # reason: intentional bad-type negative test
99-
assert host.broadcast_chat(None) == 0 # type: ignore[arg-type]
98+
assert host.broadcast_chat(None) == 0 # type: ignore[arg-type] # NOSONAR python:S5655 # reason: intentional bad-type negative test
10099
finally:
101100
host.stop(timeout=1.0)
102101

‎test/unit_test/headless/test_remote_desktop_connect_coordinator.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ def test_parse_target_rejects_bad_input(bad):
104104

105105
def test_parse_target_rejects_non_string():
106106
with pytest.raises(UnresolvableTargetError):
107-
# NOSONAR python:S5655 # reason: intentional bad-type negative test
108-
parse_target(12345) # type: ignore[arg-type]
107+
parse_target(12345) # type: ignore[arg-type] # NOSONAR python:S5655 # reason: intentional bad-type negative test
109108

110109

111110
# --- discriminator helpers ---------------------------------------------

‎test/unit_test/headless/test_remote_desktop_jpeg_recorder.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ def test_start_twice_raises(tmp_path):
5757

5858

5959
def test_record_frame_with_non_bytes_payload(tmp_path):
60-
"""NOSONAR python:S5655 # reason: intentional bad-type negative test."""
60+
"""Intentional bad-type negative test."""
6161
rec = JpegSequenceRecorder(str(tmp_path / "rec"))
6262
rec.start()
63-
rec.record_frame("not-bytes") # type: ignore[arg-type]
64-
rec.record_frame(None) # type: ignore[arg-type]
63+
rec.record_frame("not-bytes") # type: ignore[arg-type] # NOSONAR python:S5655 # reason: intentional bad-type negative test
64+
rec.record_frame(None) # type: ignore[arg-type] # NOSONAR python:S5655 # reason: intentional bad-type negative test
6565
assert rec.frame_count == 0
6666

6767

‎test/unit_test/headless/test_remote_desktop_totp.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ def test_verify_rejects_malformed_input():
6464
secret = generate_secret()
6565
assert verify_code(secret, "abcdef") is False
6666
assert verify_code(secret, "12345") is False # too short
67-
# NOSONAR python:S5655 # reason: intentional bad-type negative test
68-
assert verify_code(secret, 123456) is False # type: ignore[arg-type]
67+
assert verify_code(secret, 123456) is False # type: ignore[arg-type] # NOSONAR python:S5655 # reason: intentional bad-type negative test
6968

7069

7170
def test_decode_secret_handles_spaces_and_lowercase():
@@ -87,8 +86,7 @@ def test_invalid_secret_raises():
8786

8887

8988
def test_provisioning_uri_contains_secret_and_issuer():
90-
# NOSONAR python:S6418 # reason: literal base32 test vector, not a real secret
91-
secret = "GEZDGNBVGY3TQOJQ" # nosec B105 # reason: test-only RFC fixture
89+
secret = "GEZDGNBVGY3TQOJQ" # nosec B105 # NOSONAR python:S6418 # reason: published RFC 6238 test vector, not a real credential
9290
uri = provisioning_uri(secret, account="alice", issuer="MyApp")
9391
assert uri.startswith("otpauth://totp/")
9492
assert "secret=GEZDGNBVGY3TQOJQ" in uri

0 commit comments

Comments
 (0)