diff --git a/.editorconfig b/.editorconfig index 6c4ce4748..96cb2fbc6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -19,10 +19,10 @@ indent_size = 4 dotnet_sort_system_directives_first = true # Avoid "this." and "Me." if not necessary -dotnet_style_qualification_for_field = false:warning -dotnet_style_qualification_for_property = false:warning -dotnet_style_qualification_for_method = false:warning -dotnet_style_qualification_for_event = false:warning +dotnet_style_qualification_for_field = false:refactoring +dotnet_style_qualification_for_property = false:refactoring +dotnet_style_qualification_for_method = false:refactoring +dotnet_style_qualification_for_event = false:refactoring # Indentation preferences csharp_indent_block_contents = true @@ -32,6 +32,10 @@ csharp_indent_case_contents_when_block = true csharp_indent_switch_labels = true csharp_indent_labels = flush_left +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_event = false:suggestion dotnet_naming_style.instance_field_style.capitalization = camel_case dotnet_naming_style.instance_field_style.required_prefix = _ @@ -64,6 +68,7 @@ dotnet_diagnostic.SA1406.severity = suggestion dotnet_diagnostic.SA1410.severity = suggestion dotnet_diagnostic.SA1411.severity = suggestion dotnet_diagnostic.SA1413.severity = none +dotnet_diagnostic.SA1512.severity = none dotnet_diagnostic.SA1516.severity = none dotnet_diagnostic.SA1600.severity = none dotnet_diagnostic.SA1601.severity = none @@ -162,6 +167,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 @@ -177,9 +183,6 @@ dotnet_diagnostic.CA1720.severity = suggestion dotnet_diagnostic.CA1721.severity = suggestion dotnet_diagnostic.CA1724.severity = suggestion dotnet_diagnostic.CA1725.severity = suggestion -dotnet_diagnostic.CA1801.severity = suggestion -dotnet_diagnostic.CA1802.severity = suggestion -dotnet_diagnostic.CA1805.severity = suggestion dotnet_diagnostic.CA1806.severity = suggestion dotnet_diagnostic.CA1810.severity = suggestion dotnet_diagnostic.CA1812.severity = suggestion @@ -191,13 +194,11 @@ dotnet_diagnostic.CA1819.severity = suggestion dotnet_diagnostic.CA1822.severity = suggestion dotnet_diagnostic.CA1823.severity = suggestion dotnet_diagnostic.CA1824.severity = suggestion +dotnet_diagnostic.CA1848.severity = suggestion dotnet_diagnostic.CA2000.severity = suggestion dotnet_diagnostic.CA2002.severity = suggestion dotnet_diagnostic.CA2007.severity = suggestion dotnet_diagnostic.CA2008.severity = suggestion -dotnet_diagnostic.CA2009.severity = suggestion -dotnet_diagnostic.CA2010.severity = suggestion -dotnet_diagnostic.CA2011.severity = suggestion dotnet_diagnostic.CA2012.severity = suggestion dotnet_diagnostic.CA2013.severity = suggestion dotnet_diagnostic.CA2100.severity = suggestion @@ -228,6 +229,9 @@ dotnet_diagnostic.CA2243.severity = suggestion dotnet_diagnostic.CA2244.severity = suggestion dotnet_diagnostic.CA2245.severity = suggestion dotnet_diagnostic.CA2246.severity = suggestion +dotnet_diagnostic.CA2249.severity = suggestion +dotnet_diagnostic.CA2251.severity = suggestion +dotnet_diagnostic.CA2254.severity = suggestion dotnet_diagnostic.CA3061.severity = suggestion dotnet_diagnostic.CA3075.severity = suggestion dotnet_diagnostic.CA3076.severity = suggestion @@ -255,7 +259,7 @@ dotnet_diagnostic.CA5392.severity = suggestion dotnet_diagnostic.CA5394.severity = suggestion dotnet_diagnostic.CA5397.severity = suggestion - +dotnet_diagnostic.SYSLIB0006.severity = none [*.{js,html,js,hbs,less,css}] charset = utf-8 diff --git a/src/.globalconfig b/src/.globalconfig new file mode 100644 index 000000000..6c8ed149b --- /dev/null +++ b/src/.globalconfig @@ -0,0 +1,3 @@ +is_global = true + +dotnet_diagnostic.CA1014.severity = none diff --git a/src/Directory.Build.props b/src/Directory.Build.props index ba8dacad5..c850c75e0 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,9 @@ + 6.0-all true + true false AnyCPU diff --git a/src/NzbDrone.Common/Extensions/StringExtensions.cs b/src/NzbDrone.Common/Extensions/StringExtensions.cs index e31717d90..fbb1d9fff 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; } @@ -217,7 +217,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/Http/Dispatchers/ManagedHttpDispatcher.cs b/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs index 9e7509851..1b775552e 100644 --- a/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs +++ b/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs @@ -216,7 +216,7 @@ namespace NzbDrone.Common.Http.Dispatchers } } - private void AddContentHeader(HttpRequestMessage request, string header, string value) + private static void AddContentHeader(HttpRequestMessage request, string header, string value) { var headers = request.Content?.Headers; if (headers == null) diff --git a/src/NzbDrone.Common/Http/HttpUri.cs b/src/NzbDrone.Common/Http/HttpUri.cs index ecd4abf70..d9d915bb8 100644 --- a/src/NzbDrone.Common/Http/HttpUri.cs +++ b/src/NzbDrone.Common/Http/HttpUri.cs @@ -170,7 +170,7 @@ namespace NzbDrone.Common.Http if (baseSlashIndex >= 0) { - return basePath.Substring(0, baseSlashIndex) + "/" + relativePath; + return $"{basePath.AsSpan(0, baseSlashIndex)}/{relativePath}"; } return relativePath; diff --git a/src/NzbDrone.Common/ServiceProvider.cs b/src/NzbDrone.Common/ServiceProvider.cs index 349fa083a..849538873 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.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs b/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs index 2f1a295b5..176ed380d 100644 --- a/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs +++ b/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs @@ -19,7 +19,7 @@ namespace NzbDrone.Common.TPL private readonly int _maxDegreeOfParallelism; /// Whether the scheduler is currently processing work items. - private int _delegatesQueuedOrRunning = 0; + private int _delegatesQueuedOrRunning; /// /// Initializes an instance of the LimitedConcurrencyLevelTaskScheduler class with the diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/147_custom_formatsFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/147_custom_formatsFixture.cs index bff868068..e9bec3792 100644 --- a/src/NzbDrone.Core.Test/Datastore/Migration/147_custom_formatsFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/Migration/147_custom_formatsFixture.cs @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration [TestFixture] public class custom_formatsFixture : MigrationTest { - public static Dictionary QualityToDefinition = null; + public static Dictionary QualityToDefinition; public void AddDefaultProfile(add_custom_formats m, string name, Quality cutoff, params Quality[] allowed) { diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/FreeboxDownloadTests/TorrentFreeboxDownloadFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/FreeboxDownloadTests/TorrentFreeboxDownloadFixture.cs index e1e8dcc31..d7e5d1212 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/FreeboxDownloadTests/TorrentFreeboxDownloadFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/FreeboxDownloadTests/TorrentFreeboxDownloadFixture.cs @@ -80,7 +80,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.FreeboxDownloadTests Mocker.GetMock() .Setup(s => s.Get(It.IsAny())) - .Returns(r => new HttpResponse(r, new HttpHeader(), new byte[0])); + .Returns(r => new HttpResponse(r, new HttpHeader(), Array.Empty())); } protected void GivenCategory() diff --git a/src/NzbDrone.Core.Test/Extras/Others/OtherExtraServiceFixture.cs b/src/NzbDrone.Core.Test/Extras/Others/OtherExtraServiceFixture.cs index 7c9e71f08..707f1c600 100644 --- a/src/NzbDrone.Core.Test/Extras/Others/OtherExtraServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Extras/Others/OtherExtraServiceFixture.cs @@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.Extras.Others var results = Subject.ImportFiles(_localMovie, _movieFile, files, true).ToList(); - results.Count().Should().Be(1); + results.Count.Should().Be(1); results[0].RelativePath.AsOsAgnostic().PathEquals(expectedOutputPath.AsOsAgnostic()).Should().Be(true); } @@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.Extras.Others var results = Subject.ImportFiles(_localMovie, _movieFile, files, true).ToList(); - results.Count().Should().Be(1); + results.Count.Should().Be(1); } } } diff --git a/src/NzbDrone.Core.Test/Extras/Subtitles/SubtitleServiceFixture.cs b/src/NzbDrone.Core.Test/Extras/Subtitles/SubtitleServiceFixture.cs index f74b9736f..df15a0491 100644 --- a/src/NzbDrone.Core.Test/Extras/Subtitles/SubtitleServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Extras/Subtitles/SubtitleServiceFixture.cs @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles var results = Subject.ImportFiles(_localMovie, _movieFile, files, true).ToList(); - results.Count().Should().Be(0); + results.Count.Should().Be(0); } [Test] @@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles var results = Subject.ImportFiles(_localMovie, _movieFile, files, true).ToList(); - results.Count().Should().Be(1); + results.Count.Should().Be(1); results[0].RelativePath.AsOsAgnostic().PathEquals(expectedOutputPath.AsOsAgnostic()).Should().Be(true); } @@ -110,7 +110,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles var results = Subject.ImportFiles(_localMovie, _movieFile, files, true).ToList(); - results.Count().Should().Be(expectedOutputs.Length); + results.Count.Should().Be(expectedOutputs.Length); for (int i = 0; i < expectedOutputs.Length; i++) { @@ -139,7 +139,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles var results = Subject.ImportFiles(_localMovie, _movieFile, files, true).ToList(); - results.Count().Should().Be(expectedOutputs.Length); + results.Count.Should().Be(expectedOutputs.Length); for (int i = 0; i < expectedOutputs.Length; i++) { @@ -169,7 +169,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles var results = Subject.ImportFiles(_localMovie, _movieFile, new List { subtitleFile }, true).ToList(); - results.Count().Should().Be(1); + results.Count.Should().Be(1); results[0].RelativePath.AsOsAgnostic().PathEquals(expectedOutputPath.AsOsAgnostic()).Should().Be(true); diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaFileDeletionService/DeleteMovieFileFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaFileDeletionService/DeleteMovieFileFixture.cs index cdf5a9727..35cc8cc7b 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaFileDeletionService/DeleteMovieFileFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaFileDeletionService/DeleteMovieFileFixture.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileDeletionService [TestFixture] public class DeleteMovieFileFixture : CoreTest { - private static readonly string RootFolder = @"C:\Test\Movies"; + private const string RootFolder = @"C:\Test\Movies"; private Movie _movie; private MovieFile _movieFile; diff --git a/src/NzbDrone.Core/Datastore/Migration/199_mediainfo_to_ffmpeg.cs b/src/NzbDrone.Core/Datastore/Migration/199_mediainfo_to_ffmpeg.cs index d2e8161ec..e3294e6b7 100644 --- a/src/NzbDrone.Core/Datastore/Migration/199_mediainfo_to_ffmpeg.cs +++ b/src/NzbDrone.Core/Datastore/Migration/199_mediainfo_to_ffmpeg.cs @@ -627,13 +627,13 @@ namespace NzbDrone.Core.Datastore.Migration try { - if (audioChannelPositions.Contains("+")) + if (audioChannelPositions.Contains('+')) { return audioChannelPositions.Split('+') .Sum(s => decimal.Parse(s.Trim(), CultureInfo.InvariantCulture)); } - if (audioChannelPositions.Contains("/")) + if (audioChannelPositions.Contains('/')) { var channelStringList = Regex.Replace(audioChannelPositions, @"^\d+\sobjects", 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/Datastore/WhereBuilderPostgres.cs b/src/NzbDrone.Core/Datastore/WhereBuilderPostgres.cs index f3e31e179..91f910c9e 100644 --- a/src/NzbDrone.Core/Datastore/WhereBuilderPostgres.cs +++ b/src/NzbDrone.Core/Datastore/WhereBuilderPostgres.cs @@ -15,9 +15,9 @@ namespace NzbDrone.Core.Datastore private const DbType EnumerableMultiParameter = (DbType)(-1); private readonly string _paramNamePrefix; - private readonly bool _requireConcreteValue = false; - private int _paramCount = 0; - private bool _gotConcreteValue = false; + private readonly bool _requireConcreteValue; + private int _paramCount; + private bool _gotConcreteValue; public WhereBuilderPostgres(Expression filter, bool requireConcreteValue, int seq) { diff --git a/src/NzbDrone.Core/Datastore/WhereBuilderSqlite.cs b/src/NzbDrone.Core/Datastore/WhereBuilderSqlite.cs index 54b24d7e1..8725361e9 100644 --- a/src/NzbDrone.Core/Datastore/WhereBuilderSqlite.cs +++ b/src/NzbDrone.Core/Datastore/WhereBuilderSqlite.cs @@ -15,9 +15,9 @@ namespace NzbDrone.Core.Datastore private const DbType EnumerableMultiParameter = (DbType)(-1); private readonly string _paramNamePrefix; - private readonly bool _requireConcreteValue = false; - private int _paramCount = 0; - private bool _gotConcreteValue = false; + private readonly bool _requireConcreteValue; + private int _paramCount; + private bool _gotConcreteValue; public WhereBuilderSqlite(Expression filter, bool requireConcreteValue, int seq) { diff --git a/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs b/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs index f9836c5dd..9d7fc0020 100644 --- a/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs +++ b/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs @@ -149,7 +149,7 @@ namespace NzbDrone.Core.Extras.Subtitles .Where(file => MediaFileExtensions.Extensions.Contains(Path.GetExtension(file))) .ToList(); - if (videoFiles.Count() > 2) + if (videoFiles.Count > 2) { return importedFiles; } @@ -246,7 +246,7 @@ namespace NzbDrone.Core.Extras.Subtitles if (languageTags.Any()) { - suffixBuilder.Append("."); + suffixBuilder.Append('.'); suffixBuilder.Append(string.Join(".", languageTags)); } diff --git a/src/NzbDrone.Core/HealthCheck/HealthCheckService.cs b/src/NzbDrone.Core/HealthCheck/HealthCheckService.cs index f134bfeea..cb896dd66 100644 --- a/src/NzbDrone.Core/HealthCheck/HealthCheckService.cs +++ b/src/NzbDrone.Core/HealthCheck/HealthCheckService.cs @@ -34,8 +34,8 @@ namespace NzbDrone.Core.HealthCheck private readonly ICached _healthCheckResults; - private bool _hasRunHealthChecksAfterGracePeriod = false; - private bool _isRunningHealthChecksAfterGracePeriod = false; + private bool _hasRunHealthChecksAfterGracePeriod; + private bool _isRunningHealthChecksAfterGracePeriod; public HealthCheckService(IEnumerable healthChecks, IServerSideNotificationService serverSideNotificationService, diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs index 6b5aa742d..a8e9e94bd 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs @@ -124,12 +124,12 @@ namespace NzbDrone.Core.Indexers.Newznab if (includeTmdbSearch) { - ids += "&tmdbid=" + searchCriteria.Movie.MovieMetadata.Value.TmdbId; + ids += $"&tmdbid={searchCriteria.Movie.MovieMetadata.Value.TmdbId}"; } if (includeImdbSearch) { - ids += "&imdbid=" + searchCriteria.Movie.MovieMetadata.Value.ImdbId.Substring(2); + ids += $"&imdbid={searchCriteria.Movie.MovieMetadata.Value.ImdbId.Substring(2)}"; } chain.Add(GetPagedRequests(maxPages, categories, "movie", ids)); diff --git a/src/NzbDrone.Core/Indexers/TorrentRssParser.cs b/src/NzbDrone.Core/Indexers/TorrentRssParser.cs index 038840bc2..41350aaed 100644 --- a/src/NzbDrone.Core/Indexers/TorrentRssParser.cs +++ b/src/NzbDrone.Core/Indexers/TorrentRssParser.cs @@ -11,7 +11,7 @@ namespace NzbDrone.Core.Indexers public class TorrentRssParser : RssParser { // Use to sum/calculate Peers as Leechers+Seeders - public bool CalculatePeersAsSum { get; set; } = false; + public bool CalculatePeersAsSum { get; set; } // Use the specified element name to determine the Infohash public string InfoHashElementName { get; set; } diff --git a/src/NzbDrone.Core/Localization/LocalizationService.cs b/src/NzbDrone.Core/Localization/LocalizationService.cs index 66fda0b60..974fa1bb5 100644 --- a/src/NzbDrone.Core/Localization/LocalizationService.cs +++ b/src/NzbDrone.Core/Localization/LocalizationService.cs @@ -127,7 +127,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/MediaFiles/MovieImport/Manual/ManualImportService.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs index 9c5681e03..917102d9a 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs @@ -158,7 +158,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Manual // If the movie is unknown for the directory and there are more than 100 files in the folder don't process the items before returning. var files = _diskScanService.FilterPaths(rootFolder, _diskScanService.GetVideoFiles(baseFolder, false)); - if (files.Count() > 100) + if (files.Count > 100) { _logger.Warn("Unable to determine movie from folder name and found more than 100 files. Skipping parsing"); diff --git a/src/NzbDrone.Core/Notifications/Discord/Discord.cs b/src/NzbDrone.Core/Notifications/Discord/Discord.cs index 9ad14a102..c75f59890 100644 --- a/src/NzbDrone.Core/Notifications/Discord/Discord.cs +++ b/src/NzbDrone.Core/Notifications/Discord/Discord.cs @@ -65,8 +65,9 @@ namespace NzbDrone.Core.Notifications.Discord switch ((DiscordGrabFieldType)field) { case DiscordGrabFieldType.Overview: + var overview = message.Movie.MovieMetadata.Value.Overview ?? ""; discordField.Name = "Overview"; - discordField.Value = message.Movie.MovieMetadata.Value.Overview.Length <= 300 ? message.Movie.MovieMetadata.Value.Overview : message.Movie.MovieMetadata.Value.Overview.Substring(0, 300) + "..."; + discordField.Value = overview.Length <= 300 ? overview : $"{overview.AsSpan(0, 300)}..."; break; case DiscordGrabFieldType.Rating: discordField.Name = "Rating"; @@ -160,8 +161,9 @@ namespace NzbDrone.Core.Notifications.Discord switch ((DiscordImportFieldType)field) { case DiscordImportFieldType.Overview: + var overview = message.Movie.MovieMetadata.Value.Overview ?? ""; discordField.Name = "Overview"; - discordField.Value = message.Movie.MovieMetadata.Value.Overview.Length <= 300 ? message.Movie.MovieMetadata.Value.Overview : message.Movie.MovieMetadata.Value.Overview.Substring(0, 300) + "..."; + discordField.Value = overview.Length <= 300 ? overview : $"{overview.AsSpan(0, 300)}..."; break; case DiscordImportFieldType.Rating: discordField.Name = "Rating"; diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 90522243d..7895b98e7 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -213,7 +213,7 @@ namespace NzbDrone.Core.Parser var titleWithoutExtension = RemoveFileExtension(title).ToCharArray(); Array.Reverse(titleWithoutExtension); - title = new string(titleWithoutExtension) + title.Substring(titleWithoutExtension.Length); + title = $"{titleWithoutExtension}{title.Substring(titleWithoutExtension.Length)}"; Logger.Debug("Reversed name detected. Converted to '{0}'", title); } @@ -282,11 +282,11 @@ namespace NzbDrone.Core.Parser if (match[0].Groups["title"].Success) { simpleReleaseTitle = simpleReleaseTitle.Remove(match[0].Groups["title"].Index, match[0].Groups["title"].Length) - .Insert(match[0].Groups["title"].Index, simpleTitleReplaceString.Contains(".") ? "A.Movie" : "A Movie"); + .Insert(match[0].Groups["title"].Index, simpleTitleReplaceString.Contains('.') ? "A.Movie" : "A Movie"); } else { - simpleReleaseTitle = simpleReleaseTitle.Replace(simpleTitleReplaceString, simpleTitleReplaceString.Contains(".") ? "A.Movie" : "A Movie"); + simpleReleaseTitle = simpleReleaseTitle.Replace(simpleTitleReplaceString, simpleTitleReplaceString.Contains('.') ? "A.Movie" : "A Movie"); } } diff --git a/src/NzbDrone.Core/Parser/SceneChecker.cs b/src/NzbDrone.Core/Parser/SceneChecker.cs index 9b3bfc9ac..7ed7e7134 100644 --- a/src/NzbDrone.Core/Parser/SceneChecker.cs +++ b/src/NzbDrone.Core/Parser/SceneChecker.cs @@ -11,12 +11,12 @@ namespace NzbDrone.Core.Parser return null; } - if (!title.Contains(".")) + if (!title.Contains('.')) { return null; } - if (title.Contains(" ")) + if (title.Contains(' ')) { return null; } diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs index ad6c265f8..37aa8cbc0 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -46,7 +46,7 @@ namespace NzbDrone.Host try { Logger.Info("Starting Radarr - {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 6f069235c..5f9e3bda2 100644 --- a/src/NzbDrone.Host/Startup.cs +++ b/src/NzbDrone.Host/Startup.cs @@ -126,7 +126,7 @@ namespace NzbDrone.Host c.AddSecurityRequirement(new OpenApiSecurityRequirement { - { apiKeyHeader, new string[] { } } + { apiKeyHeader, Array.Empty() } }); var apikeyQuery = new OpenApiSecurityScheme @@ -157,7 +157,7 @@ namespace NzbDrone.Host c.AddSecurityRequirement(new OpenApiSecurityRequirement { - { apikeyQuery, new string[] { } } + { apikeyQuery, Array.Empty() } }); }); diff --git a/src/NzbDrone.Mono/Disk/ProcMountProvider.cs b/src/NzbDrone.Mono/Disk/ProcMountProvider.cs index 5900d203c..2cce7d8b6 100644 --- a/src/NzbDrone.Mono/Disk/ProcMountProvider.cs +++ b/src/NzbDrone.Mono/Disk/ProcMountProvider.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Mono.Disk private static Dictionary _fileSystems; - private bool _hasLoggedProcMountFailure = false; + private bool _hasLoggedProcMountFailure; public ProcMountProvider(Logger logger) { 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/Radarr.Api.V3/System/Backup/BackupController.cs b/src/Radarr.Api.V3/System/Backup/BackupController.cs index 0cd95ab22..4077fb87a 100644 --- a/src/Radarr.Api.V3/System/Backup/BackupController.cs +++ b/src/Radarr.Api.V3/System/Backup/BackupController.cs @@ -93,7 +93,7 @@ namespace Radarr.Api.V3.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/Radarr.Http/Frontend/Mappers/IndexHtmlMapper.cs b/src/Radarr.Http/Frontend/Mappers/IndexHtmlMapper.cs index 2d1a2d102..39ae36916 100644 --- a/src/Radarr.Http/Frontend/Mappers/IndexHtmlMapper.cs +++ b/src/Radarr.Http/Frontend/Mappers/IndexHtmlMapper.cs @@ -35,7 +35,7 @@ namespace Radarr.Http.Frontend.Mappers return !resourceUrl.StartsWith("/content") && !resourceUrl.StartsWith("/mediacover") && - !resourceUrl.Contains(".") && + !resourceUrl.Contains('.') && !resourceUrl.StartsWith("/login"); } } diff --git a/src/Radarr.Http/Middleware/StartingUpMiddleware.cs b/src/Radarr.Http/Middleware/StartingUpMiddleware.cs index 9a5cb9bf3..368ed877a 100644 --- a/src/Radarr.Http/Middleware/StartingUpMiddleware.cs +++ b/src/Radarr.Http/Middleware/StartingUpMiddleware.cs @@ -12,9 +12,9 @@ namespace Radarr.Http.Middleware { public class StartingUpMiddleware { + private const string MESSAGE = "Radarr is starting up, please try again later"; private readonly RequestDelegate _next; private readonly IRuntimeInfo _runtimeInfo; - private static readonly string MESSAGE = "Radarr is starting up, please try again later"; public StartingUpMiddleware(RequestDelegate next, IRuntimeInfo runtimeInfo) { @@ -32,7 +32,7 @@ namespace Radarr.Http.Middleware context.Response.StatusCode = 503; context.Response.ContentType = isJson ? "application/json" : "text/plain"; - await context.Response.Body.WriteAsync(bytes, 0, bytes.Length); + await context.Response.Body.WriteAsync(bytes); return; }