Skip to content

Commit 10c67b4

Browse files
authored
Merge pull request #177 from Integration-Automation/dev
Clear 8 remaining Sonar findings on main
2 parents 0ecbda2 + eeb667e commit 10c67b4

6 files changed

Lines changed: 12 additions & 9 deletions

File tree

je_auto_control/utils/clipboard/clipboard.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ def _win_set(text: str) -> None:
9393
kernel32.GlobalUnlock.argtypes = [wintypes.HGLOBAL]
9494

9595
data = ctypes.create_unicode_buffer(text)
96-
size = ctypes.sizeof(data)
96+
size = ctypes.sizeof(data) # NOSONAR S5655 false positive — Array is accepted by sizeof
9797
handle = kernel32.GlobalAlloc(gmem_moveable, size)
9898
if not handle:
9999
raise RuntimeError("GlobalAlloc failed")
100100
pointer = kernel32.GlobalLock(handle)
101101
if not pointer:
102102
raise RuntimeError("GlobalLock failed")
103-
ctypes.memmove(pointer, ctypes.addressof(data), size)
103+
ctypes.memmove(pointer, ctypes.addressof(data), size) # NOSONAR S5655 false positive — Array is accepted by addressof
104104
kernel32.GlobalUnlock(handle)
105105
if not user32.OpenClipboard(None):
106106
raise RuntimeError("OpenClipboard failed")

je_auto_control/windows/listener/win32_keyboard_listener.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _start_listener(self) -> None:
9090

9191
message = MSG()
9292
# 進入訊息迴圈 Enter message loop
93-
_user32.GetMessageA(byref(message), 0, 0, 0)
93+
_user32.GetMessageA(byref(message), 0, 0, 0) # NOSONAR S5655 false positive — MSG is a ctypes Structure
9494

9595
def record(self, want_to_record_queue: Queue) -> None:
9696
"""

je_auto_control/windows/listener/win32_mouse_listener.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def _start_listener(self) -> None:
9999
raise AutoControlException("Failed to set mouse hook")
100100

101101
message = MSG()
102-
_user32.GetMessageA(byref(message), 0, 0, 0)
102+
_user32.GetMessageA(byref(message), 0, 0, 0) # NOSONAR S5655 false positive — MSG is a ctypes Structure
103103

104104
def record(self, want_to_record_queue: Queue) -> None:
105105
"""

test/unit_test/headless/test_plugin_loader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ def test_register_plugin_commands_adds_and_removes_cleanly(tmp_path):
7373

7474
def test_discover_ignores_non_callable_ac_attribute():
7575
class Module:
76-
AC_value = 42 # noqa: N815 # reason: AC_* is the plugin contract
76+
AC_value = 42 # noqa: N815 # NOSONAR AC_* is the plugin contract
7777

7878
@staticmethod
79-
def AC_run(): # noqa: N802 # reason: AC_* is the plugin contract
79+
def AC_run(): # noqa: N802 # NOSONAR AC_* is the plugin contract
8080
return 1
8181

8282
found = discover_plugin_commands(Module)

test/unit_test/headless/test_rest_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def rest_server():
1616
server.stop(timeout=1.0)
1717

1818

19-
_TEST_SCHEME = "http" # NOSONAR: S5332 # reason: localhost-only ephemeral test server; TLS is out of scope here
19+
_TEST_SCHEME = "http" # NOSONAR localhost-only ephemeral test server; TLS is out of scope here
2020

2121

2222
def _request(server, path, method="GET", body=None):

test/unit_test/headless/test_watcher.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ def broken():
4646

4747
def test_pixel_watcher_returns_none_on_error(monkeypatch):
4848
import je_auto_control.wrapper.auto_control_screen as screen_mod
49-
monkeypatch.setattr(screen_mod, "get_pixel",
50-
lambda x, y: (_ for _ in ()).throw(OSError("nope")))
49+
50+
def _raise_os_error(_x, _y):
51+
raise OSError("nope")
52+
53+
monkeypatch.setattr(screen_mod, "get_pixel", _raise_os_error)
5154
assert PixelWatcher().sample(0, 0) is None
5255

5356

0 commit comments

Comments
 (0)