Enable all analyzers and enforce code style on build

Fixes #3406
Fixes #3407
Fixes #3408
Fixes #3409
Fixes #3410
Fixes #3411
Fixes #3412
Fixes #3413
Fixes #3414
Fixes #3415
Fixes #3416
Fixes #3417
Fixes #3418
Fixes #3419
Fixes #3420
Fixes #3421
Fixes #3422
Fixes #3423
pull/3522/head
Qstick 1 year ago
parent 7ac0e43c29
commit 1bc0b5f950

@ -32,6 +32,10 @@ csharp_indent_case_contents_when_block = true
csharp_indent_switch_labels = true csharp_indent_switch_labels = true
csharp_indent_labels = flush_left 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.capitalization = camel_case
dotnet_naming_style.instance_field_style.required_prefix = _ dotnet_naming_style.instance_field_style.required_prefix = _
@ -64,6 +68,7 @@ dotnet_diagnostic.SA1406.severity = suggestion
dotnet_diagnostic.SA1410.severity = suggestion dotnet_diagnostic.SA1410.severity = suggestion
dotnet_diagnostic.SA1411.severity = suggestion dotnet_diagnostic.SA1411.severity = suggestion
dotnet_diagnostic.SA1413.severity = none dotnet_diagnostic.SA1413.severity = none
dotnet_diagnostic.SA1512.severity = none
dotnet_diagnostic.SA1516.severity = none dotnet_diagnostic.SA1516.severity = none
dotnet_diagnostic.SA1600.severity = none dotnet_diagnostic.SA1600.severity = none
dotnet_diagnostic.SA1601.severity = none dotnet_diagnostic.SA1601.severity = none
@ -162,6 +167,7 @@ dotnet_diagnostic.CA1309.severity = suggestion
dotnet_diagnostic.CA1310.severity = suggestion dotnet_diagnostic.CA1310.severity = suggestion
dotnet_diagnostic.CA1401.severity = suggestion dotnet_diagnostic.CA1401.severity = suggestion
dotnet_diagnostic.CA1416.severity = suggestion dotnet_diagnostic.CA1416.severity = suggestion
dotnet_diagnostic.CA1419.severity = suggestion
dotnet_diagnostic.CA1507.severity = suggestion dotnet_diagnostic.CA1507.severity = suggestion
dotnet_diagnostic.CA1508.severity = suggestion dotnet_diagnostic.CA1508.severity = suggestion
dotnet_diagnostic.CA1707.severity = suggestion dotnet_diagnostic.CA1707.severity = suggestion
@ -177,9 +183,6 @@ dotnet_diagnostic.CA1720.severity = suggestion
dotnet_diagnostic.CA1721.severity = suggestion dotnet_diagnostic.CA1721.severity = suggestion
dotnet_diagnostic.CA1724.severity = suggestion dotnet_diagnostic.CA1724.severity = suggestion
dotnet_diagnostic.CA1725.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.CA1806.severity = suggestion
dotnet_diagnostic.CA1810.severity = suggestion dotnet_diagnostic.CA1810.severity = suggestion
dotnet_diagnostic.CA1812.severity = suggestion dotnet_diagnostic.CA1812.severity = suggestion
@ -188,24 +191,14 @@ dotnet_diagnostic.CA1814.severity = suggestion
dotnet_diagnostic.CA1815.severity = suggestion dotnet_diagnostic.CA1815.severity = suggestion
dotnet_diagnostic.CA1816.severity = suggestion dotnet_diagnostic.CA1816.severity = suggestion
dotnet_diagnostic.CA1819.severity = suggestion dotnet_diagnostic.CA1819.severity = suggestion
dotnet_diagnostic.CA1820.severity = suggestion
dotnet_diagnostic.CA1821.severity = suggestion
dotnet_diagnostic.CA1822.severity = suggestion dotnet_diagnostic.CA1822.severity = suggestion
dotnet_diagnostic.CA1823.severity = suggestion dotnet_diagnostic.CA1823.severity = suggestion
dotnet_diagnostic.CA1824.severity = suggestion dotnet_diagnostic.CA1824.severity = suggestion
dotnet_diagnostic.CA1825.severity = suggestion dotnet_diagnostic.CA1848.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.CA2000.severity = suggestion dotnet_diagnostic.CA2000.severity = suggestion
dotnet_diagnostic.CA2002.severity = suggestion dotnet_diagnostic.CA2002.severity = suggestion
dotnet_diagnostic.CA2007.severity = suggestion dotnet_diagnostic.CA2007.severity = suggestion
dotnet_diagnostic.CA2008.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.CA2012.severity = suggestion
dotnet_diagnostic.CA2013.severity = suggestion dotnet_diagnostic.CA2013.severity = suggestion
dotnet_diagnostic.CA2100.severity = suggestion dotnet_diagnostic.CA2100.severity = suggestion
@ -236,6 +229,9 @@ dotnet_diagnostic.CA2243.severity = suggestion
dotnet_diagnostic.CA2244.severity = suggestion dotnet_diagnostic.CA2244.severity = suggestion
dotnet_diagnostic.CA2245.severity = suggestion dotnet_diagnostic.CA2245.severity = suggestion
dotnet_diagnostic.CA2246.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.CA3061.severity = suggestion
dotnet_diagnostic.CA3075.severity = suggestion dotnet_diagnostic.CA3075.severity = suggestion
dotnet_diagnostic.CA3076.severity = suggestion dotnet_diagnostic.CA3076.severity = suggestion

@ -0,0 +1,3 @@
is_global = true
dotnet_diagnostic.CA1014.severity = none

@ -1,8 +1,10 @@
<Project> <Project>
<!-- Common to all Lidarr Projects --> <!-- Common to all Lidarr Projects -->
<PropertyGroup> <PropertyGroup>
<AnalysisLevel>6.0-all</AnalysisLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles> <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>

@ -45,7 +45,7 @@ namespace Lidarr.Api.V1.FileSystem
{ {
if (!_diskProvider.FolderExists(path)) if (!_diskProvider.FolderExists(path))
{ {
return new string[0]; return global::System.Array.Empty<string>();
} }
return _diskScanService.GetAudioFiles(path).Select(f => new return _diskScanService.GetAudioFiles(path).Select(f => new

@ -93,7 +93,7 @@ namespace Lidarr.Api.V1.System.Backup
throw new BadRequestException("file must be provided"); throw new BadRequestException("file must be provided");
} }
var file = files.First(); var file = files[0];
var extension = Path.GetExtension(file.FileName); var extension = Path.GetExtension(file.FileName);
if (!ValidExtensions.Contains(extension)) if (!ValidExtensions.Contains(extension))

@ -35,7 +35,7 @@ namespace Lidarr.Http.Frontend.Mappers
return !resourceUrl.StartsWith("/content") && return !resourceUrl.StartsWith("/content") &&
!resourceUrl.StartsWith("/mediacover") && !resourceUrl.StartsWith("/mediacover") &&
!resourceUrl.Contains(".") && !resourceUrl.Contains('.') &&
!resourceUrl.StartsWith("/login"); !resourceUrl.StartsWith("/login");
} }
} }

@ -9,9 +9,9 @@ namespace Lidarr.Http.Middleware
{ {
public class StartingUpMiddleware public class StartingUpMiddleware
{ {
private const string MESSAGE = "Lidarr is starting up, please try again later";
private readonly RequestDelegate _next; private readonly RequestDelegate _next;
private readonly IRuntimeInfo _runtimeInfo; private readonly IRuntimeInfo _runtimeInfo;
private static readonly string MESSAGE = "Lidarr is starting up, please try again later";
public StartingUpMiddleware(RequestDelegate next, IRuntimeInfo runtimeInfo) public StartingUpMiddleware(RequestDelegate next, IRuntimeInfo runtimeInfo)
{ {
@ -29,7 +29,7 @@ namespace Lidarr.Http.Middleware
context.Response.StatusCode = 503; context.Response.StatusCode = 503;
context.Response.ContentType = isJson ? "application/json" : "text/plain"; context.Response.ContentType = isJson ? "application/json" : "text/plain";
await context.Response.Body.WriteAsync(bytes, 0, bytes.Length); await context.Response.Body.WriteAsync(bytes);
return; return;
} }

@ -11,7 +11,7 @@ namespace NzbDrone.Common.Test.EnvironmentTests
[Test] [Test]
public void empty_array_should_return_empty_flags() public void empty_array_should_return_empty_flags()
{ {
var args = new StartupContext(new string[0]); var args = new StartupContext(System.Array.Empty<string>());
args.Flags.Should().BeEmpty(); args.Flags.Should().BeEmpty();
} }

@ -460,7 +460,7 @@ namespace NzbDrone.Common.Test.Http
var oldRequest = new HttpRequest($"https://{_httpBinHost2}/get"); var oldRequest = new HttpRequest($"https://{_httpBinHost2}/get");
oldRequest.Cookies["my"] = "cookie"; oldRequest.Cookies["my"] = "cookie";
var oldClient = new HttpClient(new IHttpRequestInterceptor[0], Mocker.Resolve<ICacheManager>(), Mocker.Resolve<IRateLimitService>(), Mocker.Resolve<IHttpDispatcher>(), Mocker.Resolve<Logger>()); var oldClient = new HttpClient(Array.Empty<IHttpRequestInterceptor>(), Mocker.Resolve<ICacheManager>(), Mocker.Resolve<IRateLimitService>(), Mocker.Resolve<IHttpDispatcher>(), Mocker.Resolve<Logger>());
oldClient.Should().NotBeSameAs(Subject); oldClient.Should().NotBeSameAs(Subject);

@ -91,7 +91,7 @@ namespace NzbDrone.Common.Extensions
int best_loc = -1; int best_loc = -1;
// Empty initialization added to appease C# compiler. // Empty initialization added to appease C# compiler.
var last_rd = new BigInteger[0]; var last_rd = Array.Empty<BigInteger>();
for (int d = 0; d < pattern.Length; d++) for (int d = 0; d < pattern.Length; d++)
{ {
// Scan for the best match; each iteration allows for one more error. // Scan for the best match; each iteration allows for one more error.

@ -126,7 +126,7 @@ namespace NzbDrone.Common.Extensions
public static string WrapInQuotes(this string text) public static string WrapInQuotes(this string text)
{ {
if (!text.Contains(" ")) if (!text.Contains(' '))
{ {
return text; return text;
} }
@ -170,7 +170,7 @@ namespace NzbDrone.Common.Extensions
{ {
return 0; return 0;
} }
else if (a.Contains(" ") && b.Contains(" ")) else if (a.Contains(' ') && b.Contains(' '))
{ {
var partsA = a.Split(' '); var partsA = a.Split(' ');
var partsB = b.Split(' '); var partsB = b.Split(' ');
@ -256,7 +256,7 @@ namespace NzbDrone.Common.Extensions
public static string ToUrlHost(this string input) public static string ToUrlHost(this string input)
{ {
return input.Contains(":") ? $"[{input}]" : input; return input.Contains(':') ? $"[{input}]" : input;
} }
} }
} }

@ -60,7 +60,7 @@ namespace NzbDrone.Common.Http
public string[] GetCookieHeaders() public string[] GetCookieHeaders()
{ {
return Headers.GetValues("Set-Cookie") ?? new string[0]; return Headers.GetValues("Set-Cookie") ?? Array.Empty<string>();
} }
public Dictionary<string, string> GetCookies() public Dictionary<string, string> GetCookies()

@ -27,7 +27,7 @@ namespace NzbDrone.Common.Http
if (scheme.IsNotNullOrWhiteSpace()) if (scheme.IsNotNullOrWhiteSpace())
{ {
builder.Append(scheme); builder.Append(scheme);
builder.Append(":"); builder.Append(':');
} }
if (host.IsNotNullOrWhiteSpace()) if (host.IsNotNullOrWhiteSpace())
@ -36,7 +36,7 @@ namespace NzbDrone.Common.Http
builder.Append(host); builder.Append(host);
if (port.HasValue) if (port.HasValue)
{ {
builder.Append(":"); builder.Append(':');
builder.Append(port); builder.Append(port);
} }
} }
@ -170,7 +170,7 @@ namespace NzbDrone.Common.Http
if (baseSlashIndex >= 0) if (baseSlashIndex >= 0)
{ {
return basePath.Substring(0, baseSlashIndex) + "/" + relativePath; return $"{basePath.AsSpan(0, baseSlashIndex)}/{relativePath}";
} }
return relativePath; return relativePath;
@ -202,11 +202,11 @@ namespace NzbDrone.Common.Http
{ {
if (builder.Length != 0) if (builder.Length != 0)
{ {
builder.Append("&"); builder.Append('&');
} }
builder.Append(Uri.EscapeDataString(pair.Key)); builder.Append(Uri.EscapeDataString(pair.Key));
builder.Append("="); builder.Append('=');
builder.Append(Uri.EscapeDataString(pair.Value)); builder.Append(Uri.EscapeDataString(pair.Value));
} }

@ -41,7 +41,7 @@ namespace NzbDrone.Common.Http.Proxy
return hostlist; return hostlist;
} }
return new string[] { }; return System.Array.Empty<string>();
} }
} }

@ -488,7 +488,7 @@ namespace NzbDrone.Common.OAuth
private static bool IsNullOrBlank(string value) 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()));
} }
} }
} }

@ -405,7 +405,7 @@ namespace NzbDrone.Common.OAuth
private static bool IsNullOrBlank(string value) 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()));
} }
} }
} }

@ -16,7 +16,7 @@ namespace NzbDrone.Common.OAuth
{ {
var parameters = this.Where(p => p.Name.Equals(name)); var parameters = this.Where(p => p.Name.Equals(name));
if (parameters.Count() == 0) if (!parameters.Any())
{ {
return null; return null;
} }

@ -65,7 +65,7 @@ namespace NzbDrone.Common
var args = $"create {serviceName} " + var args = $"create {serviceName} " +
$"DisplayName= \"{serviceName}\" " + $"DisplayName= \"{serviceName}\" " +
$"binpath= \"{Process.GetCurrentProcess().MainModule.FileName}\" " + $"binpath= \"{Environment.ProcessPath}\" " +
"start= auto " + "start= auto " +
"depend= EventLog/Tcpip/http " + "depend= EventLog/Tcpip/http " +
"obj= \"NT AUTHORITY\\LocalService\""; "obj= \"NT AUTHORITY\\LocalService\"";

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
@ -19,7 +19,7 @@ namespace NzbDrone.Common.TPL
private readonly int _maxDegreeOfParallelism; private readonly int _maxDegreeOfParallelism;
/// <summary>Whether the scheduler is currently processing work items.</summary> /// <summary>Whether the scheduler is currently processing work items.</summary>
private int _delegatesQueuedOrRunning = 0; // protected by lock(_tasks) private int _delegatesQueuedOrRunning; // protected by lock(_tasks)
/// <summary> /// <summary>
/// Initializes an instance of the LimitedConcurrencyLevelTaskScheduler class with the /// Initializes an instance of the LimitedConcurrencyLevelTaskScheduler class with the

@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
var albums = db.Query<Album>("SELECT * FROM \"Albums\""); var albums = db.Query<Album>("SELECT * FROM \"Albums\"");
// we only put in one release per album // 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 // each album should be linked to exactly one release
releases.Select(x => x.AlbumId).SequenceEqual(albums.Select(x => x.Id)).Should().Be(true); releases.Select(x => x.AlbumId).SequenceEqual(albums.Select(x => x.Id)).Should().Be(true);

@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
[TestFixture] [TestFixture]
public class add_mediafilerepository_mtimeFixture : MigrationTest<add_mediafilerepository_mtime> public class add_mediafilerepository_mtimeFixture : MigrationTest<add_mediafilerepository_mtime>
{ {
private string _artistPath = null; private string _artistPath;
private void GivenArtist(add_mediafilerepository_mtime c, int id, string name) private void GivenArtist(add_mediafilerepository_mtime c, int id, string name)
{ {

@ -11,7 +11,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
[TestFixture] [TestFixture]
public class add_artistmetadataid_constraintFixture : MigrationTest<add_artistmetadataid_constraint> public class add_artistmetadataid_constraintFixture : MigrationTest<add_artistmetadataid_constraint>
{ {
private string _artistPath = null; private string _artistPath;
private void GivenArtistMetadata(add_artistmetadataid_constraint c, int id, string name) private void GivenArtistMetadata(add_artistmetadataid_constraint c, int id, string name)
{ {

@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>())) .Setup(s => s.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0])); .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), Array.Empty<byte>()));
} }
protected void GivenFailedDownload() protected void GivenFailedDownload()

@ -34,7 +34,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>())) .Setup(s => s.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0])); .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), Array.Empty<byte>()));
Mocker.GetMock<IRemotePathMappingService>() Mocker.GetMock<IRemotePathMappingService>()
.Setup(v => v.RemapRemoteToLocal(It.IsAny<string>(), It.IsAny<OsPath>())) .Setup(v => v.RemapRemoteToLocal(It.IsAny<string>(), It.IsAny<OsPath>()))

@ -278,7 +278,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>())) .Setup(s => s.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0])); .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), Array.Empty<byte>()));
_downloadStationConfigItems = new Dictionary<string, object> _downloadStationConfigItems = new Dictionary<string, object>
{ {

@ -170,7 +170,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>())) .Setup(s => s.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0])); .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), Array.Empty<byte>()));
_downloadStationConfigItems = new Dictionary<string, object> _downloadStationConfigItems = new Dictionary<string, object>
{ {

@ -86,7 +86,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>())) .Setup(s => s.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0])); .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), Array.Empty<byte>()));
} }
protected void GivenFailedDownload() protected void GivenFailedDownload()

@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>())) .Setup(s => s.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0])); .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), Array.Empty<byte>()));
Mocker.GetMock<IQBittorrentProxy>() Mocker.GetMock<IQBittorrentProxy>()
.Setup(s => s.GetConfig(It.IsAny<QBittorrentSettings>())) .Setup(s => s.GetConfig(It.IsAny<QBittorrentSettings>()))
@ -56,7 +56,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>())) .Setup(s => s.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, httpHeader, new byte[0], System.Net.HttpStatusCode.SeeOther)); .Returns<HttpRequest>(r => new HttpResponse(r, httpHeader, Array.Empty<byte>(), System.Net.HttpStatusCode.SeeOther));
} }
protected void GivenRedirectToTorrent() protected void GivenRedirectToTorrent()
@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.Is<HttpRequest>(h => h.Url.FullUri == _downloadUrl))) .Setup(s => s.Get(It.Is<HttpRequest>(h => h.Url.FullUri == _downloadUrl)))
.Returns<HttpRequest>(r => new HttpResponse(r, httpHeader, new byte[0], System.Net.HttpStatusCode.Found)); .Returns<HttpRequest>(r => new HttpResponse(r, httpHeader, Array.Empty<byte>(), System.Net.HttpStatusCode.Found));
} }
protected void GivenFailedDownload() protected void GivenFailedDownload()
@ -522,7 +522,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
Mocker.GetMock<IQBittorrentProxy>() Mocker.GetMock<IQBittorrentProxy>()
.Setup(v => v.MoveTorrentToTopInQueue(It.IsAny<string>(), It.IsAny<QBittorrentSettings>())) .Setup(v => v.MoveTorrentToTopInQueue(It.IsAny<string>(), It.IsAny<QBittorrentSettings>()))
.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<byte>(), System.Net.HttpStatusCode.Forbidden)));
var remoteAlbum = CreateRemoteAlbum(); var remoteAlbum = CreateRemoteAlbum();

@ -544,7 +544,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
public void should_test_failed_if_tv_sorting_empty() public void should_test_failed_if_tv_sorting_empty()
{ {
_config.Misc.enable_tv_sorting = true; _config.Misc.enable_tv_sorting = true;
_config.Misc.tv_categories = new string[0]; _config.Misc.tv_categories = Array.Empty<string>();
var result = new NzbDroneValidationResult(Subject.Test()); var result = new NzbDroneValidationResult(Subject.Test());

@ -99,7 +99,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>())) .Setup(s => s.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0])); .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), Array.Empty<byte>()));
_transmissionConfigItems = new Dictionary<string, object>(); _transmissionConfigItems = new Dictionary<string, object>();

@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>())) .Setup(s => s.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0])); .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), Array.Empty<byte>()));
} }
protected void GivenRedirectToMagnet() protected void GivenRedirectToMagnet()
@ -101,7 +101,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.IsAny<HttpRequest>())) .Setup(s => s.Get(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>(r => new HttpResponse(r, httpHeader, new byte[0], System.Net.HttpStatusCode.SeeOther)); .Returns<HttpRequest>(r => new HttpResponse(r, httpHeader, Array.Empty<byte>(), System.Net.HttpStatusCode.SeeOther));
} }
protected void GivenRedirectToTorrent() protected void GivenRedirectToTorrent()
@ -111,7 +111,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(s => s.Get(It.Is<HttpRequest>(h => h.Url.ToString() == _downloadUrl))) .Setup(s => s.Get(It.Is<HttpRequest>(h => h.Url.ToString() == _downloadUrl)))
.Returns<HttpRequest>(r => new HttpResponse(r, httpHeader, new byte[0], System.Net.HttpStatusCode.Found)); .Returns<HttpRequest>(r => new HttpResponse(r, httpHeader, Array.Empty<byte>(), System.Net.HttpStatusCode.Found));
} }
protected void GivenFailedDownload() protected void GivenFailedDownload()

@ -130,7 +130,7 @@ namespace NzbDrone.Core.Test.Download
public void Download_report_should_trigger_indexer_backoff_on_http429_with_long_time() public void Download_report_should_trigger_indexer_backoff_on_http429_with_long_time()
{ {
var request = new HttpRequest("http://my.indexer.com"); 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<byte>(), (HttpStatusCode)429);
response.Headers["Retry-After"] = "300"; response.Headers["Retry-After"] = "300";
var mock = WithUsenetClient(); 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() public void Download_report_should_trigger_indexer_backoff_on_http429_based_on_date()
{ {
var request = new HttpRequest("http://my.indexer.com"); 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<byte>(), (HttpStatusCode)429);
response.Headers["Retry-After"] = DateTime.UtcNow.AddSeconds(300).ToString("r"); response.Headers["Retry-After"] = DateTime.UtcNow.AddSeconds(300).ToString("r");
var mock = WithUsenetClient(); var mock = WithUsenetClient();

@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.Framework
Mocker.SetConstant<ICreateManagedWebProxy>(new ManagedWebProxyFactory(Mocker.Resolve<CacheManager>())); Mocker.SetConstant<ICreateManagedWebProxy>(new ManagedWebProxyFactory(Mocker.Resolve<CacheManager>()));
Mocker.SetConstant<ICertificateValidationService>(new X509CertificateValidationService(Mocker.Resolve<ConfigService>(), TestLogger)); Mocker.SetConstant<ICertificateValidationService>(new X509CertificateValidationService(Mocker.Resolve<ConfigService>(), TestLogger));
Mocker.SetConstant<IHttpDispatcher>(new ManagedHttpDispatcher(Mocker.Resolve<IHttpProxySettingsProvider>(), Mocker.Resolve<ICreateManagedWebProxy>(), Mocker.Resolve<ICertificateValidationService>(), Mocker.Resolve<UserAgentBuilder>(), Mocker.Resolve<CacheManager>(), TestLogger)); Mocker.SetConstant<IHttpDispatcher>(new ManagedHttpDispatcher(Mocker.Resolve<IHttpProxySettingsProvider>(), Mocker.Resolve<ICreateManagedWebProxy>(), Mocker.Resolve<ICertificateValidationService>(), Mocker.Resolve<UserAgentBuilder>(), Mocker.Resolve<CacheManager>(), TestLogger));
Mocker.SetConstant<IHttpClient>(new HttpClient(new IHttpRequestInterceptor[0], Mocker.Resolve<CacheManager>(), Mocker.Resolve<RateLimitService>(), Mocker.Resolve<IHttpDispatcher>(), TestLogger)); Mocker.SetConstant<IHttpClient>(new HttpClient(Array.Empty<IHttpRequestInterceptor>(), Mocker.Resolve<CacheManager>(), Mocker.Resolve<RateLimitService>(), Mocker.Resolve<IHttpDispatcher>(), TestLogger));
Mocker.SetConstant<ILidarrCloudRequestBuilder>(new LidarrCloudRequestBuilder()); Mocker.SetConstant<ILidarrCloudRequestBuilder>(new LidarrCloudRequestBuilder());
Mocker.SetConstant<IMetadataRequestBuilder>(Mocker.Resolve<MetadataRequestBuilder>()); Mocker.SetConstant<IMetadataRequestBuilder>(Mocker.Resolve<MetadataRequestBuilder>());
} }

@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
{ {
Mocker.GetMock<IProvideDownloadClient>() Mocker.GetMock<IProvideDownloadClient>()
.Setup(s => s.GetDownloadClients(It.IsAny<bool>())) .Setup(s => s.GetDownloadClients(It.IsAny<bool>()))
.Returns(new IDownloadClient[0]); .Returns(Array.Empty<IDownloadClient>());
Subject.Check().ShouldBeWarning(); Subject.Check().ShouldBeWarning();
} }

@ -12,9 +12,6 @@ namespace NzbDrone.Core.Test.ImportListTests
[TestFixture] [TestFixture]
public class SpotifyFollowedArtistsFixture : CoreTest<SpotifyFollowedArtists> public class SpotifyFollowedArtistsFixture : CoreTest<SpotifyFollowedArtists>
{ {
// placeholder, we don't use real API
private readonly SpotifyWebAPI _api = null;
[Test] [Test]
public void should_not_throw_if_followed_is_null() public void should_not_throw_if_followed_is_null()
{ {
@ -23,7 +20,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<SpotifyWebAPI>())) It.IsAny<SpotifyWebAPI>()))
.Returns(default(FollowedArtists)); .Returns(default(FollowedArtists));
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().BeEmpty(); result.Should().BeEmpty();
} }
@ -41,7 +38,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<SpotifyWebAPI>())) It.IsAny<SpotifyWebAPI>()))
.Returns(followed); .Returns(followed);
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().BeEmpty(); result.Should().BeEmpty();
} }
@ -62,10 +59,10 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<SpotifyWebAPI>())) It.IsAny<SpotifyWebAPI>()))
.Returns(followed); .Returns(followed);
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().BeEmpty(); result.Should().BeEmpty();
Subject.Fetch(_api); Subject.Fetch(null);
} }
[Test] [Test]
@ -87,10 +84,10 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<SpotifyWebAPI>())) It.IsAny<SpotifyWebAPI>()))
.Returns(followed); .Returns(followed);
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().BeEmpty(); result.Should().BeEmpty();
Subject.Fetch(_api); Subject.Fetch(null);
} }
[Test] [Test]
@ -115,7 +112,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<SpotifyWebAPI>())) It.IsAny<SpotifyWebAPI>()))
.Returns(followed); .Returns(followed);
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().HaveCount(1); result.Should().HaveCount(1);
} }
@ -149,7 +146,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<FollowedArtists>())) It.IsAny<FollowedArtists>()))
.Returns(default(FollowedArtists)); .Returns(default(FollowedArtists));
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().HaveCount(1); result.Should().HaveCount(1);
@ -183,7 +180,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<SpotifyWebAPI>())) It.IsAny<SpotifyWebAPI>()))
.Returns(followed); .Returns(followed);
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().BeEmpty(); result.Should().BeEmpty();
} }

@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.ImportListTests
{ {
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(x => x.Get<ArtistResource>(It.IsAny<HttpRequest>())) .Setup(x => x.Get<ArtistResource>(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>((x) => new HttpResponse<ArtistResource>(new HttpResponse(x, new HttpHeader(), new byte[0], HttpStatusCode.NotFound))); .Returns<HttpRequest>((x) => new HttpResponse<ArtistResource>(new HttpResponse(x, new HttpHeader(), Array.Empty<byte>(), HttpStatusCode.NotFound)));
var data = new SpotifyImportListItemInfo var data = new SpotifyImportListItemInfo
{ {
@ -120,7 +120,7 @@ namespace NzbDrone.Core.Test.ImportListTests
{ {
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(x => x.Get<AlbumResource>(It.IsAny<HttpRequest>())) .Setup(x => x.Get<AlbumResource>(It.IsAny<HttpRequest>()))
.Returns<HttpRequest>((x) => new HttpResponse<AlbumResource>(new HttpResponse(x, new HttpHeader(), new byte[0], HttpStatusCode.NotFound))); .Returns<HttpRequest>((x) => new HttpResponse<AlbumResource>(new HttpResponse(x, new HttpHeader(), Array.Empty<byte>(), HttpStatusCode.NotFound)));
var data = new SpotifyImportListItemInfo var data = new SpotifyImportListItemInfo
{ {

@ -12,9 +12,6 @@ namespace NzbDrone.Core.Test.ImportListTests
[TestFixture] [TestFixture]
public class SpotifyPlaylistFixture : CoreTest<SpotifyPlaylist> public class SpotifyPlaylistFixture : CoreTest<SpotifyPlaylist>
{ {
// placeholder, we don't use real API
private readonly SpotifyWebAPI _api = null;
[Test] [Test]
public void should_not_throw_if_playlist_tracks_is_null() public void should_not_throw_if_playlist_tracks_is_null()
{ {
@ -25,7 +22,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<string>())) It.IsAny<string>()))
.Returns(default(Paging<PlaylistTrack>)); .Returns(default(Paging<PlaylistTrack>));
var result = Subject.Fetch(_api, "playlistid"); var result = Subject.Fetch(null, "playlistid");
result.Should().BeEmpty(); result.Should().BeEmpty();
} }
@ -45,7 +42,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<string>())) It.IsAny<string>()))
.Returns(playlistTracks); .Returns(playlistTracks);
var result = Subject.Fetch(_api, "playlistid"); var result = Subject.Fetch(null, "playlistid");
result.Should().BeEmpty(); result.Should().BeEmpty();
} }
@ -68,7 +65,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<string>())) It.IsAny<string>()))
.Returns(playlistTracks); .Returns(playlistTracks);
var result = Subject.Fetch(_api, "playlistid"); var result = Subject.Fetch(null, "playlistid");
result.Should().BeEmpty(); result.Should().BeEmpty();
} }
@ -114,7 +111,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<string>())) It.IsAny<string>()))
.Returns(playlistTracks); .Returns(playlistTracks);
var result = Subject.Fetch(_api, "playlistid"); var result = Subject.Fetch(null, "playlistid");
result.Should().HaveCount(1); result.Should().HaveCount(1);
result[0].Artist.Should().Be("AlbumArtist"); result[0].Artist.Should().Be("AlbumArtist");
@ -161,7 +158,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<string>())) It.IsAny<string>()))
.Returns(playlistTracks); .Returns(playlistTracks);
var result = Subject.Fetch(_api, "playlistid"); var result = Subject.Fetch(null, "playlistid");
result.Should().HaveCount(1); result.Should().HaveCount(1);
result[0].Artist.Should().Be("TrackArtist"); result[0].Artist.Should().Be("TrackArtist");
@ -210,7 +207,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<string>())) It.IsAny<string>()))
.Returns(playlistTracks); .Returns(playlistTracks);
var result = Subject.Fetch(_api, "playlistid"); var result = Subject.Fetch(null, "playlistid");
result.Should().BeEmpty(); result.Should().BeEmpty();
} }
@ -263,7 +260,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<Paging<PlaylistTrack>>())) It.IsAny<Paging<PlaylistTrack>>()))
.Returns(default(Paging<PlaylistTrack>)); .Returns(default(Paging<PlaylistTrack>));
var result = Subject.Fetch(_api, "playlistid"); var result = Subject.Fetch(null, "playlistid");
result.Should().HaveCount(1); result.Should().HaveCount(1);

@ -12,9 +12,6 @@ namespace NzbDrone.Core.Test.ImportListTests
[TestFixture] [TestFixture]
public class SpotifySavedAlbumsFixture : CoreTest<SpotifySavedAlbums> public class SpotifySavedAlbumsFixture : CoreTest<SpotifySavedAlbums>
{ {
// placeholder, we don't use real API
private readonly SpotifyWebAPI _api = null;
[Test] [Test]
public void should_not_throw_if_saved_albums_is_null() public void should_not_throw_if_saved_albums_is_null()
{ {
@ -23,7 +20,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<SpotifyWebAPI>())) It.IsAny<SpotifyWebAPI>()))
.Returns(default(Paging<SavedAlbum>)); .Returns(default(Paging<SavedAlbum>));
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().BeEmpty(); result.Should().BeEmpty();
} }
@ -41,7 +38,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<SpotifyWebAPI>())) It.IsAny<SpotifyWebAPI>()))
.Returns(savedAlbums); .Returns(savedAlbums);
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().BeEmpty(); result.Should().BeEmpty();
} }
@ -62,7 +59,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<SpotifyWebAPI>())) It.IsAny<SpotifyWebAPI>()))
.Returns(savedAlbums); .Returns(savedAlbums);
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().BeEmpty(); result.Should().BeEmpty();
} }
@ -96,7 +93,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<SpotifyWebAPI>())) It.IsAny<SpotifyWebAPI>()))
.Returns(savedAlbums); .Returns(savedAlbums);
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().HaveCount(1); result.Should().HaveCount(1);
} }
@ -137,7 +134,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<Paging<SavedAlbum>>())) It.IsAny<Paging<SavedAlbum>>()))
.Returns(default(Paging<SavedAlbum>)); .Returns(default(Paging<SavedAlbum>));
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().HaveCount(1); result.Should().HaveCount(1);
@ -179,7 +176,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<SpotifyWebAPI>())) It.IsAny<SpotifyWebAPI>()))
.Returns(savedAlbums); .Returns(savedAlbums);
var result = Subject.Fetch(_api); var result = Subject.Fetch(null);
result.Should().BeEmpty(); result.Should().BeEmpty();
} }

@ -86,7 +86,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
public void should_record_indexer_failure_if_caps_throw() public void should_record_indexer_failure_if_caps_throw()
{ {
var request = new HttpRequest("http://my.indexer.com"); 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<byte>(), (HttpStatusCode)429);
response.Headers["Retry-After"] = "300"; response.Headers["Retry-After"] = "300";
Mocker.GetMock<INewznabCapabilitiesProvider>() Mocker.GetMock<INewznabCapabilitiesProvider>()

@ -240,9 +240,9 @@ namespace NzbDrone.Core.Test.MediaFiles.AudioTagServiceFixture
var tag = Subject.ReadAudioTag(path); var tag = Subject.ReadAudioTag(path);
var expected = new AudioTag() var expected = new AudioTag()
{ {
Performers = new string[0], Performers = Array.Empty<string>(),
AlbumArtists = new string[0], AlbumArtists = Array.Empty<string>(),
Genres = new string[0] Genres = Array.Empty<string>()
}; };
VerifySame(tag, expected, skipProperties); VerifySame(tag, expected, skipProperties);

@ -96,7 +96,7 @@ namespace NzbDrone.Core.Test.MediaFiles
private void WasImportedResponse() private void WasImportedResponse()
{ {
Mocker.GetMock<IDiskScanService>().Setup(c => c.GetAudioFiles(It.IsAny<string>(), It.IsAny<bool>())) Mocker.GetMock<IDiskScanService>().Setup(c => c.GetAudioFiles(It.IsAny<string>(), It.IsAny<bool>()))
.Returns(new IFileInfo[0]); .Returns(System.Array.Empty<IFileInfo>());
} }
[Test] [Test]
@ -147,7 +147,7 @@ namespace NzbDrone.Core.Test.MediaFiles
Mocker.GetMock<IDiskScanService>() Mocker.GetMock<IDiskScanService>()
.Setup(c => c.GetAudioFiles(It.IsAny<string>(), It.IsAny<bool>())) .Setup(c => c.GetAudioFiles(It.IsAny<string>(), It.IsAny<bool>()))
.Returns(new IFileInfo[0]); .Returns(System.Array.Empty<IFileInfo>());
Subject.ProcessRootFolder(DiskProvider.GetDirectoryInfo(_droneFactory)); Subject.ProcessRootFolder(DiskProvider.GetDirectoryInfo(_droneFactory));

@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileDeletionService
[TestFixture] [TestFixture]
public class DeleteTrackFileFixture : CoreTest<Core.MediaFiles.MediaFileDeletionService> public class DeleteTrackFileFixture : CoreTest<Core.MediaFiles.MediaFileDeletionService>
{ {
private static readonly string RootFolder = @"C:\Test\Music"; private const string RootFolder = @"C:\Test\Music";
private Artist _artist; private Artist _artist;
private TrackFile _trackFile; private TrackFile _trackFile;

@ -266,7 +266,7 @@ namespace NzbDrone.Core.Configuration
var valueHolder = parentContainer.Descendants(key).ToList(); var valueHolder = parentContainer.Descendants(key).ToList();
if (valueHolder.Count() == 1) if (valueHolder.Count == 1)
{ {
return valueHolder.First().Value.Trim(); return valueHolder.First().Value.Trim();
} }

@ -250,7 +250,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
} }
Index = end + 1; Index = end + 1;
identifier.Append(Buffer.Substring(start, end - start)); identifier.Append(Buffer.AsSpan(start, end - start));
if (Buffer[Index] != escape) if (Buffer[Index] != escape)
{ {

@ -15,9 +15,9 @@ namespace NzbDrone.Core.Datastore
private const DbType EnumerableMultiParameter = (DbType)(-1); private const DbType EnumerableMultiParameter = (DbType)(-1);
private readonly string _paramNamePrefix; private readonly string _paramNamePrefix;
private readonly bool _requireConcreteValue = false; private readonly bool _requireConcreteValue;
private int _paramCount = 0; private int _paramCount;
private bool _gotConcreteValue = false; private bool _gotConcreteValue;
public WhereBuilderPostgres(Expression filter, bool requireConcreteValue, int seq) public WhereBuilderPostgres(Expression filter, bool requireConcreteValue, int seq)
{ {

@ -15,9 +15,9 @@ namespace NzbDrone.Core.Datastore
private const DbType EnumerableMultiParameter = (DbType)(-1); private const DbType EnumerableMultiParameter = (DbType)(-1);
private readonly string _paramNamePrefix; private readonly string _paramNamePrefix;
private readonly bool _requireConcreteValue = false; private readonly bool _requireConcreteValue;
private int _paramCount = 0; private int _paramCount;
private bool _gotConcreteValue = false; private bool _gotConcreteValue;
public WhereBuilderSqlite(Expression filter, bool requireConcreteValue, int seq) public WhereBuilderSqlite(Expression filter, bool requireConcreteValue, int seq)
{ {
@ -44,7 +44,7 @@ namespace NzbDrone.Core.Datastore
protected override Expression VisitBinary(BinaryExpression expression) protected override Expression VisitBinary(BinaryExpression expression)
{ {
_sb.Append("("); _sb.Append('(');
Visit(expression.Left); Visit(expression.Left);
@ -52,7 +52,7 @@ namespace NzbDrone.Core.Datastore
Visit(expression.Right); Visit(expression.Right);
_sb.Append(")"); _sb.Append(')');
return expression; return expression;
} }
@ -309,7 +309,7 @@ namespace NzbDrone.Core.Datastore
item = body.Arguments[1]; item = body.Arguments[1];
} }
_sb.Append("("); _sb.Append('(');
Visit(item); Visit(item);
@ -319,9 +319,9 @@ namespace NzbDrone.Core.Datastore
if (item.Type == typeof(int) && TryGetRightValue(list, out var value)) if (item.Type == typeof(int) && TryGetRightValue(list, out var value))
{ {
var items = (IEnumerable<int>)value; var items = (IEnumerable<int>)value;
_sb.Append("("); _sb.Append('(');
_sb.Append(string.Join(", ", items)); _sb.Append(string.Join(", ", items));
_sb.Append(")"); _sb.Append(')');
_gotConcreteValue = true; _gotConcreteValue = true;
} }
@ -330,12 +330,12 @@ namespace NzbDrone.Core.Datastore
Visit(list); Visit(list);
} }
_sb.Append(")"); _sb.Append(')');
} }
private void ParseStringContains(MethodCallExpression body) private void ParseStringContains(MethodCallExpression body)
{ {
_sb.Append("("); _sb.Append('(');
Visit(body.Object); Visit(body.Object);
@ -348,7 +348,7 @@ namespace NzbDrone.Core.Datastore
private void ParseStartsWith(MethodCallExpression body) private void ParseStartsWith(MethodCallExpression body)
{ {
_sb.Append("("); _sb.Append('(');
Visit(body.Object); Visit(body.Object);
@ -361,7 +361,7 @@ namespace NzbDrone.Core.Datastore
private void ParseEndsWith(MethodCallExpression body) private void ParseEndsWith(MethodCallExpression body)
{ {
_sb.Append("("); _sb.Append('(');
Visit(body.Object); Visit(body.Object);
@ -369,7 +369,7 @@ namespace NzbDrone.Core.Datastore
Visit(body.Arguments[0]); Visit(body.Arguments[0]);
_sb.Append(")"); _sb.Append(')');
} }
public override string ToString() public override string ToString()

@ -185,7 +185,7 @@ namespace NzbDrone.Core.DecisionEngine
private DownloadDecision GetDecisionForReport(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria = null) private DownloadDecision GetDecisionForReport(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria = null)
{ {
var reasons = new Rejection[0]; var reasons = Array.Empty<Rejection>();
foreach (var specifications in _specifications.GroupBy(v => v.Priority).OrderBy(v => v.Key)) foreach (var specifications in _specifications.GroupBy(v => v.Priority).OrderBy(v => v.Key))
{ {

@ -46,7 +46,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
{ {
var trackFiles = _mediaFileService.GetFilesByAlbum(album.Id); var trackFiles = _mediaFileService.GetFilesByAlbum(album.Id);
if (trackFiles.Count() == 0) if (trackFiles.Count == 0)
{ {
_logger.Debug("Skipping already imported check for album without files"); _logger.Debug("Skipping already imported check for album without files");
continue; continue;

@ -361,7 +361,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
{ {
if (result.Torrents == null) if (result.Torrents == null)
{ {
return new DelugeTorrent[0]; return Array.Empty<DelugeTorrent>();
} }
return result.Torrents.Values.ToArray(); return result.Torrents.Values.ToArray();

@ -112,7 +112,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
{ {
if (torrentsRaw == null) if (torrentsRaw == null)
{ {
return new HadoukenTorrent[0]; return Array.Empty<HadoukenTorrent>();
} }
var torrents = new List<HadoukenTorrent>(); var torrents = new List<HadoukenTorrent>();

@ -16,7 +16,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters
{ {
var split = reader.Value.ToString().Split(':').Select(int.Parse).ToArray(); var split = reader.Value.ToString().Split(':').Select(int.Parse).ToArray();
switch (split.Count()) switch (split.Length)
{ {
case 4: case 4:
return new TimeSpan((split[0] * 24) + split[1], split[2], split[3]); return new TimeSpan((split[0] * 24) + split[1], split[2], split[3]);

@ -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); _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)) foreach (var duplicate in matchingReports.Skip(1))
{ {

@ -18,7 +18,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
public TrackedDownload() public TrackedDownload()
{ {
StatusMessages = new TrackedDownloadStatusMessage[] { }; StatusMessages = System.Array.Empty<TrackedDownloadStatusMessage>();
} }
public void Warn(string message, params object[] args) public void Warn(string message, params object[] args)

@ -111,7 +111,7 @@ namespace NzbDrone.Core.Extras.Lyrics
if (multipleCopies) if (multipleCopies)
{ {
suffixBuilder.Append("."); suffixBuilder.Append('.');
suffixBuilder.Append(copy); suffixBuilder.Append(copy);
} }

@ -34,8 +34,8 @@ namespace NzbDrone.Core.HealthCheck
private readonly ICached<HealthCheck> _healthCheckResults; private readonly ICached<HealthCheck> _healthCheckResults;
private bool _hasRunHealthChecksAfterGracePeriod = false; private bool _hasRunHealthChecksAfterGracePeriod;
private bool _isRunningHealthChecksAfterGracePeriod = false; private bool _isRunningHealthChecksAfterGracePeriod;
public HealthCheckService(IEnumerable<IProvideHealthCheck> healthChecks, public HealthCheckService(IEnumerable<IProvideHealthCheck> healthChecks,
IServerSideNotificationService serverSideNotificationService, IServerSideNotificationService serverSideNotificationService,

@ -19,7 +19,7 @@ namespace NzbDrone.Core.ImportLists.Spotify
public SpotifyPlaylistSettings() public SpotifyPlaylistSettings()
{ {
PlaylistIds = new string[] { }; PlaylistIds = System.Array.Empty<string>();
} }
public override string Scope => "playlist-read-private"; public override string Scope => "playlist-read-private";

@ -176,7 +176,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
releases = ParseResponse(parser, response); releases = ParseResponse(parser, response);
ValidateReleases(releases, indexerSettings); 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)) if (releases.Any(r => r.Size < ValidSizeThreshold))
{ {

@ -127,7 +127,7 @@ namespace NzbDrone.Core.Localization
await CopyInto(dictionary, baseFilenamePath).ConfigureAwait(false); await CopyInto(dictionary, baseFilenamePath).ConfigureAwait(false);
if (culture.Contains("_")) if (culture.Contains('_'))
{ {
var languageBaseFilenamePath = Path.Combine(prefix, GetResourceFilename(culture.Split('_')[0])); var languageBaseFilenamePath = Path.Combine(prefix, GetResourceFilename(culture.Split('_')[0]));
await CopyInto(dictionary, languageBaseFilenamePath).ConfigureAwait(false); await CopyInto(dictionary, languageBaseFilenamePath).ConfigureAwait(false);

@ -283,7 +283,7 @@ namespace NzbDrone.Core.MediaCover
switch (coverType) switch (coverType)
{ {
default: default:
return new int[] { }; return Array.Empty<int>();
case MediaCoverTypes.Poster: case MediaCoverTypes.Poster:
case MediaCoverTypes.Disc: case MediaCoverTypes.Disc:

@ -324,9 +324,9 @@ namespace NzbDrone.Core.MediaFiles
// patch up any null fields to work around TagLib exception for // patch up any null fields to work around TagLib exception for
// WMA with null performers/albumartists // WMA with null performers/albumartists
Performers = Performers ?? new string[0]; Performers = Performers ?? Array.Empty<string>();
AlbumArtists = AlbumArtists ?? new string[0]; AlbumArtists = AlbumArtists ?? Array.Empty<string>();
Genres = Genres ?? new string[0]; Genres = Genres ?? Array.Empty<string>();
TagLib.File file = null; TagLib.File file = null;
try try

@ -209,7 +209,7 @@ namespace NzbDrone.Core.MediaFiles
foreach (var file in files) 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; file.Path = newPath;
} }

@ -58,9 +58,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators
public LocalAlbumRelease Aggregate(LocalAlbumRelease release, bool others) public LocalAlbumRelease Aggregate(LocalAlbumRelease release, bool others)
{ {
var tracks = release.LocalTracks; var tracks = release.LocalTracks;
if (tracks.Count(x => x.FileTrackInfo.Title.IsNullOrWhiteSpace()) > 0 if (tracks.Any(x => x.FileTrackInfo.Title.IsNullOrWhiteSpace())
|| tracks.Count(x => x.FileTrackInfo.TrackNumbers.First() == 0) > 0 || tracks.Any(x => x.FileTrackInfo.TrackNumbers.First() == 0)
|| tracks.Count(x => x.FileTrackInfo.DiscNumber == 0) > 0) || tracks.Any(x => x.FileTrackInfo.DiscNumber == 0))
{ {
_logger.Debug("Missing data in tags, trying filename augmentation"); _logger.Debug("Missing data in tags, trying filename augmentation");
foreach (var charSep in CharsAndSeps) foreach (var charSep in CharsAndSeps)
@ -171,7 +171,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators
} }
var trackNums = track.FileTrackInfo.TrackNumbers; 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); var tracknum = Convert.ToInt32(matches[track].Groups["track"].Value);
if (tracknum > 100) if (tracknum > 100)

@ -39,7 +39,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
} }
public Dictionary<string, List<double>> Penalties => _penalties; public Dictionary<string, List<double>> 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<string, List<double>> penalties) private double MaxDistance(Dictionary<string, List<double>> penalties)
{ {

@ -19,10 +19,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
public class TrackGroupingService : ITrackGroupingService public class TrackGroupingService : ITrackGroupingService
{ {
private const string MultiDiscPatternFormat = @"^(?<root>.*%s[\W_]*)\d";
private static readonly Logger _logger = NzbDroneLogger.GetLogger(typeof(TrackGroupingService)); private static readonly Logger _logger = NzbDroneLogger.GetLogger(typeof(TrackGroupingService));
private static readonly List<string> MultiDiscMarkers = new List<string> { @"dis[ck]", @"cd" }; private static readonly List<string> MultiDiscMarkers = new List<string> { @"dis[ck]", @"cd" };
private static readonly string MultiDiscPatternFormat = @"^(?<root>.*%s[\W_]*)\d";
private static readonly List<string> VariousArtistTitles = new List<string> { "", "various artists", "various", "va", "unknown" }; private static readonly List<string> VariousArtistTitles = new List<string> { "", "various artists", "various", "va", "unknown" };
public List<LocalAlbumRelease> GroupTracks(List<LocalTrack> localTracks) public List<LocalAlbumRelease> GroupTracks(List<LocalTrack> localTracks)

@ -69,7 +69,7 @@ namespace NzbDrone.Core.Notifications.Discord
case DiscordGrabFieldType.Overview: case DiscordGrabFieldType.Overview:
var overview = albums.First().Overview ?? ""; var overview = albums.First().Overview ?? "";
discordField.Name = "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; break;
case DiscordGrabFieldType.Rating: case DiscordGrabFieldType.Rating:
discordField.Name = "Rating"; discordField.Name = "Rating";
@ -162,7 +162,7 @@ namespace NzbDrone.Core.Notifications.Discord
case DiscordImportFieldType.Overview: case DiscordImportFieldType.Overview:
var overview = album.Overview ?? ""; var overview = album.Overview ?? "";
discordField.Name = "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; break;
case DiscordImportFieldType.Rating: case DiscordImportFieldType.Rating:
discordField.Name = "Rating"; discordField.Name = "Rating";

@ -22,7 +22,7 @@ namespace NzbDrone.Core.Notifications.Mailgun
public MailgunSettings() public MailgunSettings()
{ {
Recipients = new string[] { }; Recipients = System.Array.Empty<string>();
} }
[FieldDefinition(0, Label = "API Key", HelpText = "The API key generated from MailGun")] [FieldDefinition(0, Label = "API Key", HelpText = "The API key generated from MailGun")]

@ -20,8 +20,8 @@ namespace NzbDrone.Core.Notifications.PushBullet
public PushBulletSettings() public PushBulletSettings()
{ {
DeviceIds = new string[] { }; DeviceIds = System.Array.Empty<string>();
ChannelTags = new string[] { }; ChannelTags = System.Array.Empty<string>();
} }
[FieldDefinition(0, Label = "Access Token", Privacy = PrivacyLevel.ApiKey, HelpLink = "https://www.pushbullet.com/#settings/account")] [FieldDefinition(0, Label = "Access Token", Privacy = PrivacyLevel.ApiKey, HelpLink = "https://www.pushbullet.com/#settings/account")]

@ -23,7 +23,7 @@ namespace NzbDrone.Core.Notifications.Pushover
public PushoverSettings() public PushoverSettings()
{ {
Priority = 0; Priority = 0;
Devices = new string[] { }; Devices = System.Array.Empty<string>();
} }
// TODO: Get Pushover to change our app name (or create a new app) when we have a new logo // TODO: Get Pushover to change our app name (or create a new app) when we have a new logo

@ -24,7 +24,7 @@ namespace NzbDrone.Core.Notifications.SendGrid
public SendGridSettings() public SendGridSettings()
{ {
BaseUrl = "https://api.sendgrid.com/v3/"; BaseUrl = "https://api.sendgrid.com/v3/";
Recipients = new string[] { }; Recipients = System.Array.Empty<string>();
} }
public string BaseUrl { get; set; } public string BaseUrl { get; set; }

@ -102,7 +102,7 @@ namespace NzbDrone.Core.Organizer
var pattern = namingConfig.StandardTrackFormat; var pattern = namingConfig.StandardTrackFormat;
if (tracks.First().AlbumRelease.Value.Media.Count() > 1) if (tracks.First().AlbumRelease.Value.Media.Count > 1)
{ {
pattern = namingConfig.MultiDiscTrackFormat; pattern = namingConfig.MultiDiscTrackFormat;
} }

@ -33,7 +33,7 @@ namespace NzbDrone.Core.Parser.Model
public ParsedTrackInfo() public ParsedTrackInfo()
{ {
TrackNumbers = new int[0]; TrackNumbers = Array.Empty<int>();
} }
public override string ToString() public override string ToString()

@ -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 // 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) public static bool IsSceneTitle(string title)
{ {
if (!title.Contains(".")) if (!title.Contains('.'))
{ {
return false; return false;
} }
if (title.Contains(" ")) if (title.Contains(' '))
{ {
return false; return false;
} }

@ -127,7 +127,7 @@ namespace NzbDrone.Host
c.AddSecurityRequirement(new OpenApiSecurityRequirement c.AddSecurityRequirement(new OpenApiSecurityRequirement
{ {
{ apiKeyHeader, new string[] { } } { apiKeyHeader, Array.Empty<string>() }
}); });
var apikeyQuery = new OpenApiSecurityScheme var apikeyQuery = new OpenApiSecurityScheme
@ -158,7 +158,7 @@ namespace NzbDrone.Host
c.AddSecurityRequirement(new OpenApiSecurityRequirement c.AddSecurityRequirement(new OpenApiSecurityRequirement
{ {
{ apikeyQuery, new string[] { } } { apikeyQuery, Array.Empty<string>() }
}); });
}); });

@ -48,7 +48,7 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters
Subject.Read().Should().BeNull(); Subject.Read().Should().BeNull();
Mocker.GetMock<IDiskProvider>() Mocker.GetMock<IDiskProvider>()
.Setup(c => c.GetFiles(It.IsAny<string>(), SearchOption.TopDirectoryOnly)).Returns(new string[0]); .Setup(c => c.GetFiles(It.IsAny<string>(), SearchOption.TopDirectoryOnly)).Returns(System.Array.Empty<string>());
Subject.Read().Should().BeNull(); Subject.Read().Should().BeNull();
} }

@ -26,7 +26,7 @@ namespace NzbDrone.Mono.Disk
private static Dictionary<string, bool> _fileSystems; private static Dictionary<string, bool> _fileSystems;
private readonly Logger _logger; private readonly Logger _logger;
private bool _hasLoggedProcMountFailure = false; private bool _hasLoggedProcMountFailure;
public ProcMountProvider(Logger logger) public ProcMountProvider(Logger logger)
{ {

@ -2,6 +2,7 @@ using System;
using Mono.Unix; using Mono.Unix;
using Mono.Unix.Native; using Mono.Unix.Native;
using NLog; using NLog;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Mono.Disk namespace NzbDrone.Mono.Disk
{ {
@ -55,7 +56,7 @@ namespace NzbDrone.Mono.Disk
var target = 0; var target = 0;
for (var i = 0; i < dirs.Length; ++i) for (var i = 0; i < dirs.Length; ++i)
{ {
if (dirs[i] == "." || dirs[i] == string.Empty) if (dirs[i] == "." || dirs[i].IsNullOrWhiteSpace())
{ {
continue; continue;
} }

@ -27,7 +27,7 @@ namespace NzbDrone.Test.Common
public int Start() public int Start()
{ {
int threadId = Thread.CurrentThread.ManagedThreadId; int threadId = Environment.CurrentManagedThreadId;
lock (_mutex) lock (_mutex)
{ {
_threads[threadId] = 1; _threads[threadId] = 1;

@ -53,7 +53,7 @@ namespace NzbDrone.Test.Common
{ {
_mocker = new AutoMoqer(); _mocker = new AutoMoqer();
_mocker.SetConstant<ICacheManager>(new CacheManager()); _mocker.SetConstant<ICacheManager>(new CacheManager());
_mocker.SetConstant<IStartupContext>(new StartupContext(new string[0])); _mocker.SetConstant<IStartupContext>(new StartupContext(Array.Empty<string>()));
_mocker.SetConstant(TestLogger); _mocker.SetConstant(TestLogger);
} }

@ -74,7 +74,7 @@ namespace NzbDrone.Update
if (OsInfo.IsNotWindows) if (OsInfo.IsNotWindows)
{ {
switch (args.Count()) switch (args.Length)
{ {
case 1: case 1:
return startupContext; return startupContext;

Loading…
Cancel
Save