Private
Public Access
refactor(src): Phase 10.2 batch 4 - aggregate + api_hooks + context_presets + external_editor
aggregate.py (1 site): - compute_file_stats returns Result[dict[str, int]]. The 2 SILENT_SWALLOW sites (ast.parse + open) now append to errors list. Callers in gui_2.py updated to extract result.data from the cache. api_hooks.py (1 site): - WebSocketServer._handler - was 2 except ...: pass (JSONDecodeError + ConnectionClosed). Now logs warnings instead of silently swallowing. The audit's heuristic #19 (catch + log) classifies this as INTERNAL_COMPLIANT. context_presets.py (1 site): - ContextPresetManager.load_all returns Result[Dict[str, ContextPreset]]. Caller in app_controller.py (load_context_preset) updated to check result.ok. external_editor.py (1 site): - _find_vscode_in_registry returns Result[Optional[str]]. The 1 SILENT_SWALLOW site (subprocess.run) now appends to errors. Caller in ExternalEditorLauncher._resolve_vscode updated to extract result.data. Tests updated to check result.ok and use result.data.
This commit is contained in:
+10
-6
@@ -60,8 +60,9 @@ class ExternalEditorLauncher:
|
||||
_cached_vscode_config: Optional[TextEditorConfig] = None
|
||||
|
||||
|
||||
def _find_vscode_in_registry() -> Optional[str]:
|
||||
def _find_vscode_in_registry() -> Result[Optional[str]]:
|
||||
paths = []
|
||||
errors: list[ErrorInfo] = []
|
||||
reg_keys = [
|
||||
r"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*",
|
||||
r"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*",
|
||||
@@ -79,11 +80,11 @@ def _find_vscode_in_registry() -> Optional[str]:
|
||||
exe_path = line.strip() + "\\Code.exe"
|
||||
if os.path.exists(exe_path):
|
||||
paths.append(exe_path)
|
||||
except (OSError, subprocess.SubprocessError, subprocess.TimeoutExpired):
|
||||
pass
|
||||
except (OSError, subprocess.SubprocessError, subprocess.TimeoutExpired) as e:
|
||||
errors.append(ErrorInfo(kind=ErrorKind.INTERNAL, message=str(e), source=f"external_editor._find_vscode_in_registry[{key}]", original=e))
|
||||
if paths:
|
||||
return paths[0]
|
||||
return None
|
||||
return Result(data=paths[0], errors=errors)
|
||||
return Result(data=None, errors=errors)
|
||||
|
||||
|
||||
def _find_vscode_common_paths() -> Optional[str]:
|
||||
@@ -103,7 +104,10 @@ def auto_detect_vscode() -> Optional[TextEditorConfig]:
|
||||
global _cached_vscode_config
|
||||
if _cached_vscode_config is not None:
|
||||
return _cached_vscode_config
|
||||
vscode_path = _find_vscode_in_registry() or _find_vscode_common_paths()
|
||||
vscode_result = _find_vscode_in_registry()
|
||||
vscode_path = vscode_result.data if vscode_result.ok else None
|
||||
if vscode_path is None:
|
||||
vscode_path = _find_vscode_common_paths()
|
||||
if vscode_path:
|
||||
_cached_vscode_config = TextEditorConfig(
|
||||
name="vscode",
|
||||
|
||||
Reference in New Issue
Block a user