Commit 81b841f
committed
Reduce cognitive complexity in WebRTC + REST hot paths (S3776)
Each of the flagged ``S3776`` functions was split into smaller named
helpers — same behaviour, smaller per-function complexity. No public
API changed; tests still pass headless + WS + TLS.
webrtc_host.py:
- _handle_ctrl_message: dispatch dict + per-message handlers
(_handle_input_message / _handle_send_sas_message /
_handle_annotate / _handle_renegotiate_answer) plus a shared
_safe_audit_log so the rate-limit logging isn't duplicated.
- _async_apply_renegotiate_answer: split track re-subscription into
_maybe_resubscribe_viewer_video / _audio with a shared
_receiver_track helper.
- _handle_auth: split into _reject_auth + _auto_approve_via_trust /
_whitelist with early-return semantics.
- _snapshot_remote_ip: extract _extract_remote_ip so the nested
candidate-pair walk reads top-down.
webrtc_viewer.py:
- _handle_ctrl_message: dispatch dict and per-handler methods
matching the host side; _handle_inbox_op_result covers the two
inbox response variants.
webrtc_stats.py:
- _sample: factor candidate-pair / remote-inbound-rtp branches
into _absorb_entry / _absorb_remote_inbound.
adaptive_bitrate.py:
- on_stats: split into _react_to_hard_cap and _react_to_quality;
downscale / upscale logic each got their own helper plus
_should_downscale / _should_upscale predicates.
hw_codec.py:
- install_hardware_codec: extract _open_codec_context (codec init
+ libx264 fallback) and _shape_changed; the patched closure now
reads as a thin coordinator.
webrtc_dialogs.py:
- _refresh: extract _populate_row + _is_stale.
- _on_import: extract _prompt_import_data, _import_one,
_extract_fingerprints, _confirm_overwrite.
webrtc_panel.py:
- _read_webrtc_config: introduce _checked_or and _read_region
helpers to eliminate the long hasattr ladder.
- _on_sessions_context_menu: split into _trust_session_viewer +
_copy_session_id_to_clipboard.
webrtc_workers.py:
- HostPublishLoopWorker.run: extract _publish_one_session,
_handle_signaling_error, _safe_stop_session_if so the run loop
reads as a one-line state machine.
host_service.py:
- main: replace the long if/elif chain on args.command with a
module-level _COMMAND_DISPATCH dict and per-command helper
functions.
address_book.py:
- upsert: extract _find_entry_locked, _refresh_entry_locked,
_build_entry. The early return / merge / append flow now reads
linearly.
web_viewer/index.html:
- handleControlMessage: dispatch object + handleAuthOk /
verifyFingerprint / rememberFingerprint helpers replace the
if/else-if cascade.
- setLanguage: replace nested ternary with explicit if/elif chain.1 parent c2be066 commit 81b841f
11 files changed
Lines changed: 729 additions & 523 deletions
File tree
- je_auto_control
- gui/remote_desktop
- utils/remote_desktop
- web_viewer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
391 | 400 | | |
392 | 401 | | |
393 | 402 | | |
| |||
454 | 463 | | |
455 | 464 | | |
456 | 465 | | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
457 | 485 | | |
458 | 486 | | |
459 | 487 | | |
460 | 488 | | |
461 | 489 | | |
462 | | - | |
| 490 | + | |
463 | 491 | | |
464 | 492 | | |
465 | 493 | | |
466 | 494 | | |
467 | 495 | | |
468 | | - | |
| 496 | + | |
469 | 497 | | |
470 | 498 | | |
471 | 499 | | |
472 | 500 | | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
504 | 529 | | |
505 | | - | |
| 530 | + | |
| 531 | + | |
506 | 532 | | |
507 | | - | |
| 533 | + | |
508 | 534 | | |
509 | 535 | | |
510 | 536 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
151 | 171 | | |
152 | 172 | | |
153 | 173 | | |
154 | 174 | | |
155 | 175 | | |
156 | 176 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
179 | 181 | | |
| 182 | + | |
| 183 | + | |
180 | 184 | | |
181 | 185 | | |
182 | 186 | | |
183 | 187 | | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
| 188 | + | |
195 | 189 | | |
196 | | - | |
| 190 | + | |
197 | 191 | | |
198 | 192 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
210 | 200 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 201 | + | |
| 202 | + | |
216 | 203 | | |
217 | | - | |
218 | 204 | | |
219 | 205 | | |
220 | 206 | | |
| |||
995 | 981 | | |
996 | 982 | | |
997 | 983 | | |
998 | | - | |
| 984 | + | |
999 | 985 | | |
1000 | 986 | | |
1001 | 987 | | |
| |||
1019 | 1005 | | |
1020 | 1006 | | |
1021 | 1007 | | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
| 1008 | + | |
1032 | 1009 | | |
1033 | | - | |
1034 | | - | |
1035 | | - | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
1036 | 1029 | | |
1037 | 1030 | | |
1038 | 1031 | | |
| |||
0 commit comments