From 90ff43dc983f5d310f4376f7bcbb4e7848400e55 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Fri, 7 May 2021 16:49:02 +0200 Subject: [PATCH] Resolve CA1508 --- .editorconfig | 1 - ArchiSteamFarm/ASF.cs | 2 ++ ArchiSteamFarm/Bot.cs | 2 ++ ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs | 2 ++ ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs | 2 ++ ArchiSteamFarm/OS.cs | 2 +- ArchiSteamFarm/SteamPICSChanges.cs | 2 ++ ArchiSteamFarm/Utilities.cs | 2 ++ ArchiSteamFarm/Web/WebBrowser.cs | 2 ++ 9 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index edc92f7ce..2d8387a32 100644 --- a/.editorconfig +++ b/.editorconfig @@ -111,7 +111,6 @@ dotnet_diagnostic.ca1028.severity = silent dotnet_diagnostic.ca1031.severity = silent # TODO - one at a time -dotnet_diagnostic.ca1508.severity = silent dotnet_diagnostic.ca1819.severity = silent dotnet_diagnostic.ca1812.severity = silent dotnet_diagnostic.ca1823.severity = silent diff --git a/ArchiSteamFarm/ASF.cs b/ArchiSteamFarm/ASF.cs index 431ae7168..9e3ec072d 100644 --- a/ArchiSteamFarm/ASF.cs +++ b/ArchiSteamFarm/ASF.cs @@ -351,7 +351,9 @@ namespace ArchiSteamFarm { try { #if NETFRAMEWORK +#pragma warning disable CA1508 // False positive using (memoryStream) { +#pragma warning restore CA1508 // False positive #else await using (memoryStream.ConfigureAwait(false)) { #endif diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index d70886165..2eb955573 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -720,7 +720,9 @@ namespace ArchiSteamFarm { throw new ArgumentNullException(nameof(appIDs)); } +#pragma warning disable CA1508 // False positive ISet uniqueAppIDs = appIDs as ISet ?? appIDs.ToHashSet(); +#pragma warning restore CA1508 // False positive switch (ASF.GlobalConfig?.OptimizationMode) { case GlobalConfig.EOptimizationMode.MinMemoryUsage: diff --git a/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs b/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs index a18cf2061..465e9319a 100644 --- a/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs +++ b/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs @@ -179,7 +179,9 @@ namespace ArchiSteamFarm.Helpers { } try { +#pragma warning disable CA1508 // False positive using (new FileStream(FilePath, FileMode.CreateNew)) { } +#pragma warning restore CA1508 // False positive if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { FileInfo fileInfo = new(FilePath); diff --git a/ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs b/ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs index f5463f152..27eb2962f 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/NLogController.cs @@ -152,7 +152,9 @@ namespace ArchiSteamFarm.IPC.Controllers.Api { } try { +#pragma warning disable CA1508 // False positive if (cancellationToken.IsCancellationRequested || (webSocket.State != WebSocketState.Open)) { +#pragma warning restore CA1508 // False positive return; } diff --git a/ArchiSteamFarm/OS.cs b/ArchiSteamFarm/OS.cs index 27673698c..12a3b1fbd 100644 --- a/ArchiSteamFarm/OS.cs +++ b/ArchiSteamFarm/OS.cs @@ -111,7 +111,7 @@ namespace ArchiSteamFarm { Mutex? singleInstance = null; - for (byte i = 0; (i < WebBrowser.MaxTries) && (singleInstance == null); i++) { + for (byte i = 0; i < WebBrowser.MaxTries; i++) { if (i > 0) { await Task.Delay(1000).ConfigureAwait(false); } diff --git a/ArchiSteamFarm/SteamPICSChanges.cs b/ArchiSteamFarm/SteamPICSChanges.cs index e50e8cc28..b57d0f41d 100644 --- a/ArchiSteamFarm/SteamPICSChanges.cs +++ b/ArchiSteamFarm/SteamPICSChanges.cs @@ -96,7 +96,9 @@ namespace ArchiSteamFarm { LastChangeNumber = picsChanges.CurrentChangeNumber; +#pragma warning disable CA1508 // False positive if (picsChanges.RequiresFullAppUpdate || picsChanges.RequiresFullPackageUpdate || ((picsChanges.AppChanges.Count == 0) && (picsChanges.PackageChanges.Count == 0))) { +#pragma warning restore CA1508 // False positive if (ASF.GlobalDatabase != null) { await ASF.GlobalDatabase.OnPICSChangesRestart(picsChanges.CurrentChangeNumber).ConfigureAwait(false); } diff --git a/ArchiSteamFarm/Utilities.cs b/ArchiSteamFarm/Utilities.cs index ff0618585..06f3fd35a 100644 --- a/ArchiSteamFarm/Utilities.cs +++ b/ArchiSteamFarm/Utilities.cs @@ -312,7 +312,9 @@ namespace ArchiSteamFarm { throw new ArgumentNullException(nameof(directory)); } +#pragma warning disable CA1508 // False positive if ((prefixes == null) || (prefixes.Length == 0)) { +#pragma warning restore CA1508 // False positive throw new ArgumentNullException(nameof(prefixes)); } diff --git a/ArchiSteamFarm/Web/WebBrowser.cs b/ArchiSteamFarm/Web/WebBrowser.cs index 2a0cefe56..ce5e849f4 100644 --- a/ArchiSteamFarm/Web/WebBrowser.cs +++ b/ArchiSteamFarm/Web/WebBrowser.cs @@ -143,7 +143,9 @@ namespace ArchiSteamFarm.Web { MemoryStream ms = new((int) response.Length); #if NETFRAMEWORK +#pragma warning disable CA1508 // False positive using (ms) { +#pragma warning restore CA1508 // False positive #else await using (ms.ConfigureAwait(false)) { #endif