diff --git a/.editorconfig b/.editorconfig index b208caf04..a78530bfe 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 @@ -188,24 +191,14 @@ dotnet_diagnostic.CA1814.severity = suggestion dotnet_diagnostic.CA1815.severity = suggestion dotnet_diagnostic.CA1816.severity = suggestion dotnet_diagnostic.CA1819.severity = suggestion -dotnet_diagnostic.CA1820.severity = suggestion -dotnet_diagnostic.CA1821.severity = suggestion dotnet_diagnostic.CA1822.severity = suggestion dotnet_diagnostic.CA1823.severity = suggestion dotnet_diagnostic.CA1824.severity = suggestion -dotnet_diagnostic.CA1825.severity = suggestion -dotnet_diagnostic.CA1826.severity = suggestion -dotnet_diagnostic.CA1827.severity = suggestion -dotnet_diagnostic.CA1828.severity = suggestion -dotnet_diagnostic.CA1829.severity = suggestion -dotnet_diagnostic.CA1834.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 @@ -236,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 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 a3b28bdb0..8dd6874a3 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,8 +1,10 @@ + 6.0-all true - false + true + false AnyCPU true diff --git a/src/Lidarr.Api.V1/FileSystem/FileSystemController.cs b/src/Lidarr.Api.V1/FileSystem/FileSystemController.cs index 353f06ad5..88e6f273f 100644 --- a/src/Lidarr.Api.V1/FileSystem/FileSystemController.cs +++ b/src/Lidarr.Api.V1/FileSystem/FileSystemController.cs @@ -45,7 +45,7 @@ namespace Lidarr.Api.V1.FileSystem { if (!_diskProvider.FolderExists(path)) { - return new string[0]; + return global::System.Array.Empty(); } return _diskScanService.GetAudioFiles(path).Select(f => new diff --git a/src/Lidarr.Api.V1/System/Backup/BackupController.cs b/src/Lidarr.Api.V1/System/Backup/BackupController.cs index 7bb70827f..4acdb0ffa 100644 --- a/src/Lidarr.Api.V1/System/Backup/BackupController.cs +++ b/src/Lidarr.Api.V1/System/Backup/BackupController.cs @@ -93,7 +93,7 @@ namespace Lidarr.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/Lidarr.Http/Frontend/Mappers/IndexHtmlMapper.cs b/src/Lidarr.Http/Frontend/Mappers/IndexHtmlMapper.cs index 2f0b6d445..742c09b14 100644 --- a/src/Lidarr.Http/Frontend/Mappers/IndexHtmlMapper.cs +++ b/src/Lidarr.Http/Frontend/Mappers/IndexHtmlMapper.cs @@ -35,7 +35,7 @@ namespace Lidarr.Http.Frontend.Mappers return !resourceUrl.StartsWith("/content") && !resourceUrl.StartsWith("/mediacover") && - !resourceUrl.Contains(".") && + !resourceUrl.Contains('.') && !resourceUrl.StartsWith("/login"); } } diff --git a/src/Lidarr.Http/Middleware/StartingUpMiddleware.cs b/src/Lidarr.Http/Middleware/StartingUpMiddleware.cs index 486f83e0d..4c2b13b51 100644 --- a/src/Lidarr.Http/Middleware/StartingUpMiddleware.cs +++ b/src/Lidarr.Http/Middleware/StartingUpMiddleware.cs @@ -9,9 +9,9 @@ namespace Lidarr.Http.Middleware { public class StartingUpMiddleware { + private const string MESSAGE = "Lidarr is starting up, please try again later"; private readonly RequestDelegate _next; private readonly IRuntimeInfo _runtimeInfo; - private static readonly string MESSAGE = "Lidarr is starting up, please try again later"; public StartingUpMiddleware(RequestDelegate next, IRuntimeInfo runtimeInfo) { @@ -29,7 +29,7 @@ namespace Lidarr.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; } diff --git a/src/NzbDrone.Common.Test/EnvironmentTests/StartupArgumentsFixture.cs b/src/NzbDrone.Common.Test/EnvironmentTests/StartupArgumentsFixture.cs index 07df9c79e..4313271db 100644 --- a/src/NzbDrone.Common.Test/EnvironmentTests/StartupArgumentsFixture.cs +++ b/src/NzbDrone.Common.Test/EnvironmentTests/StartupArgumentsFixture.cs @@ -11,7 +11,7 @@ namespace NzbDrone.Common.Test.EnvironmentTests [Test] public void empty_array_should_return_empty_flags() { - var args = new StartupContext(new string[0]); + var args = new StartupContext(System.Array.Empty()); args.Flags.Should().BeEmpty(); } diff --git a/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs b/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs index 1f2a18916..643568acd 100644 --- a/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs +++ b/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs @@ -460,7 +460,7 @@ namespace NzbDrone.Common.Test.Http var oldRequest = new HttpRequest($"https://{_httpBinHost2}/get"); oldRequest.Cookies["my"] = "cookie"; - var oldClient = new HttpClient(new IHttpRequestInterceptor[0], Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve()); + var oldClient = new HttpClient(Array.Empty(), Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve()); oldClient.Should().NotBeSameAs(Subject); diff --git a/src/NzbDrone.Common/Extensions/FuzzyContains.cs b/src/NzbDrone.Common/Extensions/FuzzyContains.cs index e3aad635a..451c0cd7e 100644 --- a/src/NzbDrone.Common/Extensions/FuzzyContains.cs +++ b/src/NzbDrone.Common/Extensions/FuzzyContains.cs @@ -91,7 +91,7 @@ namespace NzbDrone.Common.Extensions int best_loc = -1; // Empty initialization added to appease C# compiler. - var last_rd = new BigInteger[0]; + var last_rd = Array.Empty(); for (int d = 0; d < pattern.Length; d++) { // Scan for the best match; each iteration allows for one more error. diff --git a/src/NzbDrone.Common/Extensions/StringExtensions.cs b/src/NzbDrone.Common/Extensions/StringExtensions.cs index e71a14fcb..02156b253 100644 --- a/src/NzbDrone.Common/Extensions/StringExtensions.cs +++ b/src/NzbDrone.Common/Extensions/StringExtensions.cs @@ -126,7 +126,7 @@ namespace NzbDrone.Common.Extensions public static string WrapInQuotes(this string text) { - if (!text.Contains(" ")) + if (!text.Contains(' ')) { return text; } @@ -170,7 +170,7 @@ namespace NzbDrone.Common.Extensions { return 0; } - else if (a.Contains(" ") && b.Contains(" ")) + else if (a.Contains(' ') && b.Contains(' ')) { var partsA = a.Split(' '); var partsB = b.Split(' '); @@ -256,7 +256,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/HttpResponse.cs b/src/NzbDrone.Common/Http/HttpResponse.cs index bc4bc2c74..43340c40e 100644 --- a/src/NzbDrone.Common/Http/HttpResponse.cs +++ b/src/NzbDrone.Common/Http/HttpResponse.cs @@ -60,7 +60,7 @@ namespace NzbDrone.Common.Http public string[] GetCookieHeaders() { - return Headers.GetValues("Set-Cookie") ?? new string[0]; + return Headers.GetValues("Set-Cookie") ?? Array.Empty(); } public Dictionary GetCookies() diff --git a/src/NzbDrone.Common/Http/HttpUri.cs b/src/NzbDrone.Common/Http/HttpUri.cs index 647da04ee..d9d915bb8 100644 --- a/src/NzbDrone.Common/Http/HttpUri.cs +++ b/src/NzbDrone.Common/Http/HttpUri.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Common.Http if (scheme.IsNotNullOrWhiteSpace()) { builder.Append(scheme); - builder.Append(":"); + builder.Append(':'); } if (host.IsNotNullOrWhiteSpace()) @@ -36,7 +36,7 @@ namespace NzbDrone.Common.Http builder.Append(host); if (port.HasValue) { - builder.Append(":"); + builder.Append(':'); builder.Append(port); } } @@ -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; @@ -202,11 +202,11 @@ namespace NzbDrone.Common.Http { if (builder.Length != 0) { - builder.Append("&"); + builder.Append('&'); } builder.Append(Uri.EscapeDataString(pair.Key)); - builder.Append("="); + builder.Append('='); builder.Append(Uri.EscapeDataString(pair.Value)); } diff --git a/src/NzbDrone.Common/Http/Proxy/HttpProxySettings.cs b/src/NzbDrone.Common/Http/Proxy/HttpProxySettings.cs index 58a7541da..ce7dc7608 100644 --- a/src/NzbDrone.Common/Http/Proxy/HttpProxySettings.cs +++ b/src/NzbDrone.Common/Http/Proxy/HttpProxySettings.cs @@ -41,7 +41,7 @@ namespace NzbDrone.Common.Http.Proxy return hostlist; } - return new string[] { }; + return System.Array.Empty(); } } diff --git a/src/NzbDrone.Common/OAuth/OAuthRequest.cs b/src/NzbDrone.Common/OAuth/OAuthRequest.cs index 7f84d9e7f..99275bf03 100644 --- a/src/NzbDrone.Common/OAuth/OAuthRequest.cs +++ b/src/NzbDrone.Common/OAuth/OAuthRequest.cs @@ -488,7 +488,7 @@ namespace NzbDrone.Common.OAuth private static bool IsNullOrBlank(string value) { - return string.IsNullOrEmpty(value) || (!string.IsNullOrEmpty(value) && value.Trim() == string.Empty); + return string.IsNullOrEmpty(value) || (!string.IsNullOrEmpty(value) && string.IsNullOrEmpty(value.Trim())); } } } diff --git a/src/NzbDrone.Common/OAuth/OAuthTools.cs b/src/NzbDrone.Common/OAuth/OAuthTools.cs index ef8a8a343..9d4b14aab 100644 --- a/src/NzbDrone.Common/OAuth/OAuthTools.cs +++ b/src/NzbDrone.Common/OAuth/OAuthTools.cs @@ -405,7 +405,7 @@ namespace NzbDrone.Common.OAuth private static bool IsNullOrBlank(string value) { - return string.IsNullOrEmpty(value) || (!string.IsNullOrEmpty(value) && value.Trim() == string.Empty); + return string.IsNullOrEmpty(value) || (!string.IsNullOrEmpty(value) && string.IsNullOrEmpty(value.Trim())); } } } diff --git a/src/NzbDrone.Common/OAuth/WebParameterCollection.cs b/src/NzbDrone.Common/OAuth/WebParameterCollection.cs index a1084a0ef..cea68b114 100644 --- a/src/NzbDrone.Common/OAuth/WebParameterCollection.cs +++ b/src/NzbDrone.Common/OAuth/WebParameterCollection.cs @@ -16,7 +16,7 @@ namespace NzbDrone.Common.OAuth { var parameters = this.Where(p => p.Name.Equals(name)); - if (parameters.Count() == 0) + if (!parameters.Any()) { return null; } diff --git a/src/NzbDrone.Common/ServiceProvider.cs b/src/NzbDrone.Common/ServiceProvider.cs index 6c6c8db4f..8f9f4ee90 100644 --- a/src/NzbDrone.Common/ServiceProvider.cs +++ b/src/NzbDrone.Common/ServiceProvider.cs @@ -65,7 +65,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 770ca59a7..4c28feb67 100644 --- a/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs +++ b/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -19,7 +19,7 @@ namespace NzbDrone.Common.TPL private readonly int _maxDegreeOfParallelism; /// Whether the scheduler is currently processing work items. - private int _delegatesQueuedOrRunning = 0; // protected by lock(_tasks) + private int _delegatesQueuedOrRunning; // protected by lock(_tasks) /// /// Initializes an instance of the LimitedConcurrencyLevelTaskScheduler class with the diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/023_add_release_groups_etcFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/023_add_release_groups_etcFixture.cs index 0278fbb79..dfcad6cf8 100644 --- a/src/NzbDrone.Core.Test/Datastore/Migration/023_add_release_groups_etcFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/Migration/023_add_release_groups_etcFixture.cs @@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration var albums = db.Query("SELECT * FROM \"Albums\""); // we only put in one release per album - releases.Count().Should().Be(albums.Count()); + releases.Count.Should().Be(albums.Count); // each album should be linked to exactly one release releases.Select(x => x.AlbumId).SequenceEqual(albums.Select(x => x.Id)).Should().Be(true); diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/030_add_mediafilerepository_mtimeFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/030_add_mediafilerepository_mtimeFixture.cs index 67a82d38f..1abb1d4b6 100644 --- a/src/NzbDrone.Core.Test/Datastore/Migration/030_add_mediafilerepository_mtimeFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/Migration/030_add_mediafilerepository_mtimeFixture.cs @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration [TestFixture] public class add_mediafilerepository_mtimeFixture : MigrationTest { - private string _artistPath = null; + private string _artistPath; private void GivenArtist(add_mediafilerepository_mtime c, int id, string name) { diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/031_add_artistmetadataid_constraintFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/031_add_artistmetadataid_constraintFixture.cs index b83e38e74..b9a91e4f3 100644 --- a/src/NzbDrone.Core.Test/Datastore/Migration/031_add_artistmetadataid_constraintFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/Migration/031_add_artistmetadataid_constraintFixture.cs @@ -11,7 +11,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration [TestFixture] public class add_artistmetadataid_constraintFixture : MigrationTest { - private string _artistPath = null; + private string _artistPath; private void GivenArtistMetadata(add_artistmetadataid_constraint c, int id, string name) { diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs index e7c14527b..fabffce97 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs @@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests 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 GivenFailedDownload() diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs index 48464e8e9..d09d7ed8b 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs @@ -34,7 +34,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests 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())); Mocker.GetMock() .Setup(v => v.RemapRemoteToLocal(It.IsAny(), It.IsAny())) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs index 7ee104258..451d7d5c4 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs @@ -278,7 +278,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests 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())); _downloadStationConfigItems = new Dictionary { diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs index 36b212395..6b0335b64 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs @@ -170,7 +170,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests 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())); _downloadStationConfigItems = new Dictionary { diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/HadoukenTests/HadoukenFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/HadoukenTests/HadoukenFixture.cs index 8fade99fc..8bf6825a6 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/HadoukenTests/HadoukenFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/HadoukenTests/HadoukenFixture.cs @@ -86,7 +86,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests 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 GivenFailedDownload() diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs index 426f61c4a..fca18bcce 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs @@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests 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())); Mocker.GetMock() .Setup(s => s.GetConfig(It.IsAny())) @@ -56,7 +56,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests Mocker.GetMock() .Setup(s => s.Get(It.IsAny())) - .Returns(r => new HttpResponse(r, httpHeader, new byte[0], System.Net.HttpStatusCode.SeeOther)); + .Returns(r => new HttpResponse(r, httpHeader, Array.Empty(), System.Net.HttpStatusCode.SeeOther)); } protected void GivenRedirectToTorrent() @@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests Mocker.GetMock() .Setup(s => s.Get(It.Is(h => h.Url.FullUri == _downloadUrl))) - .Returns(r => new HttpResponse(r, httpHeader, new byte[0], System.Net.HttpStatusCode.Found)); + .Returns(r => new HttpResponse(r, httpHeader, Array.Empty(), System.Net.HttpStatusCode.Found)); } protected void GivenFailedDownload() @@ -522,7 +522,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests Mocker.GetMock() .Setup(v => v.MoveTorrentToTopInQueue(It.IsAny(), It.IsAny())) - .Throws(new HttpException(new HttpResponse(new HttpRequest("http://me.local/"), new HttpHeader(), new byte[0], System.Net.HttpStatusCode.Forbidden))); + .Throws(new HttpException(new HttpResponse(new HttpRequest("http://me.local/"), new HttpHeader(), Array.Empty(), System.Net.HttpStatusCode.Forbidden))); var remoteAlbum = CreateRemoteAlbum(); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs index 57dfcb757..a7db61183 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs @@ -544,7 +544,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests public void should_test_failed_if_tv_sorting_empty() { _config.Misc.enable_tv_sorting = true; - _config.Misc.tv_categories = new string[0]; + _config.Misc.tv_categories = Array.Empty(); var result = new NzbDroneValidationResult(Subject.Test()); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixtureBase.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixtureBase.cs index a29dbbd3e..c4f239f33 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixtureBase.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixtureBase.cs @@ -99,7 +99,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests 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())); _transmissionConfigItems = new Dictionary(); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs index 17c8bc952..ce4050f48 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs @@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests 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 GivenRedirectToMagnet() @@ -101,7 +101,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests Mocker.GetMock() .Setup(s => s.Get(It.IsAny())) - .Returns(r => new HttpResponse(r, httpHeader, new byte[0], System.Net.HttpStatusCode.SeeOther)); + .Returns(r => new HttpResponse(r, httpHeader, Array.Empty(), System.Net.HttpStatusCode.SeeOther)); } protected void GivenRedirectToTorrent() @@ -111,7 +111,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests Mocker.GetMock() .Setup(s => s.Get(It.Is(h => h.Url.ToString() == _downloadUrl))) - .Returns(r => new HttpResponse(r, httpHeader, new byte[0], System.Net.HttpStatusCode.Found)); + .Returns(r => new HttpResponse(r, httpHeader, Array.Empty(), System.Net.HttpStatusCode.Found)); } protected void GivenFailedDownload() diff --git a/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs index b1cda4833..fcf5f7d51 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs @@ -130,7 +130,7 @@ namespace NzbDrone.Core.Test.Download public void Download_report_should_trigger_indexer_backoff_on_http429_with_long_time() { var request = new HttpRequest("http://my.indexer.com"); - var response = new HttpResponse(request, new HttpHeader(), new byte[0], (HttpStatusCode)429); + var response = new HttpResponse(request, new HttpHeader(), Array.Empty(), (HttpStatusCode)429); response.Headers["Retry-After"] = "300"; var mock = WithUsenetClient(); @@ -150,7 +150,7 @@ namespace NzbDrone.Core.Test.Download public void Download_report_should_trigger_indexer_backoff_on_http429_based_on_date() { var request = new HttpRequest("http://my.indexer.com"); - var response = new HttpResponse(request, new HttpHeader(), new byte[0], (HttpStatusCode)429); + var response = new HttpResponse(request, new HttpHeader(), Array.Empty(), (HttpStatusCode)429); response.Headers["Retry-After"] = DateTime.UtcNow.AddSeconds(300).ToString("r"); var mock = WithUsenetClient(); diff --git a/src/NzbDrone.Core.Test/Framework/CoreTest.cs b/src/NzbDrone.Core.Test/Framework/CoreTest.cs index 550309a34..b1213cb6e 100644 --- a/src/NzbDrone.Core.Test/Framework/CoreTest.cs +++ b/src/NzbDrone.Core.Test/Framework/CoreTest.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.Framework Mocker.SetConstant(new ManagedWebProxyFactory(Mocker.Resolve())); Mocker.SetConstant(new X509CertificateValidationService(Mocker.Resolve(), TestLogger)); Mocker.SetConstant(new ManagedHttpDispatcher(Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve(), TestLogger)); - Mocker.SetConstant(new HttpClient(new IHttpRequestInterceptor[0], Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve(), TestLogger)); + Mocker.SetConstant(new HttpClient(Array.Empty(), Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve(), TestLogger)); Mocker.SetConstant(new LidarrCloudRequestBuilder()); Mocker.SetConstant(Mocker.Resolve()); } diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/DownloadClientCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/DownloadClientCheckFixture.cs index 75ea979d2..0b37d192d 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/DownloadClientCheckFixture.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/DownloadClientCheckFixture.cs @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks { Mocker.GetMock() .Setup(s => s.GetDownloadClients(It.IsAny())) - .Returns(new IDownloadClient[0]); + .Returns(Array.Empty()); Subject.Check().ShouldBeWarning(); } diff --git a/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifyFollowedArtistsFixture.cs b/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifyFollowedArtistsFixture.cs index d293b4ec4..6f7f94c99 100644 --- a/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifyFollowedArtistsFixture.cs +++ b/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifyFollowedArtistsFixture.cs @@ -12,9 +12,6 @@ namespace NzbDrone.Core.Test.ImportListTests [TestFixture] public class SpotifyFollowedArtistsFixture : CoreTest { - // placeholder, we don't use real API - private readonly SpotifyWebAPI _api = null; - [Test] public void should_not_throw_if_followed_is_null() { @@ -23,7 +20,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(default(FollowedArtists)); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().BeEmpty(); } @@ -41,7 +38,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(followed); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().BeEmpty(); } @@ -62,10 +59,10 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(followed); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().BeEmpty(); - Subject.Fetch(_api); + Subject.Fetch(null); } [Test] @@ -87,10 +84,10 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(followed); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().BeEmpty(); - Subject.Fetch(_api); + Subject.Fetch(null); } [Test] @@ -115,7 +112,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(followed); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().HaveCount(1); } @@ -149,7 +146,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(default(FollowedArtists)); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().HaveCount(1); @@ -183,7 +180,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(followed); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().BeEmpty(); } diff --git a/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifyMappingFixture.cs b/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifyMappingFixture.cs index af4ebb1ac..0d04d71cf 100644 --- a/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifyMappingFixture.cs +++ b/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifyMappingFixture.cs @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.ImportListTests { Mocker.GetMock() .Setup(x => x.Get(It.IsAny())) - .Returns((x) => new HttpResponse(new HttpResponse(x, new HttpHeader(), new byte[0], HttpStatusCode.NotFound))); + .Returns((x) => new HttpResponse(new HttpResponse(x, new HttpHeader(), Array.Empty(), HttpStatusCode.NotFound))); var data = new SpotifyImportListItemInfo { @@ -120,7 +120,7 @@ namespace NzbDrone.Core.Test.ImportListTests { Mocker.GetMock() .Setup(x => x.Get(It.IsAny())) - .Returns((x) => new HttpResponse(new HttpResponse(x, new HttpHeader(), new byte[0], HttpStatusCode.NotFound))); + .Returns((x) => new HttpResponse(new HttpResponse(x, new HttpHeader(), Array.Empty(), HttpStatusCode.NotFound))); var data = new SpotifyImportListItemInfo { diff --git a/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifyPlaylistFixture.cs b/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifyPlaylistFixture.cs index a9f9c5bef..7689bb15b 100644 --- a/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifyPlaylistFixture.cs +++ b/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifyPlaylistFixture.cs @@ -12,9 +12,6 @@ namespace NzbDrone.Core.Test.ImportListTests [TestFixture] public class SpotifyPlaylistFixture : CoreTest { - // placeholder, we don't use real API - private readonly SpotifyWebAPI _api = null; - [Test] public void should_not_throw_if_playlist_tracks_is_null() { @@ -25,7 +22,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(default(Paging)); - var result = Subject.Fetch(_api, "playlistid"); + var result = Subject.Fetch(null, "playlistid"); result.Should().BeEmpty(); } @@ -45,7 +42,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(playlistTracks); - var result = Subject.Fetch(_api, "playlistid"); + var result = Subject.Fetch(null, "playlistid"); result.Should().BeEmpty(); } @@ -68,7 +65,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(playlistTracks); - var result = Subject.Fetch(_api, "playlistid"); + var result = Subject.Fetch(null, "playlistid"); result.Should().BeEmpty(); } @@ -114,7 +111,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(playlistTracks); - var result = Subject.Fetch(_api, "playlistid"); + var result = Subject.Fetch(null, "playlistid"); result.Should().HaveCount(1); result[0].Artist.Should().Be("AlbumArtist"); @@ -161,7 +158,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(playlistTracks); - var result = Subject.Fetch(_api, "playlistid"); + var result = Subject.Fetch(null, "playlistid"); result.Should().HaveCount(1); result[0].Artist.Should().Be("TrackArtist"); @@ -210,7 +207,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(playlistTracks); - var result = Subject.Fetch(_api, "playlistid"); + var result = Subject.Fetch(null, "playlistid"); result.Should().BeEmpty(); } @@ -263,7 +260,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny>())) .Returns(default(Paging)); - var result = Subject.Fetch(_api, "playlistid"); + var result = Subject.Fetch(null, "playlistid"); result.Should().HaveCount(1); diff --git a/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifySavedAlbumsFixture.cs b/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifySavedAlbumsFixture.cs index 4f1371f5d..9679a7705 100644 --- a/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifySavedAlbumsFixture.cs +++ b/src/NzbDrone.Core.Test/ImportListTests/Spotify/SpotifySavedAlbumsFixture.cs @@ -12,9 +12,6 @@ namespace NzbDrone.Core.Test.ImportListTests [TestFixture] public class SpotifySavedAlbumsFixture : CoreTest { - // placeholder, we don't use real API - private readonly SpotifyWebAPI _api = null; - [Test] public void should_not_throw_if_saved_albums_is_null() { @@ -23,7 +20,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(default(Paging)); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().BeEmpty(); } @@ -41,7 +38,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(savedAlbums); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().BeEmpty(); } @@ -62,7 +59,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(savedAlbums); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().BeEmpty(); } @@ -96,7 +93,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(savedAlbums); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().HaveCount(1); } @@ -137,7 +134,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny>())) .Returns(default(Paging)); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().HaveCount(1); @@ -179,7 +176,7 @@ namespace NzbDrone.Core.Test.ImportListTests It.IsAny())) .Returns(savedAlbums); - var result = Subject.Fetch(_api); + var result = Subject.Fetch(null); result.Should().BeEmpty(); } diff --git a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs index 8dfa3fccb..68c78043b 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs @@ -86,7 +86,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests public void should_record_indexer_failure_if_caps_throw() { var request = new HttpRequest("http://my.indexer.com"); - var response = new HttpResponse(request, new HttpHeader(), new byte[0], (HttpStatusCode)429); + var response = new HttpResponse(request, new HttpHeader(), Array.Empty(), (HttpStatusCode)429); response.Headers["Retry-After"] = "300"; Mocker.GetMock() diff --git a/src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs index 04c3525bc..4099b95d3 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/AudioTagServiceFixture.cs @@ -240,9 +240,9 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture var tag = Subject.ReadAudioTag(path); var expected = new AudioTag() { - Performers = new string[0], - AlbumArtists = new string[0], - Genres = new string[0] + Performers = Array.Empty(), + AlbumArtists = Array.Empty(), + Genres = Array.Empty() }; VerifySame(tag, expected, skipProperties); diff --git a/src/NzbDrone.Core.Test/MediaFiles/DownloadedTracksImportServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DownloadedTracksImportServiceFixture.cs index 113f2b32f..3c0707ad9 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/DownloadedTracksImportServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/DownloadedTracksImportServiceFixture.cs @@ -96,7 +96,7 @@ namespace NzbDrone.Core.Test.MediaFiles private void WasImportedResponse() { Mocker.GetMock().Setup(c => c.GetAudioFiles(It.IsAny(), It.IsAny())) - .Returns(new IFileInfo[0]); + .Returns(System.Array.Empty()); } [Test] @@ -147,7 +147,7 @@ namespace NzbDrone.Core.Test.MediaFiles Mocker.GetMock() .Setup(c => c.GetAudioFiles(It.IsAny(), It.IsAny())) - .Returns(new IFileInfo[0]); + .Returns(System.Array.Empty()); Subject.ProcessRootFolder(DiskProvider.GetDirectoryInfo(_droneFactory)); diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaFileDeletionService/DeleteTrackFileFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaFileDeletionService/DeleteTrackFileFixture.cs index 48d3006db..ab9446d4d 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaFileDeletionService/DeleteTrackFileFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaFileDeletionService/DeleteTrackFileFixture.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileDeletionService [TestFixture] public class DeleteTrackFileFixture : CoreTest { - private static readonly string RootFolder = @"C:\Test\Music"; + private const string RootFolder = @"C:\Test\Music"; private Artist _artist; private TrackFile _trackFile; diff --git a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 9ab6fb580..51380763f 100644 --- a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -266,7 +266,7 @@ namespace NzbDrone.Core.Configuration var valueHolder = parentContainer.Descendants(key).ToList(); - if (valueHolder.Count() == 1) + if (valueHolder.Count == 1) { return valueHolder.First().Value.Trim(); } diff --git a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSyntaxReader.cs b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSyntaxReader.cs index c41425ab7..8ca85ba88 100644 --- a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSyntaxReader.cs +++ b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSyntaxReader.cs @@ -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 b63e861c4..fe951228b 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 576182f7d..b91c9e61e 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) { @@ -44,7 +44,7 @@ namespace NzbDrone.Core.Datastore protected override Expression VisitBinary(BinaryExpression expression) { - _sb.Append("("); + _sb.Append('('); Visit(expression.Left); @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Datastore Visit(expression.Right); - _sb.Append(")"); + _sb.Append(')'); return expression; } @@ -309,7 +309,7 @@ namespace NzbDrone.Core.Datastore item = body.Arguments[1]; } - _sb.Append("("); + _sb.Append('('); Visit(item); @@ -319,9 +319,9 @@ namespace NzbDrone.Core.Datastore if (item.Type == typeof(int) && TryGetRightValue(list, out var value)) { var items = (IEnumerable)value; - _sb.Append("("); + _sb.Append('('); _sb.Append(string.Join(", ", items)); - _sb.Append(")"); + _sb.Append(')'); _gotConcreteValue = true; } @@ -330,12 +330,12 @@ namespace NzbDrone.Core.Datastore Visit(list); } - _sb.Append(")"); + _sb.Append(')'); } private void ParseStringContains(MethodCallExpression body) { - _sb.Append("("); + _sb.Append('('); Visit(body.Object); @@ -348,7 +348,7 @@ namespace NzbDrone.Core.Datastore private void ParseStartsWith(MethodCallExpression body) { - _sb.Append("("); + _sb.Append('('); Visit(body.Object); @@ -361,7 +361,7 @@ namespace NzbDrone.Core.Datastore private void ParseEndsWith(MethodCallExpression body) { - _sb.Append("("); + _sb.Append('('); Visit(body.Object); @@ -369,7 +369,7 @@ namespace NzbDrone.Core.Datastore Visit(body.Arguments[0]); - _sb.Append(")"); + _sb.Append(')'); } public override string ToString() diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs index 4c4a8a2c9..09dfcd5ea 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs @@ -185,7 +185,7 @@ namespace NzbDrone.Core.DecisionEngine private DownloadDecision GetDecisionForReport(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria = null) { - var reasons = new Rejection[0]; + var reasons = Array.Empty(); foreach (var specifications in _specifications.GroupBy(v => v.Priority).OrderBy(v => v.Key)) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/AlreadyImportedSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/AlreadyImportedSpecification.cs index afb69c1ec..da16edac8 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/AlreadyImportedSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/AlreadyImportedSpecification.cs @@ -46,7 +46,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications { var trackFiles = _mediaFileService.GetFilesByAlbum(album.Id); - if (trackFiles.Count() == 0) + if (trackFiles.Count == 0) { _logger.Debug("Skipping already imported check for album without files"); continue; diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs index 9dbdccb24..870fc63b7 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs @@ -361,7 +361,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge { if (result.Torrents == null) { - return new DelugeTorrent[0]; + return Array.Empty(); } return result.Torrents.Values.ToArray(); diff --git a/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs b/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs index ec0dd1ffe..5dd548e5a 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs @@ -112,7 +112,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken { if (torrentsRaw == null) { - return new HadoukenTorrent[0]; + return Array.Empty(); } var torrents = new List(); diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdQueueTimeConverter.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdQueueTimeConverter.cs index 10efa12b2..a94c7811a 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdQueueTimeConverter.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdQueueTimeConverter.cs @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters { var split = reader.Value.ToString().Split(':').Select(int.Parse).ToArray(); - switch (split.Count()) + switch (split.Length) { case 4: return new TimeSpan((split[0] * 24) + split[1], split[2], split[3]); diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs index 6334625b7..f73bebfc7 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs @@ -116,9 +116,9 @@ namespace NzbDrone.Core.Download.Pending _logger.Debug("The release {0} is already pending with reason {1}, not adding again", decision.RemoteAlbum, reason); } - if (matchingReports.Count() > 1) + if (matchingReports.Count > 1) { - _logger.Debug("The release {0} had {1} duplicate pending, removing duplicates.", decision.RemoteAlbum, matchingReports.Count() - 1); + _logger.Debug("The release {0} had {1} duplicate pending, removing duplicates.", decision.RemoteAlbum, matchingReports.Count - 1); foreach (var duplicate in matchingReports.Skip(1)) { diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs index 02d313751..e12949bd1 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads public TrackedDownload() { - StatusMessages = new TrackedDownloadStatusMessage[] { }; + StatusMessages = System.Array.Empty(); } public void Warn(string message, params object[] args) diff --git a/src/NzbDrone.Core/Extras/Lyrics/LyricService.cs b/src/NzbDrone.Core/Extras/Lyrics/LyricService.cs index 78325429c..a2560b084 100644 --- a/src/NzbDrone.Core/Extras/Lyrics/LyricService.cs +++ b/src/NzbDrone.Core/Extras/Lyrics/LyricService.cs @@ -111,7 +111,7 @@ namespace NzbDrone.Core.Extras.Lyrics if (multipleCopies) { - suffixBuilder.Append("."); + suffixBuilder.Append('.'); suffixBuilder.Append(copy); } diff --git a/src/NzbDrone.Core/HealthCheck/HealthCheckService.cs b/src/NzbDrone.Core/HealthCheck/HealthCheckService.cs index 36bc6e969..1957ce276 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/ImportLists/Spotify/SpotifyPlaylistSettings.cs b/src/NzbDrone.Core/ImportLists/Spotify/SpotifyPlaylistSettings.cs index ac4d87199..2b18f9d81 100644 --- a/src/NzbDrone.Core/ImportLists/Spotify/SpotifyPlaylistSettings.cs +++ b/src/NzbDrone.Core/ImportLists/Spotify/SpotifyPlaylistSettings.cs @@ -19,7 +19,7 @@ namespace NzbDrone.Core.ImportLists.Spotify public SpotifyPlaylistSettings() { - PlaylistIds = new string[] { }; + PlaylistIds = System.Array.Empty(); } public override string Scope => "playlist-read-private"; diff --git a/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssSettingsDetector.cs b/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssSettingsDetector.cs index d9bc95c22..e2b4fb466 100644 --- a/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssSettingsDetector.cs +++ b/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssSettingsDetector.cs @@ -176,7 +176,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss releases = ParseResponse(parser, response); ValidateReleases(releases, indexerSettings); - if (releases.Count(r => r.Size >= ValidSizeThreshold) > releases.Count() / 2) + if (releases.Count(r => r.Size >= ValidSizeThreshold) > releases.Length / 2) { if (releases.Any(r => r.Size < ValidSizeThreshold)) { 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/MediaCover/MediaCoverService.cs b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs index a36c93e01..7d7a19b91 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs @@ -283,7 +283,7 @@ namespace NzbDrone.Core.MediaCover switch (coverType) { default: - return new int[] { }; + return Array.Empty(); case MediaCoverTypes.Poster: case MediaCoverTypes.Disc: diff --git a/src/NzbDrone.Core/MediaFiles/AudioTag.cs b/src/NzbDrone.Core/MediaFiles/AudioTag.cs index f5b226dc2..1b0fb21e9 100644 --- a/src/NzbDrone.Core/MediaFiles/AudioTag.cs +++ b/src/NzbDrone.Core/MediaFiles/AudioTag.cs @@ -324,9 +324,9 @@ namespace NzbDrone.Core.MediaFiles // patch up any null fields to work around TagLib exception for // WMA with null performers/albumartists - Performers = Performers ?? new string[0]; - AlbumArtists = AlbumArtists ?? new string[0]; - Genres = Genres ?? new string[0]; + Performers = Performers ?? Array.Empty(); + AlbumArtists = AlbumArtists ?? Array.Empty(); + Genres = Genres ?? Array.Empty(); TagLib.File file = null; try diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileService.cs b/src/NzbDrone.Core/MediaFiles/MediaFileService.cs index f7beb7c2d..ee5c44f4a 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileService.cs @@ -209,7 +209,7 @@ namespace NzbDrone.Core.MediaFiles foreach (var file in files) { - var newPath = message.DestinationPath + file.Path.Substring(message.SourcePath.Length); + var newPath = $"{message.DestinationPath}{file.Path.AsSpan(message.SourcePath.Length)}"; file.Path = newPath; } diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateFilenameInfo.cs b/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateFilenameInfo.cs index dec828cc9..f40b6ec6e 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateFilenameInfo.cs +++ b/src/NzbDrone.Core/MediaFiles/TrackImport/Aggregation/Aggregators/AggregateFilenameInfo.cs @@ -58,9 +58,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators public LocalAlbumRelease Aggregate(LocalAlbumRelease release, bool others) { var tracks = release.LocalTracks; - if (tracks.Count(x => x.FileTrackInfo.Title.IsNullOrWhiteSpace()) > 0 - || tracks.Count(x => x.FileTrackInfo.TrackNumbers.First() == 0) > 0 - || tracks.Count(x => x.FileTrackInfo.DiscNumber == 0) > 0) + if (tracks.Any(x => x.FileTrackInfo.Title.IsNullOrWhiteSpace()) + || tracks.Any(x => x.FileTrackInfo.TrackNumbers.First() == 0) + || tracks.Any(x => x.FileTrackInfo.DiscNumber == 0)) { _logger.Debug("Missing data in tags, trying filename augmentation"); foreach (var charSep in CharsAndSeps) @@ -171,7 +171,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators } var trackNums = track.FileTrackInfo.TrackNumbers; - if (keys.Contains("track") && (trackNums.Count() == 0 || trackNums.First() == 0)) + if (keys.Contains("track") && (trackNums.Length == 0 || trackNums.First() == 0)) { var tracknum = Convert.ToInt32(matches[track].Groups["track"].Value); if (tracknum > 100) diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Distance.cs b/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Distance.cs index b0888fa33..76e74fc6b 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Distance.cs +++ b/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Distance.cs @@ -39,7 +39,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification } public Dictionary> Penalties => _penalties; - public string Reasons => _penalties.Count(x => x.Value.Max() > 0.0) > 0 ? "[" + string.Join(", ", Penalties.Where(x => x.Value.Max() > 0.0).Select(x => x.Key.Replace('_', ' '))) + "]" : string.Empty; + public string Reasons => _penalties.Any(x => x.Value.Max() > 0.0) ? "[" + string.Join(", ", Penalties.Where(x => x.Value.Max() > 0.0).Select(x => x.Key.Replace('_', ' '))) + "]" : string.Empty; private double MaxDistance(Dictionary> penalties) { diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/TrackGroupingService.cs b/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/TrackGroupingService.cs index 85b17098a..6eabc393c 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/TrackGroupingService.cs +++ b/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/TrackGroupingService.cs @@ -19,10 +19,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification public class TrackGroupingService : ITrackGroupingService { + private const string MultiDiscPatternFormat = @"^(?.*%s[\W_]*)\d"; private static readonly Logger _logger = NzbDroneLogger.GetLogger(typeof(TrackGroupingService)); private static readonly List MultiDiscMarkers = new List { @"dis[ck]", @"cd" }; - private static readonly string MultiDiscPatternFormat = @"^(?.*%s[\W_]*)\d"; private static readonly List VariousArtistTitles = new List { "", "various artists", "various", "va", "unknown" }; public List GroupTracks(List localTracks) diff --git a/src/NzbDrone.Core/Notifications/Discord/Discord.cs b/src/NzbDrone.Core/Notifications/Discord/Discord.cs index 126e3240b..63cf96ccc 100644 --- a/src/NzbDrone.Core/Notifications/Discord/Discord.cs +++ b/src/NzbDrone.Core/Notifications/Discord/Discord.cs @@ -69,7 +69,7 @@ namespace NzbDrone.Core.Notifications.Discord case DiscordGrabFieldType.Overview: var overview = albums.First().Overview ?? ""; discordField.Name = "Overview"; - discordField.Value = overview.Length <= 300 ? overview : overview.Substring(0, 300) + "..."; + discordField.Value = overview.Length <= 300 ? overview : $"{overview.AsSpan(0, 300)}..."; break; case DiscordGrabFieldType.Rating: discordField.Name = "Rating"; @@ -162,7 +162,7 @@ namespace NzbDrone.Core.Notifications.Discord case DiscordImportFieldType.Overview: var overview = album.Overview ?? ""; discordField.Name = "Overview"; - discordField.Value = overview.Length <= 300 ? overview : 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/Notifications/Mailgun/MailgunSettings.cs b/src/NzbDrone.Core/Notifications/Mailgun/MailgunSettings.cs index b09824ac3..74a4c23f7 100644 --- a/src/NzbDrone.Core/Notifications/Mailgun/MailgunSettings.cs +++ b/src/NzbDrone.Core/Notifications/Mailgun/MailgunSettings.cs @@ -22,7 +22,7 @@ namespace NzbDrone.Core.Notifications.Mailgun public MailgunSettings() { - Recipients = new string[] { }; + Recipients = System.Array.Empty(); } [FieldDefinition(0, Label = "API Key", HelpText = "The API key generated from MailGun")] diff --git a/src/NzbDrone.Core/Notifications/PushBullet/PushBulletSettings.cs b/src/NzbDrone.Core/Notifications/PushBullet/PushBulletSettings.cs index 0203c7d95..bd3435cc8 100644 --- a/src/NzbDrone.Core/Notifications/PushBullet/PushBulletSettings.cs +++ b/src/NzbDrone.Core/Notifications/PushBullet/PushBulletSettings.cs @@ -20,8 +20,8 @@ namespace NzbDrone.Core.Notifications.PushBullet public PushBulletSettings() { - DeviceIds = new string[] { }; - ChannelTags = new string[] { }; + DeviceIds = System.Array.Empty(); + ChannelTags = System.Array.Empty(); } [FieldDefinition(0, Label = "Access Token", Privacy = PrivacyLevel.ApiKey, HelpLink = "https://www.pushbullet.com/#settings/account")] diff --git a/src/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs b/src/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs index 02ba85c28..21067d7d3 100644 --- a/src/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs +++ b/src/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Notifications.Pushover public PushoverSettings() { Priority = 0; - Devices = new string[] { }; + Devices = System.Array.Empty(); } // TODO: Get Pushover to change our app name (or create a new app) when we have a new logo diff --git a/src/NzbDrone.Core/Notifications/SendGrid/SendGridSettings.cs b/src/NzbDrone.Core/Notifications/SendGrid/SendGridSettings.cs index 25b78b9c4..a908265cc 100644 --- a/src/NzbDrone.Core/Notifications/SendGrid/SendGridSettings.cs +++ b/src/NzbDrone.Core/Notifications/SendGrid/SendGridSettings.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Notifications.SendGrid public SendGridSettings() { BaseUrl = "https://api.sendgrid.com/v3/"; - Recipients = new string[] { }; + Recipients = System.Array.Empty(); } public string BaseUrl { get; set; } diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index 757330a6f..792f593e7 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -102,7 +102,7 @@ namespace NzbDrone.Core.Organizer var pattern = namingConfig.StandardTrackFormat; - if (tracks.First().AlbumRelease.Value.Media.Count() > 1) + if (tracks.First().AlbumRelease.Value.Media.Count > 1) { pattern = namingConfig.MultiDiscTrackFormat; } diff --git a/src/NzbDrone.Core/Parser/Model/ParsedTrackInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedTrackInfo.cs index 2e454a6bf..f4df7e47f 100644 --- a/src/NzbDrone.Core/Parser/Model/ParsedTrackInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ParsedTrackInfo.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Parser.Model public ParsedTrackInfo() { - TrackNumbers = new int[0]; + TrackNumbers = Array.Empty(); } public override string ToString() diff --git a/src/NzbDrone.Core/Parser/SceneChecker.cs b/src/NzbDrone.Core/Parser/SceneChecker.cs index 10b092bd7..969adf901 100644 --- a/src/NzbDrone.Core/Parser/SceneChecker.cs +++ b/src/NzbDrone.Core/Parser/SceneChecker.cs @@ -6,12 +6,12 @@ namespace NzbDrone.Core.Parser // It's better not to use a title that might be scene than to use one that isn't scene public static bool IsSceneTitle(string title) { - if (!title.Contains(".")) + if (!title.Contains('.')) { return false; } - if (title.Contains(" ")) + if (title.Contains(' ')) { return false; } diff --git a/src/NzbDrone.Host/Startup.cs b/src/NzbDrone.Host/Startup.cs index d7fe4519e..ccd9dcbdb 100644 --- a/src/NzbDrone.Host/Startup.cs +++ b/src/NzbDrone.Host/Startup.cs @@ -127,7 +127,7 @@ namespace NzbDrone.Host c.AddSecurityRequirement(new OpenApiSecurityRequirement { - { apiKeyHeader, new string[] { } } + { apiKeyHeader, Array.Empty() } }); var apikeyQuery = new OpenApiSecurityScheme @@ -158,7 +158,7 @@ namespace NzbDrone.Host c.AddSecurityRequirement(new OpenApiSecurityRequirement { - { apikeyQuery, new string[] { } } + { apikeyQuery, Array.Empty() } }); }); diff --git a/src/NzbDrone.Mono.Test/EnvironmentInfo/VersionAdapters/ReleaseFileVersionAdapterFixture.cs b/src/NzbDrone.Mono.Test/EnvironmentInfo/VersionAdapters/ReleaseFileVersionAdapterFixture.cs index 9edb99fe3..5f8dbc913 100644 --- a/src/NzbDrone.Mono.Test/EnvironmentInfo/VersionAdapters/ReleaseFileVersionAdapterFixture.cs +++ b/src/NzbDrone.Mono.Test/EnvironmentInfo/VersionAdapters/ReleaseFileVersionAdapterFixture.cs @@ -48,7 +48,7 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters Subject.Read().Should().BeNull(); Mocker.GetMock() - .Setup(c => c.GetFiles(It.IsAny(), SearchOption.TopDirectoryOnly)).Returns(new string[0]); + .Setup(c => c.GetFiles(It.IsAny(), SearchOption.TopDirectoryOnly)).Returns(System.Array.Empty()); Subject.Read().Should().BeNull(); } diff --git a/src/NzbDrone.Mono/Disk/ProcMountProvider.cs b/src/NzbDrone.Mono/Disk/ProcMountProvider.cs index 76ed7758b..fd465b827 100644 --- a/src/NzbDrone.Mono/Disk/ProcMountProvider.cs +++ b/src/NzbDrone.Mono/Disk/ProcMountProvider.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Mono.Disk private static Dictionary _fileSystems; private readonly Logger _logger; - private bool _hasLoggedProcMountFailure = false; + private bool _hasLoggedProcMountFailure; public ProcMountProvider(Logger logger) { diff --git a/src/NzbDrone.Mono/Disk/SymbolicLinkResolver.cs b/src/NzbDrone.Mono/Disk/SymbolicLinkResolver.cs index a190fc1ce..791f19c0f 100644 --- a/src/NzbDrone.Mono/Disk/SymbolicLinkResolver.cs +++ b/src/NzbDrone.Mono/Disk/SymbolicLinkResolver.cs @@ -2,6 +2,7 @@ using System; using Mono.Unix; using Mono.Unix.Native; using NLog; +using NzbDrone.Common.Extensions; namespace NzbDrone.Mono.Disk { @@ -55,7 +56,7 @@ namespace NzbDrone.Mono.Disk var target = 0; for (var i = 0; i < dirs.Length; ++i) { - if (dirs[i] == "." || dirs[i] == string.Empty) + if (dirs[i] == "." || dirs[i].IsNullOrWhiteSpace()) { continue; } 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/NzbDrone.Test.Common/TestBase.cs b/src/NzbDrone.Test.Common/TestBase.cs index 8a8d54828..6d2f2a908 100644 --- a/src/NzbDrone.Test.Common/TestBase.cs +++ b/src/NzbDrone.Test.Common/TestBase.cs @@ -53,7 +53,7 @@ namespace NzbDrone.Test.Common { _mocker = new AutoMoqer(); _mocker.SetConstant(new CacheManager()); - _mocker.SetConstant(new StartupContext(new string[0])); + _mocker.SetConstant(new StartupContext(Array.Empty())); _mocker.SetConstant(TestLogger); } diff --git a/src/NzbDrone.Update/UpdateApp.cs b/src/NzbDrone.Update/UpdateApp.cs index 9fd4880fc..b32a9a269 100644 --- a/src/NzbDrone.Update/UpdateApp.cs +++ b/src/NzbDrone.Update/UpdateApp.cs @@ -74,7 +74,7 @@ namespace NzbDrone.Update if (OsInfo.IsNotWindows) { - switch (args.Count()) + switch (args.Length) { case 1: return startupContext;