Clear Qodana findings in monitor runtime code

- Guard logger calls with IsEnabled so value-type arguments are not boxed
  when the level is disabled
- Make helper members static, narrow write-only properties to init or
  private get, and delete members no call site reaches
- Flatten nested conditionals and convert if/else chains into switch and
  ternary form
- Drop the unused *MonitorInit interfaces; NetDaemon instantiates the
  concrete app classes
- Drop the unused IConfiguration parameter from AddNordPool and
  AddPowerMonitor, and the unused IEntityManager.CreateEntitiesAsync
- Remove the ignored parameters of the boiler run-time tracker stub
- Pin the NordPool DTO price mapping explicitly so the getter use is
  visible to static analysis
- Fail Qodana on any finding and record the registration changes in
  AGENTS.md
This commit is contained in:
2026-11-29 21:42:43 +02:00
parent 17774b40b8
commit 41ac93733e
65 changed files with 545 additions and 459 deletions
+36 -31
View File
@@ -80,21 +80,24 @@ public sealed class ShowerDetectionService(
private ShowerState EvaluateIdle(double rate, double differential, double humidity, DateTimeOffset timestamp)
{
if (rate >= _options.SpikeRateThreshold && differential >= _options.MinDifferentialHumidity)
{
_suspectedSince = timestamp;
_currentSession = new ShowerSession
{
StartTime = timestamp,
PreEventHumidity = rateCalculator.PreviousReading ?? humidity,
PeakHumidity = humidity,
PeakTime = timestamp
};
var showerSuspected = rate >= _options.SpikeRateThreshold
&& differential >= _options.MinDifferentialHumidity;
return ShowerState.Suspected;
if (!showerSuspected)
{
return ShowerState.Idle;
}
return ShowerState.Idle;
_suspectedSince = timestamp;
_currentSession = new ShowerSession
{
StartTime = timestamp,
PreEventHumidity = rateCalculator.PreviousReading ?? humidity,
PeakHumidity = humidity,
PeakTime = timestamp
};
return ShowerState.Suspected;
}
private ShowerState EvaluateSuspected(double rate, double differential, double humidity, DateTimeOffset timestamp)
@@ -106,21 +109,23 @@ public sealed class ShowerDetectionService(
}
var confirmationWindow = TimeSpan.FromMinutes(_options.ConfirmationWindowMinutes);
if (_suspectedSince.HasValue && (timestamp - _suspectedSince.Value) >= confirmationWindow
if (_suspectedSince.HasValue && timestamp - _suspectedSince.Value >= confirmationWindow
&& humidity >= _options.PeakHumidityThreshold
&& differential >= _options.MinDifferentialHumidity)
{
return ShowerState.Active;
}
if (rate < 0 && differential < _options.MinDifferentialHumidity)
var showerAbandoned = rate < 0 && differential < _options.MinDifferentialHumidity;
if (!showerAbandoned)
{
CompleteSessionCleanup();
return ShowerState.Idle;
return ShowerState.Suspected;
}
return ShowerState.Suspected;
CompleteSessionCleanup();
return ShowerState.Idle;
}
private ShowerState EvaluateActive(double rate, double differential, double humidity, DateTimeOffset timestamp)
@@ -132,13 +137,11 @@ public sealed class ShowerDetectionService(
}
var maxDuration = TimeSpan.FromMinutes(_options.MaxShowerDurationMinutes);
var maxDurationReached = _currentSession is not null
&& _currentSession.GetDuration(timestamp) >= maxDuration;
var humidityRecovered = rate < 0 && differential < _options.MinDifferentialHumidity;
if (_currentSession is not null && _currentSession.GetDuration(timestamp) >= maxDuration)
{
return TransitionToDeclining();
}
if (rate < 0 && differential < _options.MinDifferentialHumidity)
if (maxDurationReached || humidityRecovered)
{
return TransitionToDeclining();
}
@@ -151,23 +154,25 @@ public sealed class ShowerDetectionService(
if (differential <= _options.RecoveryDifferentialThreshold)
{
CompleteSession(timestamp);
return ShowerState.Completed;
}
var maxDuration = TimeSpan.FromMinutes(_options.MaxShowerDurationMinutes);
var maxDurationReached = _currentSession is not null
&& _currentSession.GetDuration(timestamp) >= maxDuration;
if (_currentSession is not null && _currentSession.GetDuration(timestamp) >= maxDuration)
if (!maxDurationReached)
{
CompleteSession(timestamp);
return ShowerState.Completed;
return ShowerState.Declining;
}
return ShowerState.Declining;
CompleteSession(timestamp);
return ShowerState.Completed;
}
private ShowerState TransitionToDeclining()
private static ShowerState TransitionToDeclining()
{
return ShowerState.Declining;
}