Commit 562b541
committed
Address SonarCloud + Codacy findings on PR #181
Round-up of every issue both scanners flagged on this branch:
Library code:
- Drop unused imports (NONCE_BYTES in host.py, dataclasses.field in
file_transfer.py).
- Replace the 17-parameter RemoteDesktopHost.__init__ with an
AudioCaptureConfig dataclass (S107). GUI and tests now pass
audio_config=AudioCaptureConfig(enabled=True, ...) instead of five
separate kwargs, taking the parameter list down to 13.
- Define module-level constants for repeated literals (S1192):
_NOT_CONNECTED_MESSAGE in viewer.py, _OPEN_CLIPBOARD_FAILED in
clipboard.py, _INVALID_TRANSFER_ID_MESSAGE in file_transfer.py.
- Refactor RemoteDesktopViewer._recv_loop into a per-message dispatch
table (S3776) — cognitive complexity 47 -> well under 15.
- Float equality on host.py:638 sleep_for == 0.0 -> <= 0.0 (S1244).
- Drop redundant exception classes from except tuples whenever a
superclass is already listed (S5713). ConnectionError, ssl.SSLError
and TimeoutError all derive from OSError.
- ws_protocol.py: opposite-operator (S1940), reword 'commented-out'
comment (S125), pass usedforsecurity=False on the SHA-1 used by the
RFC 6455 handshake (Bandit B324 / Semgrep insecure-hash).
- audio.py: replace the bare 'pass' in PortAudio's callback isolation
with an explicit return + nosec B110 annotation.
- All ssl.SSLContext(...) calls now set minimum_version = TLSv1_2
(S4423). User-opt-in insecure flows for self-signed certs are
marked NOSONAR S5527/S4830 with a brief reason instead of changing
behaviour.
GUI:
- Drop unused imports (os, QClipboard, QApplication, send_file).
- Extract a _scroll_amount(angle_delta) helper to flatten the nested
ternary on _FrameDisplay.wheelEvent (S3358).
Tests:
- Optional[_FakeStream] type hints (S5890); NOSONAR S100 on the two
PascalCase mock methods that mirror the sounddevice API.
- Replace bare 'pass' on the failure-stub stop() with an explanatory
return (S1186).
- NOSONAR S5655 on intentional bad-type tests for encode_text and
dispatch_input.
- Rename the unused 'tid' tuple element to '_tid' (S1481).
- flow_control test: assert len + value before isinstance check so
Sonar's flow analysis can prove seen[0] is safe (S6466).
Behaviour is unchanged; tests still 295 pass on Windows.1 parent a1df760 commit 562b541
13 files changed
Lines changed: 191 additions & 118 deletions
File tree
- je_auto_control
- gui
- utils
- clipboard
- remote_desktop
- test/unit_test
- flow_control
- headless
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
24 | | - | |
| 23 | + | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | | - | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | | - | |
| 41 | + | |
| 42 | + | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
105 | 113 | | |
106 | 114 | | |
107 | 115 | | |
| |||
209 | 217 | | |
210 | 218 | | |
211 | 219 | | |
212 | | - | |
213 | | - | |
| 220 | + | |
214 | 221 | | |
215 | 222 | | |
216 | 223 | | |
| |||
433 | 440 | | |
434 | 441 | | |
435 | 442 | | |
| 443 | + | |
436 | 444 | | |
437 | 445 | | |
438 | 446 | | |
| |||
443 | 451 | | |
444 | 452 | | |
445 | 453 | | |
446 | | - | |
| 454 | + | |
447 | 455 | | |
448 | 456 | | |
449 | 457 | | |
| |||
459 | 467 | | |
460 | 468 | | |
461 | 469 | | |
462 | | - | |
463 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
464 | 474 | | |
465 | 475 | | |
466 | 476 | | |
| |||
686 | 696 | | |
687 | 697 | | |
688 | 698 | | |
689 | | - | |
| 699 | + | |
690 | 700 | | |
691 | 701 | | |
692 | 702 | | |
| |||
705 | 715 | | |
706 | 716 | | |
707 | 717 | | |
| 718 | + | |
708 | 719 | | |
| 720 | + | |
709 | 721 | | |
710 | 722 | | |
711 | 723 | | |
| |||
827 | 839 | | |
828 | 840 | | |
829 | 841 | | |
830 | | - | |
| 842 | + | |
831 | 843 | | |
832 | 844 | | |
833 | 845 | | |
| |||
859 | 871 | | |
860 | 872 | | |
861 | 873 | | |
862 | | - | |
| 874 | + | |
863 | 875 | | |
864 | 876 | | |
865 | 877 | | |
| |||
925 | 937 | | |
926 | 938 | | |
927 | 939 | | |
928 | | - | |
| 940 | + | |
929 | 941 | | |
930 | 942 | | |
931 | 943 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
86 | | - | |
| 88 | + | |
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| |||
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
134 | | - | |
| 136 | + | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| |||
256 | 258 | | |
257 | 259 | | |
258 | 260 | | |
259 | | - | |
| 261 | + | |
260 | 262 | | |
261 | 263 | | |
262 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
50 | 62 | | |
51 | 63 | | |
52 | 64 | | |
| |||
125 | 137 | | |
126 | 138 | | |
127 | 139 | | |
128 | | - | |
| 140 | + | |
129 | 141 | | |
130 | | - | |
| 142 | + | |
131 | 143 | | |
132 | 144 | | |
133 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | | - | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| |||
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
73 | | - | |
| 77 | + | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| |||
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
87 | | - | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| |||
257 | 261 | | |
258 | 262 | | |
259 | 263 | | |
260 | | - | |
| 264 | + | |
261 | 265 | | |
262 | 266 | | |
263 | 267 | | |
| |||
0 commit comments