Improve code quality

This commit is contained in:
Jack251970 2025-02-24 11:35:41 +08:00
parent 8f7ad27aef
commit d07b304f9e
3 changed files with 6 additions and 9 deletions

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
@ -9,7 +9,6 @@ using System.Text.Json;
namespace Flow.Launcher.Core.Plugin
{
internal abstract class PluginConfig
{
/// <summary>
@ -112,7 +111,7 @@ namespace Flow.Launcher.Core.Plugin
metadata = JsonSerializer.Deserialize<PluginMetadata>(File.ReadAllText(configPath));
metadata.PluginDirectory = pluginDirectory;
// for plugins which doesn't has ActionKeywords key
metadata.ActionKeywords = metadata.ActionKeywords ?? new List<string> { metadata.ActionKeyword };
metadata.ActionKeywords ??= new List<string> { metadata.ActionKeyword };
// for plugin still use old ActionKeyword
metadata.ActionKeyword = metadata.ActionKeywords?[0];
}
@ -137,4 +136,4 @@ namespace Flow.Launcher.Core.Plugin
return metadata;
}
}
}
}

View file

@ -81,7 +81,7 @@ namespace Flow.Launcher.Core.Plugin
metadata.PluginCacheDirectoryPath = Path.Combine(DataLocation.PluginCacheDirectory, assemblyName);
}
#if DEBUG
catch (Exception e)
catch (Exception)
{
throw;
}
@ -117,7 +117,7 @@ namespace Flow.Launcher.Core.Plugin
if (erroredPlugins.Count > 0)
{
var errorPluginString = String.Join(Environment.NewLine, erroredPlugins);
var errorPluginString = string.Join(Environment.NewLine, erroredPlugins);
var errorMessage = "The following "
+ (erroredPlugins.Count > 1 ? "plugins have " : "plugin has ")

View file

@ -32,10 +32,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings
{
foreach (var metadata in metadatas)
{
if (Plugins.ContainsKey(metadata.ID))
if (Plugins.TryGetValue(metadata.ID, out var settings))
{
var settings = Plugins[metadata.ID];
if (string.IsNullOrEmpty(settings.Version))
settings.Version = metadata.Version;