Skip to content

Commit be3d4c1

Browse files
shanselmanCopilot
andcommitted
Address remaining Slopwatch findings
Add diagnostics for high-value swallowed Tray state, persistence, and cleanup paths; replace several timing-based unit-test waits with event-driven waits; and add narrow inline Slopwatch justifications for audited intentional cleanup, cancellation, polling, and legacy-warning cases. Slopwatch now reports zero unsuppressed findings with --no-baseline. Co-authored-by: Copilot <[email protected]>
1 parent 88d7583 commit be3d4c1

131 files changed

Lines changed: 446 additions & 63 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/OpenClaw.Connection/GatewayConnectionManager.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ tunnel.SshPort is < 1 or > 65535 ||
289289
{
290290
await lifecycle.ConnectAsync(ct);
291291
}
292+
// slopwatch-ignore: SW003 Shutdown cancellation or disposal is expected and the caller already preserves the safe state.
292293
catch (OperationCanceledException) { }
293294
catch (Exception ex)
294295
{
@@ -654,6 +655,7 @@ private bool TryScheduleOperatorTokenRecovery(string message, long gen)
654655
if (Interlocked.Read(ref _generation) != gen || _disposed) return;
655656
await ReconnectAsync();
656657
}
658+
// slopwatch-ignore: SW003 Shutdown cancellation or disposal is expected and the caller already preserves the safe state.
657659
catch (ObjectDisposedException) { }
658660
catch (Exception ex)
659661
{
@@ -1239,6 +1241,7 @@ private async Task DisposeCoreAsync()
12391241
{
12401242
if (semaphoreEntered)
12411243
{
1244+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
12421245
try { _transitionSemaphore.Release(); } catch { }
12431246
_transitionSemaphore.Dispose();
12441247
}

‎src/OpenClaw.Connection/SshTunnelService.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public void Stop()
106106
}
107107
finally
108108
{
109+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
109110
try { _process.Dispose(); } catch { }
110111
_process = null;
111112
_lastSpec = null;
@@ -172,6 +173,7 @@ private void StartProcess(string user, string host, int remotePort, int localPor
172173
LastError = $"SSH tunnel exited unexpectedly with code {exitCode}.";
173174
StartedAtUtc = null;
174175
Status = TunnelStatus.Failed;
176+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
175177
try { process.Dispose(); } catch { }
176178
_process = null;
177179
_lastSpec = null;

‎src/OpenClaw.SetupEngine.UI/LogFileLauncher.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public static void RevealInExplorer(string? logPath)
6565
});
6666
}
6767
}
68+
// slopwatch-ignore: SW003 Audited non-critical fallback is intentional and the caller preserves safe behavior without this work.
6869
catch
6970
{
7071
// best effort — the link is informational

‎src/OpenClaw.SetupEngine.UI/Pages/PermissionsPage.xaml.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ private static FrameworkElement BuildRow(PermDef perm, string status, bool grant
106106
btn.Click += async (_, _) =>
107107
{
108108
try { await Windows.System.Launcher.LaunchUriAsync(new Uri(uri)); }
109+
// slopwatch-ignore: SW003 UI helper action is best-effort and failure should not break the owning UI flow.
109110
catch { /* best effort */ }
110111
};
111112
actionCol = btn;

‎src/OpenClaw.SetupEngine.UI/Pages/WizardPage.xaml.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ private void StartConsoleTail()
626626
AppendConsoleLine(message);
627627
});
628628
}
629+
// slopwatch-ignore: SW003 Audited non-critical fallback is intentional and the caller preserves safe behavior without this work.
629630
catch
630631
{
631632
}
@@ -636,7 +637,9 @@ private void StopConsoleTail()
636637
{
637638
var tail = _consoleTail;
638639
_consoleTail = null;
640+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
639641
try { tail?.Stop(); } catch { }
642+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
640643
try { tail?.Dispose(); } catch { }
641644
}
642645

@@ -778,6 +781,7 @@ private async Task CancelCurrentSessionAsync()
778781
if (_client != null && !string.IsNullOrWhiteSpace(_sessionId))
779782
{
780783
try { await _client.SendWizardRequestAsync("wizard.cancel", new { sessionId = _sessionId }, timeoutMs: 10_000); }
784+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
781785
catch { }
782786
}
783787
await DisconnectAsync();
@@ -809,6 +813,7 @@ private async Task DisconnectAsync()
809813
if (client == null) return;
810814
_client = null;
811815
client.StatusChanged -= OnWizardClientStatusChanged;
816+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
812817
try { await client.DisconnectAsync(); } catch { }
813818
client.Dispose();
814819
}

‎src/OpenClaw.SetupEngine.UI/WizardConsoleTail.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public void Start(Action<string> onMessage)
8787
var extracted = TryExtractConsoleMessage(e.Data);
8888
if (extracted == null) return;
8989
try { onMessage(extracted); }
90+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
9091
catch { /* never let a UI mistake kill the tail */ }
9192
};
9293
process.ErrorDataReceived += (_, e) =>
@@ -124,7 +125,9 @@ public void Stop()
124125
if (!process.HasExited)
125126
process.Kill(entireProcessTree: true);
126127
}
128+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
127129
catch { /* already gone */ }
130+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
128131
try { process.Dispose(); } catch { }
129132
}
130133

‎src/OpenClaw.SetupEngine/CommandRunner.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public Task<CommandResult> RunInWslAsync(
176176

177177
private static void TryKill(Process process)
178178
{
179+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
179180
try { process.Kill(entireProcessTree: true); } catch { /* best effort */ }
180181
}
181182

‎src/OpenClaw.SetupEngine/SetupRunLock.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public static bool TryAcquire(string dataDir, out SetupRunLock? runLock, out str
4646
public void Dispose()
4747
{
4848
_stream.Dispose();
49+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
4950
try { File.Delete(_path); } catch { }
5051
}
5152
}

‎src/OpenClaw.SetupEngine/SetupWizardRunner.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public async Task<StepResult> RunAsync(CancellationToken ct)
165165
restartAttempts++;
166166
_ctx.Logger.Warn($"Gateway restarted during wizard; reconnecting and replaying answers (attempt {restartAttempts}/2): {ex.Message}");
167167

168+
// slopwatch-ignore: SW003 Cleanup is best-effort; failure cannot improve caller state and the original outcome is preserved.
168169
try { await client.DisconnectAsync(); } catch { }
169170
client.Dispose();
170171

‎src/OpenClaw.SetupEngine/TransactionJournal.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ private void Append(JournalEntry entry)
8282
var json = JsonSerializer.Serialize(entry, _jsonOptions);
8383
_writer?.WriteLine(json);
8484
}
85+
// slopwatch-ignore: SW003 Optional persisted state fallback is intentional; caller continues with defaults or prior state.
8586
catch (IOException)
8687
{
8788
// Journal write failure is non-fatal — entries are still in memory
@@ -105,6 +106,7 @@ private void LoadExistingEntries(string filePath)
105106
if (entry != null)
106107
_entries.Add(entry);
107108
}
109+
// slopwatch-ignore: SW003 Optional persisted state fallback is intentional; caller continues with defaults or prior state.
108110
catch (JsonException)
109111
{
110112
// Preserve the journal file as crash evidence even if one line is corrupt.

0 commit comments

Comments
 (0)