[NetAnalyzers]CA1031 suppressions cleanup (#18706)

This commit is contained in:
Davide Giacometti
2022-06-12 15:11:52 +02:00
committed by GitHub
parent 33072c7ee3
commit b33bc2ecd0
54 changed files with 0 additions and 143 deletions

View File

@@ -139,9 +139,7 @@ namespace PowerLauncher.Helper
}
}
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
// The dotnet method "System.Environment.SetEnvironmentVariable" has it's own internal method to check the input parameters. Here we catch the exceptions that we don't check before updating the environment variable and log it to avoid crashes of PT Run.
Log.Exception($"Unhandled exception while updating the environment variable [{kv.Key}] for the PT Run process. (The variable value has a length of [{varValueLength}].)", ex, typeof(PowerLauncher.Helper.EnvironmentHelper));
@@ -215,9 +213,7 @@ namespace PowerLauncher.Helper
{
return Environment.GetEnvironmentVariables(target);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
Log.Exception($"Unhandled exception while getting the environment variables for target '{target}'.", ex, typeof(PowerLauncher.Helper.EnvironmentHelper));
return new Hashtable();

View File

@@ -68,9 +68,7 @@ namespace PowerLauncher
var telemetryEvent = new RunPluginsSettingsEvent(plugins);
PowerToysTelemetry.Log.WriteEvent(telemetryEvent);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
Log.Exception("Unhandled exception when trying to send PowerToys Run settings telemetry.", ex, GetType());
}

View File

@@ -37,7 +37,6 @@ namespace PowerLauncher.Plugin
return PluginMetadatas;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
private static void ParsePluginConfigs(IEnumerable<string> directories)
{
// todo use linq when diable plugin is implemented since parallel.foreach + list is not thread saft
@@ -65,7 +64,6 @@ namespace PowerLauncher.Plugin
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
private static PluginMetadata GetPluginMetadata(string pluginDirectory)
{
string configPath = Path.Combine(pluginDirectory, PluginConfigName);

View File

@@ -12,7 +12,6 @@ using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using PowerLauncher.Properties;
using Wox.Infrastructure;
using Wox.Infrastructure.Storage;
using Wox.Plugin;
using Wox.Plugin.Logger;
@@ -135,7 +134,6 @@ namespace PowerLauncher.Plugin
/// <summary>
/// Call initialize for all plugins
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
public static void InitializePlugins(IPublicAPI api)
{
API = api ?? throw new ArgumentNullException(nameof(api));
@@ -165,7 +163,6 @@ namespace PowerLauncher.Plugin
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
public static List<Result> QueryForPlugin(PluginPair pair, Query query, bool delayedExecution = false)
{
if (pair == null)
@@ -272,7 +269,6 @@ namespace PowerLauncher.Plugin
return AllPlugins.Where(p => p.Plugin is T);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
public static List<ContextMenuResult> GetContextMenusForPlugin(Result result)
{
var pluginPair = _contextMenuPlugins.FirstOrDefault(o => o.Metadata.ID == result.PluginID);

View File

@@ -780,9 +780,7 @@ namespace PowerLauncher.ViewModel
_hotkeyHandle = HotkeyManager.RegisterHotkey(hotkey, action);
}
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception)
#pragma warning restore CA1031 // Do not catch general exception types
{
string errorMsg = string.Format(CultureInfo.InvariantCulture, Properties.Resources.registerHotkeyFailed, hotkeyStr);
MessageBox.Show(errorMsg);

View File

@@ -193,9 +193,7 @@ namespace PowerLauncher.ViewModel
{
return Result.Icon();
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
{
Log.Exception($"IcoPath is empty and exception when calling Icon() for result <{Result.Title}> of plugin <{Result.PluginDirectory}>", e, GetType());
imagePath = ImageLoader.ErrorIconPath;