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
+4 -4
View File
@@ -5,14 +5,14 @@ namespace NordPool.Models;
public class CheapestIntervalResult
{
[JsonPropertyName("start")]
public DateTime Start { get; set; }
public DateTime Start { get; init; }
[JsonPropertyName("end")]
public DateTime End { get; set; }
public DateTime End { get; init; }
[JsonPropertyName("price")]
public double Price { get; set; }
public double Price { get; init; }
[JsonPropertyName("rank")]
public int Rank { get; set; }
public int Rank { get; init; }
}
+3 -5
View File
@@ -69,12 +69,10 @@ internal sealed class CompactNordPoolDayPriceConverter : JsonConverter<CompactNo
double? price = reader.TokenType == JsonTokenType.Null ? null : reader.GetDouble();
reader.Read();
if (reader.TokenType != JsonTokenType.EndArray)
{
throw new JsonException("Expected end of array.");
}
return new CompactNordPoolDayPrice { Start = start, End = end, Price = price };
return reader.TokenType == JsonTokenType.EndArray
? new CompactNordPoolDayPrice { Start = start, End = end, Price = price }
: throw new JsonException("Expected end of array.");
}
public override void Write(Utf8JsonWriter writer, CompactNordPoolDayPrice value, JsonSerializerOptions options)
+2 -2
View File
@@ -5,9 +5,9 @@ namespace NordPool.Models.Dtos;
public class NordPoolDayPriceDto
{
[JsonPropertyName("start")]
public string? Start { get; set; }
public string? Start { get; init; }
[JsonPropertyName("end")]
public string? End { get; set; }
public string? End { get; init; }
[JsonPropertyName("price")]
public double? Price { get; set; }
}
@@ -5,5 +5,5 @@ namespace NordPool.Models.Dtos;
public class NordPoolPriceResultDto
{
[JsonPropertyName("LT")]
public List<NordPoolDayPriceDto>? Prices { get; set; }
public List<NordPoolDayPriceDto>? Prices { get; init; }
}
+1 -1
View File
@@ -2,7 +2,7 @@ namespace NordPool.Models;
public static class NordPoolConsts
{
public static readonly string ConfigEntry = "01K9HYQE4Y0E7KC36JZV11MEXH";
public const string ConfigEntry = "01K9HYQE4Y0E7KC36JZV11MEXH";
/// <summary>
/// NordPool electricity market uses 15-minute trading intervals.
@@ -4,11 +4,8 @@ public static class NordPoolDayPriceExtensions
{
public static List<CompactNordPoolDayPrice> ToCompact(this IEnumerable<NordPoolDayPrice>? prices)
{
if (prices is null)
{
return [];
}
return prices.Select(CompactNordPoolDayPrice.FromDayPrice).ToList();
return prices is null
? []
: [.. prices.Select(CompactNordPoolDayPrice.FromDayPrice)];
}
}
+3 -3
View File
@@ -13,9 +13,9 @@ public class NordPoolEntity : EntityCreateModel
manufacturer = NordPoolConsts.DeviceManufacturer
};
public string Domain { get; set; }
public string Identifier { get; set; }
public string Name { get; set; }
public string Domain { get; }
public string Identifier { get; }
public string Name { get; }
public NordPoolEntity(string domain, string identifier, string name)
{
+1 -1
View File
@@ -2,5 +2,5 @@
public class NordPoolPrice
{
public IList<NordPoolDayPrice>? Prices { get; set; }
public IList<NordPoolDayPrice>? Prices { get; init; }
}