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_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

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

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

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

@ -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))

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

@ -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;
}

@ -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<string>());
args.Flags.Should().BeEmpty();
}

@ -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<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);

@ -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<BigInteger>();
for (int d = 0; d < pattern.Length; d++)
{
// 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)
{
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;
}
}
}

@ -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<string>();
}
public Dictionary<string, string> GetCookies()

@ -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));
}

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

@ -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()));
}
}
}

@ -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()));
}
}
}

@ -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;
}

@ -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\"";

@ -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;
/// <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>
/// 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\"");
// 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);

@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
[TestFixture]
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)
{

@ -11,7 +11,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
[TestFixture]
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)
{

@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
Mocker.GetMock<IHttpClient>()
.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()

@ -34,7 +34,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
Mocker.GetMock<IHttpClient>()
.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>()
.Setup(v => v.RemapRemoteToLocal(It.IsAny<string>(), It.IsAny<OsPath>()))

@ -278,7 +278,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Mocker.GetMock<IHttpClient>()
.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>
{

@ -170,7 +170,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Mocker.GetMock<IHttpClient>()
.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>
{

@ -86,7 +86,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests
Mocker.GetMock<IHttpClient>()
.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()

@ -38,7 +38,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
Mocker.GetMock<IHttpClient>()
.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>()
.Setup(s => s.GetConfig(It.IsAny<QBittorrentSettings>()))
@ -56,7 +56,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
Mocker.GetMock<IHttpClient>()
.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()
@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
Mocker.GetMock<IHttpClient>()
.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()
@ -522,7 +522,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
Mocker.GetMock<IQBittorrentProxy>()
.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();

@ -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<string>();
var result = new NzbDroneValidationResult(Subject.Test());

@ -99,7 +99,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
Mocker.GetMock<IHttpClient>()
.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>();

@ -91,7 +91,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
Mocker.GetMock<IHttpClient>()
.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()
@ -101,7 +101,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
Mocker.GetMock<IHttpClient>()
.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()
@ -111,7 +111,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
Mocker.GetMock<IHttpClient>()
.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()

@ -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<byte>(), (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<byte>(), (HttpStatusCode)429);
response.Headers["Retry-After"] = DateTime.UtcNow.AddSeconds(300).ToString("r");
var mock = WithUsenetClient();

@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.Framework
Mocker.SetConstant<ICreateManagedWebProxy>(new ManagedWebProxyFactory(Mocker.Resolve<CacheManager>()));
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<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<IMetadataRequestBuilder>(Mocker.Resolve<MetadataRequestBuilder>());
}

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

@ -12,9 +12,6 @@ namespace NzbDrone.Core.Test.ImportListTests
[TestFixture]
public class SpotifyFollowedArtistsFixture : CoreTest<SpotifyFollowedArtists>
{
// 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<SpotifyWebAPI>()))
.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<SpotifyWebAPI>()))
.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<SpotifyWebAPI>()))
.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<SpotifyWebAPI>()))
.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<SpotifyWebAPI>()))
.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<FollowedArtists>()))
.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<SpotifyWebAPI>()))
.Returns(followed);
var result = Subject.Fetch(_api);
var result = Subject.Fetch(null);
result.Should().BeEmpty();
}

@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.ImportListTests
{
Mocker.GetMock<IHttpClient>()
.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
{
@ -120,7 +120,7 @@ namespace NzbDrone.Core.Test.ImportListTests
{
Mocker.GetMock<IHttpClient>()
.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
{

@ -12,9 +12,6 @@ namespace NzbDrone.Core.Test.ImportListTests
[TestFixture]
public class SpotifyPlaylistFixture : CoreTest<SpotifyPlaylist>
{
// 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<string>()))
.Returns(default(Paging<PlaylistTrack>));
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<string>()))
.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<string>()))
.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<string>()))
.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<string>()))
.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<string>()))
.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<Paging<PlaylistTrack>>()))
.Returns(default(Paging<PlaylistTrack>));
var result = Subject.Fetch(_api, "playlistid");
var result = Subject.Fetch(null, "playlistid");
result.Should().HaveCount(1);

@ -12,9 +12,6 @@ namespace NzbDrone.Core.Test.ImportListTests
[TestFixture]
public class SpotifySavedAlbumsFixture : CoreTest<SpotifySavedAlbums>
{
// 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<SpotifyWebAPI>()))
.Returns(default(Paging<SavedAlbum>));
var result = Subject.Fetch(_api);
var result = Subject.Fetch(null);
result.Should().BeEmpty();
}
@ -41,7 +38,7 @@ namespace NzbDrone.Core.Test.ImportListTests
It.IsAny<SpotifyWebAPI>()))
.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<SpotifyWebAPI>()))
.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<SpotifyWebAPI>()))
.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<Paging<SavedAlbum>>()))
.Returns(default(Paging<SavedAlbum>));
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<SpotifyWebAPI>()))
.Returns(savedAlbums);
var result = Subject.Fetch(_api);
var result = Subject.Fetch(null);
result.Should().BeEmpty();
}

@ -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<byte>(), (HttpStatusCode)429);
response.Headers["Retry-After"] = "300";
Mocker.GetMock<INewznabCapabilitiesProvider>()

@ -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<string>(),
AlbumArtists = Array.Empty<string>(),
Genres = Array.Empty<string>()
};
VerifySame(tag, expected, skipProperties);

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

@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileDeletionService
[TestFixture]
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 TrackFile _trackFile;

@ -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();
}

@ -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)
{

@ -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)
{

@ -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<int>)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()

@ -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<Rejection>();
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);
if (trackFiles.Count() == 0)
if (trackFiles.Count == 0)
{
_logger.Debug("Skipping already imported check for album without files");
continue;

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

@ -112,7 +112,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
{
if (torrentsRaw == null)
{
return new HadoukenTorrent[0];
return Array.Empty<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();
switch (split.Count())
switch (split.Length)
{
case 4:
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);
}
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))
{

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

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

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

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

@ -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))
{

@ -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);

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

@ -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<string>();
AlbumArtists = AlbumArtists ?? Array.Empty<string>();
Genres = Genres ?? Array.Empty<string>();
TagLib.File file = null;
try

@ -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;
}

@ -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)

@ -39,7 +39,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
}
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)
{

@ -19,10 +19,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
public class TrackGroupingService : ITrackGroupingService
{
private const string MultiDiscPatternFormat = @"^(?<root>.*%s[\W_]*)\d";
private static readonly Logger _logger = NzbDroneLogger.GetLogger(typeof(TrackGroupingService));
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" };
public List<LocalAlbumRelease> GroupTracks(List<LocalTrack> localTracks)

@ -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";

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

@ -20,8 +20,8 @@ namespace NzbDrone.Core.Notifications.PushBullet
public PushBulletSettings()
{
DeviceIds = new string[] { };
ChannelTags = new string[] { };
DeviceIds = System.Array.Empty<string>();
ChannelTags = System.Array.Empty<string>();
}
[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()
{
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

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

@ -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;
}

@ -33,7 +33,7 @@ namespace NzbDrone.Core.Parser.Model
public ParsedTrackInfo()
{
TrackNumbers = new int[0];
TrackNumbers = Array.Empty<int>();
}
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
public static bool IsSceneTitle(string title)
{
if (!title.Contains("."))
if (!title.Contains('.'))
{
return false;
}
if (title.Contains(" "))
if (title.Contains(' '))
{
return false;
}

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

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

@ -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;
}

@ -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;

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

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

Loading…
Cancel
Save