Skip to content

Commit a665bbd

Browse files
Prekzursilclaude
andauthored
fix: resolve 7 SonarQube issues (#54)
* fix: resolve 7 SonarQube issues (CA1859, CA1869, S6596) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: update test delegates to match CA1859 return type changes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 50378e6 commit a665bbd

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

.github/workflows/semgrep.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: Semgrep
2-
1+
name: Semgrep
2+
33
on:
44
push:
55
branches: [main]
@@ -11,7 +11,7 @@ permissions:
1111

1212
jobs:
1313
scan:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-24.04
1515
steps:
1616
- uses: actions/checkout@v6
1717
- uses: actions/setup-python@v5

src/CodexSessionManager.App/MainWindow.xaml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public partial class MainWindow : Window
3030
internal Func<SessionCatalogRepository, SessionWorkspaceIndexer> WorkspaceIndexerFactory { get; set; }
3131
internal Func<string, MaintenanceExecutor> MaintenanceExecutorFactory { get; set; }
3232
internal Action ScheduleRefreshAction { get; set; }
33-
internal Func<bool, IReadOnlyList<KnownSessionStore>> KnownStoresProvider { get; set; }
33+
internal Func<bool, List<KnownSessionStore>> KnownStoresProvider { get; set; }
3434
internal Func<string> LiveSqliteStatusProvider { get; set; }
3535
internal Func<string, CancellationToken, Task<ParsedSessionFile>> SessionParser { get; set; }
3636
internal Func<string, string> FileTextReader { get; set; }
@@ -175,7 +175,7 @@ private Task<T> RunOnUiThreadValueAsync<T>(Func<T> func)
175175
return SaveFileDialogPresenter(dialog, this) == true ? dialog.FileName : null;
176176
}
177177

178-
private static IReadOnlyList<KnownSessionStore> BuildKnownStores(bool deepScan)
178+
private static List<KnownSessionStore> BuildKnownStores(bool deepScan)
179179
{
180180
var codexHome = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".codex");
181181
var stores = new List<KnownSessionStore>(KnownStoreLocator.GetKnownStores(codexHome));
@@ -201,7 +201,7 @@ private static IReadOnlyList<KnownSessionStore> BuildKnownStores(bool deepScan)
201201

202202
private IndexedLogicalSession? GetSelectedSession() => SessionsListBox.SelectedItem as IndexedLogicalSession;
203203

204-
private IReadOnlyList<IndexedLogicalSession> GetSelectedSessions() =>
204+
private IndexedLogicalSession[] GetSelectedSessions() =>
205205
SessionsListBox.SelectedItems.Cast<IndexedLogicalSession>().ToArray();
206206

207207
private async void SessionsListBox_OnSelectionChanged(object _, System.Windows.Controls.SelectionChangedEventArgs __) =>
@@ -321,7 +321,7 @@ private void ExportButton_OnClick(object _, RoutedEventArgs __)
321321
private void BuildPreviewButton_OnClick(object _, RoutedEventArgs __)
322322
{
323323
var selectedSessions = GetSelectedSessions();
324-
if (selectedSessions.Count == 0)
324+
if (selectedSessions.Length == 0)
325325
{
326326
return;
327327
}

src/CodexSessionManager.Storage/Indexing/SessionCatalogRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ private Task<SqliteConnection> OpenConnectionAsync(CancellationToken cancellatio
326326
return Task.FromResult(connection);
327327
}
328328

329-
private static IReadOnlyList<string> SplitLines(string value)
329+
private static string[] SplitLines(string value)
330330
{
331331
var nonNullValue = value ?? throw new ArgumentNullException(nameof(value));
332332

src/CodexSessionManager.Storage/Maintenance/MaintenanceExecutor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace CodexSessionManager.Storage.Maintenance;
66

77
public sealed class MaintenanceExecutor
88
{
9+
private static readonly JsonSerializerOptions IndentedJsonOptions = new() { WriteIndented = true };
910
private readonly string _checkpointRoot;
1011

1112
public MaintenanceExecutor(string checkpointRoot)
@@ -68,7 +69,7 @@ public async Task<MaintenanceExecutionResult> ExecuteAsync(
6869
};
6970
await File.WriteAllTextAsync(
7071
manifestPath,
71-
JsonSerializer.Serialize(payload, new JsonSerializerOptions { WriteIndented = true }),
72+
JsonSerializer.Serialize(payload, IndentedJsonOptions),
7273
cancellationToken);
7374

7475
return new MaintenanceExecutionResult(

src/CodexSessionManager.Storage/Parsing/SessionJsonlParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private static bool IsTextContentItem(JsonElement contentItem)
228228
return commandElement.GetString();
229229
}
230230

231-
private static void ExtractFilePathsAndUrls(string value, ISet<string> filePaths, ISet<string> urls)
231+
private static void ExtractFilePathsAndUrls(string value, HashSet<string> filePaths, HashSet<string> urls)
232232
{
233233
if (value is null)
234234
{

tests/CodexSessionManager.App.Tests/MainWindowCoverageTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ await RunInStaAsync(async () =>
297297

298298
SetProvider(window, "LocalDataRootProvider", () => root);
299299
SetProvider(window, "ScheduleRefreshAction", (Action)(() => scheduled++));
300-
SetProvider(window, "KnownStoresProvider", (Func<bool, IReadOnlyList<KnownSessionStore>>)(_ => Array.Empty<KnownSessionStore>()));
300+
SetProvider(window, "KnownStoresProvider", (Func<bool, List<KnownSessionStore>>)(_ => new List<KnownSessionStore>()));
301301

302302
await InvokePrivateTaskAsync(window, InitializeAsyncMethod);
303303

@@ -367,7 +367,7 @@ await RunInStaAsync(async () =>
367367
var indexer = new SessionWorkspaceIndexer(repository);
368368
var window = new MainWindow();
369369
var stores =
370-
new[]
370+
new List<KnownSessionStore>
371371
{
372372
new KnownSessionStore(
373373
root,
@@ -383,7 +383,7 @@ await RunInStaAsync(async () =>
383383

384384
RepositoryField.SetValue(window, repository);
385385
WorkspaceIndexerField.SetValue(window, indexer);
386-
SetProvider(window, "KnownStoresProvider", (Func<bool, IReadOnlyList<KnownSessionStore>>)(_ => stores));
386+
SetProvider(window, "KnownStoresProvider", (Func<bool, List<KnownSessionStore>>)(_ => stores));
387387

388388
await InvokePrivateTaskAsync(window, RefreshAsyncMethod, false);
389389

@@ -410,7 +410,7 @@ await RunInStaAsync(async () =>
410410
var indexer = new SessionWorkspaceIndexer(repository);
411411
var window = new MainWindow();
412412
var stores =
413-
new[]
413+
new List<KnownSessionStore>
414414
{
415415
new KnownSessionStore(
416416
root,
@@ -426,7 +426,7 @@ await RunInStaAsync(async () =>
426426

427427
RepositoryField.SetValue(window, repository);
428428
WorkspaceIndexerField.SetValue(window, indexer);
429-
SetProvider(window, "KnownStoresProvider", (Func<bool, IReadOnlyList<KnownSessionStore>>)(deepScan =>
429+
SetProvider(window, "KnownStoresProvider", (Func<bool, List<KnownSessionStore>>)(deepScan =>
430430
{
431431
Assert.True(deepScan);
432432
return stores;
@@ -459,7 +459,7 @@ await RunInStaAsync(async () =>
459459
SetProvider(
460460
window,
461461
"KnownStoresProvider",
462-
(Func<bool, IReadOnlyList<KnownSessionStore>>)(_ => throw new InvalidOperationException("refresh boom")));
462+
(Func<bool, List<KnownSessionStore>>)(_ => throw new InvalidOperationException("refresh boom")));
463463

464464
await InvokePrivateTaskAsync(window, RunBackgroundRefreshAsyncMethod);
465465

@@ -484,7 +484,7 @@ await RunInStaAsync(async () =>
484484
var window = new MainWindow();
485485
RepositoryField.SetValue(window, repository);
486486
WorkspaceIndexerField.SetValue(window, new SessionWorkspaceIndexer(repository));
487-
SetProvider(window, "KnownStoresProvider", (Func<bool, IReadOnlyList<KnownSessionStore>>)(_ => Array.Empty<KnownSessionStore>()));
487+
SetProvider(window, "KnownStoresProvider", (Func<bool, List<KnownSessionStore>>)(_ => new List<KnownSessionStore>()));
488488

489489
await InvokePrivateTaskAsync(window, RunBackgroundRefreshAsyncMethod);
490490

@@ -1270,8 +1270,8 @@ await RunInStaAsync(async () =>
12701270
});
12711271
}
12721272

1273-
private static IReadOnlyList<KnownSessionStore> InvokeBuildKnownStores(bool deepScan) =>
1274-
(IReadOnlyList<KnownSessionStore>)BuildKnownStoresMethod.Invoke(null, [deepScan])!;
1273+
private static List<KnownSessionStore> InvokeBuildKnownStores(bool deepScan) =>
1274+
(List<KnownSessionStore>)BuildKnownStoresMethod.Invoke(null, [deepScan])!;
12751275

12761276
private static Task InvokePrivateTaskAsync(object instance, MethodInfo method, params object?[] args) =>
12771277
(Task)method.Invoke(instance, args)!;

0 commit comments

Comments
 (0)