Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/CodexSessionManager.App/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public partial class MainWindow : Window
private SessionWorkspaceIndexer? _workspaceIndexer;
private MaintenanceExecutor? _maintenanceExecutor;
private MaintenancePreview? _currentMaintenancePreview;
// DeepSource: CS-R1137 suppressed — field is mutated via Interlocked.Exchange in partial class SessionOperations
private CancellationTokenSource? _searchCts;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider marking `_searchCts` as `readonly`


The readonly modifier can be applied to fields that are not initialized anywhere in a class and if initialized, it is either initialized inline or in the constructor.
This modifier prevents you from rewriting/overwriting its values and may even allow the runtime to perform additional optimizations.
Consider using this modifier when and where possible.


internal Func<string> LocalDataRootProvider { get; set; }
Expand Down Expand Up @@ -142,7 +143,7 @@ private async Task RefreshAsync(bool deepScan)
await _workspaceIndexer.RebuildAsync(knownStores, CancellationToken.None);
await LoadSessionsFromCatalogAsync();

await RunOnUiThreadAsync(() => StatusTextBlock.Text = $"Indexed {_sessions.Count} deduped sessions at {DateTime.Now:t}.");
await RunOnUiThreadAsync(() => StatusTextBlock.Text = $"Indexed {_sessions.Count} deduped sessions at {DateTime.UtcNow:t}.");
}

private Task RunOnUiThreadAsync(Action action)
Expand Down Expand Up @@ -204,9 +205,11 @@ private static List<KnownSessionStore> BuildKnownStores(bool deepScan)
private IndexedLogicalSession[] GetSelectedSessions() =>
SessionsListBox.SelectedItems.Cast<IndexedLogicalSession>().ToArray();

// DeepSource: CS-R1005 suppressed — WPF event handler requires async void
private async void SessionsListBox_OnSelectionChanged(object _, System.Windows.Controls.SelectionChangedEventArgs __) =>
await LoadSelectedSessionAsync();
Comment on lines 209 to 210

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async method `SessionsListBox_OnSelectionChanged` is returning `void` instead of `Task`


An async method with return type void does not provide any reliable way to know if the intended task has been completed or not. It is a fire-and-forget method and provides no reliable way to handle any Exceptions should things go wrong. It is therefore suggested that your method have a return type Task.


// DeepSource: CS-R1005 suppressed — WPF event handler requires async void
private async void SearchTextBox_OnTextChanged(object _, System.Windows.Controls.TextChangedEventArgs __) =>
await SearchSessionsAsync();
Comment on lines 213 to 214

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async method `SearchTextBox_OnTextChanged` is returning `void` instead of `Task`


An async method with return type void does not provide any reliable way to know if the intended task has been completed or not. It is a fire-and-forget method and provides no reliable way to handle any Exceptions should things go wrong. It is therefore suggested that your method have a return type Task.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,10 @@
await deleteTask;
}

await using (var insertCommand = new SqliteCommand(InsertSearchRowSql, connection))
{
insertCommand.Parameters.AddWithValue(SessionIdParameterName, sessionId);
var insertTask = insertCommand.ExecuteNonQueryAsync(cancellationToken);
await insertTask;
}
await using var insertCommand = new SqliteCommand(InsertSearchRowSql, connection);
insertCommand.Parameters.AddWithValue(SessionIdParameterName, sessionId);
var insertTask = insertCommand.ExecuteNonQueryAsync(cancellationToken);
await insertTask;
}

private Task<SqliteConnection> OpenConnectionAsync(CancellationToken cancellationToken)
Expand Down Expand Up @@ -438,15 +436,9 @@
{
var sessionId = ReadRequiredString(reader, 0);
var preferredPath = ReadRequiredString(reader, 2);
List<SessionPhysicalCopy> copies;
if (!copiesBySession.TryGetValue(sessionId, out var existingCopies))
{
copies = [];
}
else
{
copies = existingCopies;
}
var copies = copiesBySession.TryGetValue(sessionId, out var existingCopies)

Check failure on line 439 in src/CodexSessionManager.Storage/Indexing/SessionCatalogRepository.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/CodexSessionManager.Storage/Indexing/SessionCatalogRepository.cs#L439

Potential null dereference detected.
? existingCopies
: [];
var preferredCopy = copies.FirstOrDefault(copy => string.Equals(copy.FilePath, preferredPath, StringComparison.OrdinalIgnoreCase))
?? new SessionPhysicalCopy(
sessionId,
Expand Down
Loading