Skip to content

[DEV] Code quality and cleanup items #113

@erikdarlingdata

Description

@erikdarlingdata

Summary

Miscellaneous code quality findings from the Developer review that don't fit neatly into other themed issues. Includes disposal gaps, event handler leaks, inconsistent patterns, and configuration improvements.

Source: Comprehensive themed agent review (Developer)

Checklist

Resource Disposal

  • Dispose ScottPlot chart objects when server tabs close
  • Dispose _mcpHostService properly if StopAsync() throws
  • Stop and dispose _statusTimer in Lite closing handler
  • Verify NotificationService._trayIcon disposal chain

Event Handler Leaks

  • Unsubscribe DispatcherTimer.Tick handlers in OnClosed
  • Unsubscribe Button.Click handlers for dynamically created tabs
  • Consider weak event pattern for long-lived subscriptions

Configuration

  • Replace App.xaml.cs static settings (30+ properties) with injectable ISettingsService
  • Replace EmailAlertService.Current static instance with DI pattern
  • Synchronize version numbers across all projects (Dashboard 1.1.0, Installer 1.0.0)
  • Add .editorconfig enforcement for consistent style (braces, using declarations)

Code Consistency

  • Standardize on using declarations (C# 8+) vs legacy using blocks
  • Audit SafeToDecimal / SafeToInt16 helpers - enforce usage or remove
  • Standardize naming: RefreshAsync vs CheckConnectionAsync (both are refresh operations)
  • Use ConcurrentDictionary for _openTabs (thread safety)

Logging

  • Add correlation IDs for tracing user actions through logs
  • Shared logger interface (Dashboard Logger vs Lite AppLogger have different APIs)
  • Log failed log-file cleanup operations (currently silent)

Minor Fixes

  • NumericFilterHelper.EvaluateRange(): fix negative-to-negative range parsing
  • CredentialService: differentiate CryptographicException vs UnauthorizedAccessException
  • RemoteCollectorService: initialize health entries for never-run collectors

Priority

Tier 3 - Medium (disposal, events), Tier 4 - Low (consistency, logging)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions