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
+11 -3
View File
@@ -22,6 +22,8 @@ public sealed class MqttRecreateApp
private const string NordPoolPriceEntityId = "sensor.nordpool_price";
private const string DefaultUnitOfMeasurement = "EUR/kWh";
private static readonly string[] AppDaemonIdentifiers = ["appdaemon"];
private readonly IHaContext _haContext;
private readonly IMqttEntityManager _mqttEntityManager;
private readonly IServiceProvider _serviceProvider;
@@ -59,14 +61,17 @@ public sealed class MqttRecreateApp
icon = "mdi:refresh",
device = new
{
identifiers = new[] { "appdaemon" },
identifiers = AppDaemonIdentifiers,
name = "AppDaemon",
model = "AppDaemon",
manufacturer = "HomeAssistant App Daemon"
}
}).ConfigureAwait(false);
_logger.LogInformation("Recreate-all button created: {EntityId}", RecreateButtonEntityId);
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("Recreate-all button created: {EntityId}", RecreateButtonEntityId);
}
var button = new Entity(_haContext, RecreateButtonEntityId);
button.StateChanges()
@@ -210,7 +215,10 @@ public sealed class MqttRecreateApp
}
catch (Exception ex)
{
_logger.LogDebug(ex, "Could not read unit_of_measurement for {EntityId}", NordPoolPriceEntityId);
if (_logger.IsEnabled(LogLevel.Debug))
{
_logger.LogDebug(ex, "Could not read unit_of_measurement for {EntityId}", NordPoolPriceEntityId);
}
}
return null;