From b96f48c2c05eba7554eb859c14b4571ae4756920 Mon Sep 17 00:00:00 2001 From: Alcheri Date: Tue, 11 Aug 2026 20:15:04 +1000 Subject: [PATCH] Fix for Missed opportunity to use Where Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Alcheri --- example.csharp.greeter/GreeterPlugin.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/example.csharp.greeter/GreeterPlugin.cs b/example.csharp.greeter/GreeterPlugin.cs index 653fcc0..f5c7045 100644 --- a/example.csharp.greeter/GreeterPlugin.cs +++ b/example.csharp.greeter/GreeterPlugin.cs @@ -1,3 +1,4 @@ +using System.Linq; using System.Reflection; using System.Text.Json; using Fabulor.Plugins; @@ -121,13 +122,11 @@ private void LoadTargets() try { var settings = JsonSerializer.Deserialize(File.ReadAllText(SettingsPath)); - foreach (var target in settings?.Targets ?? []) + foreach (var target in (settings?.Targets ?? []) + .Where(target => !string.IsNullOrWhiteSpace(target.Network) + && !string.IsNullOrWhiteSpace(target.Channel))) { - if (!string.IsNullOrWhiteSpace(target.Network) - && !string.IsNullOrWhiteSpace(target.Channel)) - { - _targets[TargetKey(target.Network, target.Channel)] = target; - } + _targets[TargetKey(target.Network, target.Channel)] = target; } } catch (Exception error) when (error is IOException or JsonException or UnauthorizedAccessException)