diff --git a/.editorconfig b/.editorconfig index aa031494e..fc4494c93 100644 --- a/.editorconfig +++ b/.editorconfig @@ -163,6 +163,7 @@ dotnet_diagnostic.CA1309.severity = suggestion dotnet_diagnostic.CA1310.severity = suggestion dotnet_diagnostic.CA1401.severity = suggestion dotnet_diagnostic.CA1416.severity = suggestion +dotnet_diagnostic.CA1419.severity = suggestion dotnet_diagnostic.CA1507.severity = suggestion dotnet_diagnostic.CA1508.severity = suggestion dotnet_diagnostic.CA1707.severity = suggestion @@ -192,6 +193,10 @@ dotnet_diagnostic.CA1819.severity = suggestion dotnet_diagnostic.CA1822.severity = suggestion dotnet_diagnostic.CA1823.severity = suggestion dotnet_diagnostic.CA1824.severity = suggestion +dotnet_diagnostic.CA1835.severity = suggestion +dotnet_diagnostic.CA1845.severity = suggestion +dotnet_diagnostic.CA1848.severity = suggestion +dotnet_diagnostic.CA1849.severity = suggestion dotnet_diagnostic.CA2000.severity = suggestion dotnet_diagnostic.CA2002.severity = suggestion dotnet_diagnostic.CA2007.severity = suggestion @@ -229,6 +234,7 @@ dotnet_diagnostic.CA2243.severity = suggestion dotnet_diagnostic.CA2244.severity = suggestion dotnet_diagnostic.CA2245.severity = suggestion dotnet_diagnostic.CA2246.severity = suggestion +dotnet_diagnostic.CA2254.severity = suggestion dotnet_diagnostic.CA3061.severity = suggestion dotnet_diagnostic.CA3075.severity = suggestion dotnet_diagnostic.CA3076.severity = suggestion @@ -255,6 +261,7 @@ dotnet_diagnostic.CA5385.severity = suggestion dotnet_diagnostic.CA5392.severity = suggestion dotnet_diagnostic.CA5394.severity = suggestion dotnet_diagnostic.CA5397.severity = suggestion +dotnet_diagnostic.CA5401.severity = suggestion dotnet_diagnostic.SYSLIB0014.severity = none diff --git a/src/Directory.Build.props b/src/Directory.Build.props index df60a8196..487a323c2 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,6 +1,7 @@ + 6.0-all true false AnyCPU diff --git a/src/NzbDrone.Common/Extensions/StringExtensions.cs b/src/NzbDrone.Common/Extensions/StringExtensions.cs index 8144b6a92..b35d0afb1 100644 --- a/src/NzbDrone.Common/Extensions/StringExtensions.cs +++ b/src/NzbDrone.Common/Extensions/StringExtensions.cs @@ -131,7 +131,7 @@ namespace NzbDrone.Common.Extensions public static string WrapInQuotes(this string text) { - if (!text.Contains(" ")) + if (!text.Contains(' ')) { return text; } @@ -255,7 +255,7 @@ namespace NzbDrone.Common.Extensions public static string ToUrlHost(this string input) { - return input.Contains(":") ? $"[{input}]" : input; + return input.Contains(':') ? $"[{input}]" : input; } } } diff --git a/src/NzbDrone.Common/OAuth/OAuthTools.cs b/src/NzbDrone.Common/OAuth/OAuthTools.cs index 20ea671b6..866890966 100644 --- a/src/NzbDrone.Common/OAuth/OAuthTools.cs +++ b/src/NzbDrone.Common/OAuth/OAuthTools.cs @@ -226,7 +226,7 @@ namespace NzbDrone.Common.OAuth #if WINRT return CultureInfo.InvariantCulture.CompareInfo.Compare(left, right, CompareOptions.IgnoreCase) == 0; #else - return string.Compare(left, right, StringComparison.InvariantCultureIgnoreCase) == 0; + return string.Equals(left, right, StringComparison.InvariantCultureIgnoreCase); #endif } diff --git a/src/NzbDrone.Common/ServiceProvider.cs b/src/NzbDrone.Common/ServiceProvider.cs index 7da62e6fd..d9a95192e 100644 --- a/src/NzbDrone.Common/ServiceProvider.cs +++ b/src/NzbDrone.Common/ServiceProvider.cs @@ -64,7 +64,7 @@ namespace NzbDrone.Common var args = $"create {serviceName} " + $"DisplayName= \"{serviceName}\" " + - $"binpath= \"{Process.GetCurrentProcess().MainModule.FileName}\" " + + $"binpath= \"{Environment.ProcessPath}\" " + "start= auto " + "depend= EventLog/Tcpip/http " + "obj= \"NT AUTHORITY\\LocalService\""; diff --git a/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs index 9018763a7..e5a6f6c32 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs @@ -162,7 +162,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests releaseInfo.InfoHash.Should().Be("(removed)"); releaseInfo.Seeders.Should().Be(3); releaseInfo.Peers.Should().Be(3); - releaseInfo.Categories.Count().Should().Be(4); + releaseInfo.Categories.Count.Should().Be(4); } [Test] diff --git a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSyntaxReader.cs b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSyntaxReader.cs index 77d53175c..0a0b519aa 100644 --- a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSyntaxReader.cs +++ b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSyntaxReader.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Data; using System.Text; @@ -250,7 +250,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework } Index = end + 1; - identifier.Append(Buffer.Substring(start, end - start)); + identifier.Append(Buffer.AsSpan(start, end - start)); if (Buffer[Index] != escape) { diff --git a/src/NzbDrone.Core/History/HistoryService.cs b/src/NzbDrone.Core/History/HistoryService.cs index cd3ba6b3d..247c8f4e1 100644 --- a/src/NzbDrone.Core/History/HistoryService.cs +++ b/src/NzbDrone.Core/History/HistoryService.cs @@ -173,7 +173,7 @@ namespace NzbDrone.Core.History history.Data.Add("Categories", string.Join(",", message.Query.Categories) ?? string.Empty); history.Data.Add("Source", message.Query.Source ?? string.Empty); history.Data.Add("Host", message.Query.Host ?? string.Empty); - history.Data.Add("QueryResults", message.QueryResult.Releases?.Count().ToString() ?? string.Empty); + history.Data.Add("QueryResults", message.QueryResult.Releases?.Count.ToString() ?? string.Empty); history.Data.Add("Url", message.QueryResult.Response?.Request.Url.FullUri ?? string.Empty); _historyRepository.Insert(history); diff --git a/src/NzbDrone.Core/Http/CloudFlare/CloudFlareDetectionService.cs b/src/NzbDrone.Core/Http/CloudFlare/CloudFlareDetectionService.cs index 54dc2338e..8f38c032e 100644 --- a/src/NzbDrone.Core/Http/CloudFlare/CloudFlareDetectionService.cs +++ b/src/NzbDrone.Core/Http/CloudFlare/CloudFlareDetectionService.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; using NLog; +using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; namespace NzbDrone.Core.Http.CloudFlare @@ -41,7 +42,7 @@ namespace NzbDrone.Core.Http.CloudFlare // detect Custom CloudFlare for EbookParadijs, Film-Paleis, MuziekFabriek and Puur-Hollands if (response.Headers.Vary == "Accept-Encoding,User-Agent" && - response.Headers.ContentEncoding == "" && + response.Headers.ContentEncoding.IsNullOrWhiteSpace() && response.Content.ToLower().Contains("ddos")) { return true; diff --git a/src/NzbDrone.Core/IndexerStats/IndexerStatisticsService.cs b/src/NzbDrone.Core/IndexerStats/IndexerStatisticsService.cs index 42cd79cad..e0a9bace7 100644 --- a/src/NzbDrone.Core/IndexerStats/IndexerStatisticsService.cs +++ b/src/NzbDrone.Core/IndexerStats/IndexerStatisticsService.cs @@ -59,7 +59,7 @@ namespace NzbDrone.Core.IndexerStats var elapsedTimeEvents = sortedEvents.Where(h => int.TryParse(h.Data.GetValueOrDefault("elapsedTime"), out temp)) .Select(h => temp); - indexerStats.AverageResponseTime = elapsedTimeEvents.Count() > 0 ? (int)elapsedTimeEvents.Average() : 0; + indexerStats.AverageResponseTime = elapsedTimeEvents.Any() ? (int)elapsedTimeEvents.Average() : 0; foreach (var historyEvent in sortedEvents) { diff --git a/src/NzbDrone.Core/Indexers/Definitions/AnimeBytes.cs b/src/NzbDrone.Core/Indexers/Definitions/AnimeBytes.cs index d3f0c2410..804cfe848 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/AnimeBytes.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/AnimeBytes.cs @@ -425,7 +425,7 @@ namespace NzbDrone.Core.Indexers.Definitions } var releaseGroup = releaseTags.LastOrDefault(); - if (releaseGroup != null && releaseGroup.Contains("(") && releaseGroup.Contains(")")) + if (releaseGroup != null && releaseGroup.Contains('(') && releaseGroup.Contains(')')) { //// Skip raws if set //if (releaseGroup.ToLowerInvariant().StartsWith("raw") && !AllowRaws) diff --git a/src/NzbDrone.Core/Indexers/Definitions/BakaBT.cs b/src/NzbDrone.Core/Indexers/Definitions/BakaBT.cs index 860925474..4481c8fe1 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BakaBT.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BakaBT.cs @@ -281,7 +281,7 @@ namespace NzbDrone.Core.Indexers.Definitions var stringSeparator = new[] { " | " }; var titles = titleSeries.Split(stringSeparator, StringSplitOptions.RemoveEmptyEntries); - if (titles.Count() > 1 && !_settings.AddRomajiTitle) + if (titles.Length > 1 && !_settings.AddRomajiTitle) { titles = titles.Skip(1).ToArray(); } @@ -293,7 +293,7 @@ namespace NzbDrone.Core.Indexers.Definitions release.Title = (name + releaseInfo).Trim(); // Ensure the season is defined as this tracker only deals with full seasons - if (release.Title.IndexOf("Season") == -1 && _settings.AppendSeason) + if (!release.Title.Contains("Season", StringComparison.CurrentCulture) && _settings.AppendSeason) { // Insert before the release info var aidx = release.Title.IndexOf('('); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs index ebfea2aef..5e841d7c9 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs @@ -66,7 +66,7 @@ namespace NzbDrone.Core.Indexers.Cardigann { if (request.SearchPath.Response != null && request.SearchPath.Response.NoResultsMessage != null && - ((request.SearchPath.Response.NoResultsMessage != string.Empty && results.Contains(request.SearchPath.Response.NoResultsMessage)) || (request.SearchPath.Response.NoResultsMessage == string.Empty && results == string.Empty))) + ((request.SearchPath.Response.NoResultsMessage.IsNotNullOrWhiteSpace() && results.Contains(request.SearchPath.Response.NoResultsMessage)) || (request.SearchPath.Response.NoResultsMessage.IsNullOrWhiteSpace() && results.IsNullOrWhiteSpace()))) { return releases; } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Shazbat.cs b/src/NzbDrone.Core/Indexers/Definitions/Shazbat.cs index c0b738ee2..2748810f7 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Shazbat.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Shazbat.cs @@ -351,7 +351,7 @@ public class ShazbatParser : IParseIndexerResponse private static string ParseTitle(IElement titleRow) { - var title = titleRow?.ChildNodes.First(n => n.NodeType == NodeType.Text && n.TextContent.Trim() != string.Empty); + var title = titleRow?.ChildNodes.First(n => n.NodeType == NodeType.Text && n.TextContent.Trim().IsNotNullOrWhiteSpace()); return title?.TextContent.Trim(); } diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index 9885fd52d..dde3112b2 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -34,7 +34,7 @@ namespace NzbDrone.Core.Indexers public override Encoding Encoding => Encoding.UTF8; public override string Language => "en-US"; - public override string[] LegacyUrls => new string[] { }; + public override string[] LegacyUrls => Array.Empty(); public override bool FollowRedirect => false; public override IndexerCapabilities Capabilities { get; protected set; } diff --git a/src/NzbDrone.Core/Localization/LocalizationService.cs b/src/NzbDrone.Core/Localization/LocalizationService.cs index 5b0b42c01..632b5215a 100644 --- a/src/NzbDrone.Core/Localization/LocalizationService.cs +++ b/src/NzbDrone.Core/Localization/LocalizationService.cs @@ -160,7 +160,7 @@ namespace NzbDrone.Core.Localization await CopyInto(dictionary, baseFilenamePath).ConfigureAwait(false); - if (culture.Contains("_")) + if (culture.Contains('_')) { var languageBaseFilenamePath = Path.Combine(prefix, GetResourceFilename(culture.Split('_')[0])); await CopyInto(dictionary, languageBaseFilenamePath).ConfigureAwait(false); diff --git a/src/NzbDrone.Core/Parser/DateTimeRoutines.cs b/src/NzbDrone.Core/Parser/DateTimeRoutines.cs index 0592ed222..d0aea643a 100644 --- a/src/NzbDrone.Core/Parser/DateTimeRoutines.cs +++ b/src/NzbDrone.Core/Parser/DateTimeRoutines.cs @@ -219,11 +219,11 @@ namespace NzbDrone.Core.Parser } } - if (string.Compare(m.Groups["ampm"].Value, "PM", true) == 0 && hour < 12) + if (string.Equals(m.Groups["ampm"].Value, "PM", StringComparison.InvariantCultureIgnoreCase) && hour < 12) { hour += 12; } - else if (string.Compare(m.Groups["ampm"].Value, "AM", true) == 0 && hour == 12) + else if (string.Equals(m.Groups["ampm"].Value, "AM", StringComparison.InvariantCultureIgnoreCase) && hour == 12) { hour -= 12; } diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs index 55284346a..35e930b6e 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -50,7 +50,7 @@ namespace NzbDrone.Host try { Logger.Info("Starting Prowlarr - {0} - Version {1}", - Process.GetCurrentProcess().MainModule.FileName, + Environment.ProcessPath, Assembly.GetExecutingAssembly().GetName().Version); var startupContext = new StartupContext(args); diff --git a/src/NzbDrone.Host/Startup.cs b/src/NzbDrone.Host/Startup.cs index f70d90be0..e833ed876 100644 --- a/src/NzbDrone.Host/Startup.cs +++ b/src/NzbDrone.Host/Startup.cs @@ -125,7 +125,7 @@ namespace NzbDrone.Host c.AddSecurityRequirement(new OpenApiSecurityRequirement { - { apiKeyHeader, new string[] { } } + { apiKeyHeader, Array.Empty() } }); var apikeyQuery = new OpenApiSecurityScheme @@ -156,7 +156,7 @@ namespace NzbDrone.Host c.AddSecurityRequirement(new OpenApiSecurityRequirement { - { apikeyQuery, new string[] { } } + { apikeyQuery, Array.Empty() } }); }); diff --git a/src/NzbDrone.Test.Common/ConcurrencyCounter.cs b/src/NzbDrone.Test.Common/ConcurrencyCounter.cs index 6ee4554db..f3c12023f 100644 --- a/src/NzbDrone.Test.Common/ConcurrencyCounter.cs +++ b/src/NzbDrone.Test.Common/ConcurrencyCounter.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Test.Common public int Start() { - int threadId = Thread.CurrentThread.ManagedThreadId; + int threadId = Environment.CurrentManagedThreadId; lock (_mutex) { _threads[threadId] = 1; diff --git a/src/Prowlarr.Api.V1/System/Backup/BackupController.cs b/src/Prowlarr.Api.V1/System/Backup/BackupController.cs index 8c70239e5..15f8b5889 100644 --- a/src/Prowlarr.Api.V1/System/Backup/BackupController.cs +++ b/src/Prowlarr.Api.V1/System/Backup/BackupController.cs @@ -93,7 +93,7 @@ namespace Prowlarr.Api.V1.System.Backup throw new BadRequestException("file must be provided"); } - var file = files.First(); + var file = files[0]; var extension = Path.GetExtension(file.FileName); if (!ValidExtensions.Contains(extension)) diff --git a/src/Prowlarr.Http/Frontend/Mappers/IndexHtmlMapper.cs b/src/Prowlarr.Http/Frontend/Mappers/IndexHtmlMapper.cs index 5f2aeaaf3..a5801a6b2 100644 --- a/src/Prowlarr.Http/Frontend/Mappers/IndexHtmlMapper.cs +++ b/src/Prowlarr.Http/Frontend/Mappers/IndexHtmlMapper.cs @@ -35,7 +35,7 @@ namespace Prowlarr.Http.Frontend.Mappers return !resourceUrl.StartsWith("/content") && !resourceUrl.StartsWith("/mediacover") && - !resourceUrl.Contains(".") && + !resourceUrl.Contains('.') && !resourceUrl.StartsWith("/login"); } }