Resolve CA2000

This commit is contained in:
JustArchi 2021-05-07 18:55:50 +02:00
parent 1661cf4be9
commit 809a4bbfbf
6 changed files with 19 additions and 12 deletions

View file

@ -111,7 +111,6 @@ dotnet_diagnostic.ca1028.severity = silent
dotnet_diagnostic.ca1031.severity = silent
# TODO - one at a time
dotnet_diagnostic.ca2000.severity = silent
dotnet_diagnostic.ca2002.severity = silent
dotnet_diagnostic.ca3003.severity = silent
dotnet_diagnostic.ca3012.severity = silent

View file

@ -121,10 +121,10 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
if (globalCache == null) {
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.FileCouldNotBeLoadedFreshInit, nameof(GlobalCache)));
globalCache = new GlobalCache();
GlobalCache = new GlobalCache();
} else {
GlobalCache = globalCache;
}
GlobalCache = globalCache;
}
TimeSpan startIn = TimeSpan.FromMinutes(Utilities.RandomNext(SharedInfo.MinimumMinutesBeforeFirstUpload, SharedInfo.MaximumMinutesBeforeFirstUpload));

View file

@ -3025,12 +3025,14 @@ namespace ArchiSteamFarm {
byte[] sentryHash;
try {
FileStream fileStream = File.Open(sentryFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
FileStream fileStream;
#if NETFRAMEWORK
using (fileStream) {
using (fileStream = File.Open(sentryFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite)) {
#else
await using (fileStream.ConfigureAwait(false)) {
#pragma warning disable CA2000 // False positive
await using ((fileStream = File.Open(sentryFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite)).ConfigureAwait(false)) {
#pragma warning restore CA2000 // False positive
#endif
fileStream.Seek(callback.Offset, SeekOrigin.Begin);

View file

@ -160,7 +160,9 @@ namespace ArchiSteamFarm.NLog {
ConfigurationItemFactory.Default.ParseMessageTemplates = false;
LoggingConfiguration config = new();
#pragma warning disable CA2000 // False positive
ColoredConsoleTarget coloredConsoleTarget = new("ColoredConsole") { Layout = GeneralLayout };
#pragma warning restore CA2000 // False positive
config.AddTarget(coloredConsoleTarget);
config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, coloredConsoleTarget));
@ -174,6 +176,7 @@ namespace ArchiSteamFarm.NLog {
ASF.ArchiLogger.LogGenericException(e);
}
#pragma warning disable CA2000 // False positive
FileTarget fileTarget = new("File") {
ArchiveFileName = Path.Combine("${currentdir}", SharedInfo.ArchivalLogsDirectory, SharedInfo.ArchivalLogFile),
ArchiveNumbering = ArchiveNumberingMode.Rolling,
@ -185,6 +188,7 @@ namespace ArchiSteamFarm.NLog {
Layout = GeneralLayout,
MaxArchiveFiles = 10
};
#pragma warning restore CA2000 // False positive
config.AddTarget(fileTarget);
config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, fileTarget));

View file

@ -345,7 +345,9 @@ namespace ArchiSteamFarm {
break;
}
#pragma warning disable CA2000 // False positive
using (await Bot.Actions.GetTradingLock().ConfigureAwait(false)) {
#pragma warning restore CA2000 // False positive
Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.ActivelyMatchingItems, i));
(shouldContinueMatching, tradedSomething) = await MatchActivelyRound(acceptedMatchableTypes, triedSteamIDs).ConfigureAwait(false);
Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.DoneActivelyMatchingItems, i));

View file

@ -140,14 +140,14 @@ namespace ArchiSteamFarm.Web {
progressReporter?.Report(0);
MemoryStream ms = new((int) response.Length);
MemoryStream ms;
#if NETFRAMEWORK
#pragma warning disable CA1508 // False positive
using (ms) {
#pragma warning restore CA1508 // False positive
using (ms = new MemoryStream((int) response.Length)) {
#else
await using (ms.ConfigureAwait(false)) {
#pragma warning disable CA2000 // False positive
await using ((ms = new MemoryStream((int) response.Length)).ConfigureAwait(false)) {
#pragma warning restore CA2000 // False positive
#endif
try {
byte batch = 0;