mirror of
https://github.com/Readarr/Readarr
synced 2026-01-16 12:33:54 +01:00
Inline 'out' variable declarations
(cherry picked from commit 281add47de1d3940990156c841362125dea9cc7d) Closes #2558
This commit is contained in:
parent
fc6c78a54e
commit
89dd4d3271
38 changed files with 66 additions and 149 deletions
|
|
@ -54,8 +54,7 @@ public void Set(string key, T value, TimeSpan? lifeTime = null)
|
|||
|
||||
public T Find(string key)
|
||||
{
|
||||
CacheItem cacheItem;
|
||||
if (!_store.TryGetValue(key, out cacheItem))
|
||||
if (!_store.TryGetValue(key, out var cacheItem))
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
|
@ -84,8 +83,7 @@ public T Find(string key)
|
|||
|
||||
public void Remove(string key)
|
||||
{
|
||||
CacheItem value;
|
||||
_store.TryRemove(key, out value);
|
||||
_store.TryRemove(key, out _);
|
||||
}
|
||||
|
||||
public int Count => _store.Count;
|
||||
|
|
@ -96,9 +94,7 @@ public T Get(string key, Func<T> function, TimeSpan? lifeTime = null)
|
|||
|
||||
lifeTime = lifeTime ?? _defaultLifeTime;
|
||||
|
||||
CacheItem cacheItem;
|
||||
|
||||
if (_store.TryGetValue(key, out cacheItem) && !cacheItem.IsExpired())
|
||||
if (_store.TryGetValue(key, out var cacheItem) && !cacheItem.IsExpired())
|
||||
{
|
||||
if (_rollingExpiry && lifeTime.HasValue)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
|
@ -86,9 +86,7 @@ public TValue Get(string key)
|
|||
{
|
||||
RefreshIfExpired();
|
||||
|
||||
TValue result;
|
||||
|
||||
if (!_items.TryGetValue(key, out result))
|
||||
if (!_items.TryGetValue(key, out var result))
|
||||
{
|
||||
throw new KeyNotFoundException(string.Format("Item {0} not found in cache.", key));
|
||||
}
|
||||
|
|
@ -100,9 +98,7 @@ public TValue Find(string key)
|
|||
{
|
||||
RefreshIfExpired();
|
||||
|
||||
TValue result;
|
||||
|
||||
_items.TryGetValue(key, out result);
|
||||
_items.TryGetValue(key, out var result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -128,8 +124,7 @@ public void ClearExpired()
|
|||
|
||||
public void Remove(string key)
|
||||
{
|
||||
TValue item;
|
||||
_items.TryRemove(key, out item);
|
||||
_items.TryRemove(key, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@ public static class TryParseExtensions
|
|||
{
|
||||
public static int? ParseInt32(this string source)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (int.TryParse(source, out result))
|
||||
if (int.TryParse(source, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
|
@ -18,9 +16,7 @@ public static class TryParseExtensions
|
|||
|
||||
public static long? ParseInt64(this string source)
|
||||
{
|
||||
long result;
|
||||
|
||||
if (long.TryParse(source, out result))
|
||||
if (long.TryParse(source, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
|
@ -30,9 +26,7 @@ public static class TryParseExtensions
|
|||
|
||||
public static double? ParseDouble(this string source)
|
||||
{
|
||||
double result;
|
||||
|
||||
if (double.TryParse(source.Replace(',', '.'), NumberStyles.Number, CultureInfo.InvariantCulture, out result))
|
||||
if (double.TryParse(source.Replace(',', '.'), NumberStyles.Number, CultureInfo.InvariantCulture, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,14 +12,12 @@ public TooManyRequestsException(HttpRequest request, HttpResponse response)
|
|||
if (response.Headers.ContainsKey("Retry-After"))
|
||||
{
|
||||
var retryAfter = response.Headers["Retry-After"].ToString();
|
||||
int seconds;
|
||||
DateTime date;
|
||||
|
||||
if (int.TryParse(retryAfter, out seconds))
|
||||
if (int.TryParse(retryAfter, out var seconds))
|
||||
{
|
||||
RetryAfter = TimeSpan.FromSeconds(seconds);
|
||||
}
|
||||
else if (DateTime.TryParse(retryAfter, out date))
|
||||
else if (DateTime.TryParse(retryAfter, out var date))
|
||||
{
|
||||
RetryAfter = date.ToUniversalTime() - DateTime.UtcNow;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,8 +117,7 @@ public void SaveConfigDictionary(Dictionary<string, object> configValues)
|
|||
continue;
|
||||
}
|
||||
|
||||
object currentValue;
|
||||
allWithDefaults.TryGetValue(configValue.Key, out currentValue);
|
||||
allWithDefaults.TryGetValue(configValue.Key, out var currentValue);
|
||||
if (currentValue == null)
|
||||
{
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -56,8 +56,7 @@ public void SaveConfigDictionary(Dictionary<string, object> configValues)
|
|||
|
||||
foreach (var configValue in configValues)
|
||||
{
|
||||
object currentValue;
|
||||
allWithDefaults.TryGetValue(configValue.Key, out currentValue);
|
||||
allWithDefaults.TryGetValue(configValue.Key, out var currentValue);
|
||||
if (currentValue == null || configValue.Value == null)
|
||||
{
|
||||
continue;
|
||||
|
|
@ -439,9 +438,7 @@ public string GetValue(string key, object defaultValue, bool persist = false)
|
|||
|
||||
EnsureCache();
|
||||
|
||||
string dbValue;
|
||||
|
||||
if (_cache.TryGetValue(key, out dbValue) && dbValue != null && !string.IsNullOrEmpty(dbValue))
|
||||
if (_cache.TryGetValue(key, out var dbValue) && dbValue != null && !string.IsNullOrEmpty(dbValue))
|
||||
{
|
||||
return dbValue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,9 +254,8 @@ protected DownloadItemStatus GetStatus(DownloadStationTask torrent)
|
|||
protected long GetRemainingSize(DownloadStationTask torrent)
|
||||
{
|
||||
var downloadedString = torrent.Additional.Transfer["size_downloaded"];
|
||||
long downloadedSize;
|
||||
|
||||
if (downloadedString.IsNullOrWhiteSpace() || !long.TryParse(downloadedString, out downloadedSize))
|
||||
if (downloadedString.IsNullOrWhiteSpace() || !long.TryParse(downloadedString, out var downloadedSize))
|
||||
{
|
||||
_logger.Debug("Torrent {0} has invalid size_downloaded: {1}", torrent.Title, downloadedString);
|
||||
downloadedSize = 0;
|
||||
|
|
@ -268,9 +267,8 @@ protected long GetRemainingSize(DownloadStationTask torrent)
|
|||
protected TimeSpan? GetRemainingTime(DownloadStationTask torrent)
|
||||
{
|
||||
var speedString = torrent.Additional.Transfer["speed_download"];
|
||||
long downloadSpeed;
|
||||
|
||||
if (speedString.IsNullOrWhiteSpace() || !long.TryParse(speedString, out downloadSpeed))
|
||||
if (speedString.IsNullOrWhiteSpace() || !long.TryParse(speedString, out var downloadSpeed))
|
||||
{
|
||||
_logger.Debug("Torrent {0} has invalid speed_download: {1}", torrent.Title, speedString);
|
||||
downloadSpeed = 0;
|
||||
|
|
|
|||
|
|
@ -351,9 +351,8 @@ protected DownloadItemStatus GetStatus(DownloadStationTask task)
|
|||
protected long GetRemainingSize(DownloadStationTask task)
|
||||
{
|
||||
var downloadedString = task.Additional.Transfer["size_downloaded"];
|
||||
long downloadedSize;
|
||||
|
||||
if (downloadedString.IsNullOrWhiteSpace() || !long.TryParse(downloadedString, out downloadedSize))
|
||||
if (downloadedString.IsNullOrWhiteSpace() || !long.TryParse(downloadedString, out var downloadedSize))
|
||||
{
|
||||
_logger.Debug("Task {0} has invalid size_downloaded: {1}", task.Title, downloadedString);
|
||||
downloadedSize = 0;
|
||||
|
|
@ -365,9 +364,8 @@ protected long GetRemainingSize(DownloadStationTask task)
|
|||
protected long GetDownloadSpeed(DownloadStationTask task)
|
||||
{
|
||||
var speedString = task.Additional.Transfer["speed_download"];
|
||||
long downloadSpeed;
|
||||
|
||||
if (speedString.IsNullOrWhiteSpace() || !long.TryParse(speedString, out downloadSpeed))
|
||||
if (speedString.IsNullOrWhiteSpace() || !long.TryParse(speedString, out var downloadSpeed))
|
||||
{
|
||||
_logger.Debug("Task {0} has invalid speed_download: {1}", task.Title, speedString);
|
||||
downloadSpeed = 0;
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
|
|||
{
|
||||
var result = reader.Value.ToString().Replace("_", string.Empty);
|
||||
|
||||
NzbVortexLoginResultType output;
|
||||
Enum.TryParse(result, true, out output);
|
||||
Enum.TryParse(result, true, out NzbVortexLoginResultType output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
|
|||
{
|
||||
var result = reader.Value.ToString().Replace("_", string.Empty);
|
||||
|
||||
NzbVortexResultType output;
|
||||
Enum.TryParse(result, true, out output);
|
||||
Enum.TryParse(result, true, out NzbVortexResultType output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,9 +113,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
|
|||
public override void RemoveItem(DownloadClientItem item, bool deleteData)
|
||||
{
|
||||
// Try to find the download by numerical ID, otherwise try by AddUUID
|
||||
int id;
|
||||
|
||||
if (int.TryParse(item.DownloadId, out id))
|
||||
if (int.TryParse(item.DownloadId, out var id))
|
||||
{
|
||||
_proxy.Remove(id, deleteData, Settings);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -310,8 +310,7 @@ private ValidationFailure TestSettings()
|
|||
var config = _proxy.GetConfig(Settings);
|
||||
|
||||
var keepHistory = config.GetValueOrDefault("KeepHistory", "7");
|
||||
int value;
|
||||
if (!int.TryParse(keepHistory, NumberStyles.None, CultureInfo.InvariantCulture, out value) || value == 0)
|
||||
if (!int.TryParse(keepHistory, NumberStyles.None, CultureInfo.InvariantCulture, out var value) || value == 0)
|
||||
{
|
||||
return new NzbDroneValidationFailure(string.Empty, "NzbGet setting KeepHistory should be greater than 0")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -164,11 +164,10 @@ public void RemoveItem(string id, NzbgetSettings settings)
|
|||
var queue = GetQueue(settings);
|
||||
var history = GetHistory(settings);
|
||||
|
||||
int nzbId;
|
||||
NzbgetQueueItem queueItem;
|
||||
NzbgetHistoryItem historyItem;
|
||||
|
||||
if (id.Length < 10 && int.TryParse(id, out nzbId))
|
||||
if (id.Length < 10 && int.TryParse(id, out var nzbId))
|
||||
{
|
||||
// Download wasn't grabbed by Readarr, so the id is the NzbId reported by nzbget.
|
||||
queueItem = queue.SingleOrDefault(h => h.NzbId == nzbId);
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
|
|||
{
|
||||
var queuePriority = reader.Value.ToString();
|
||||
|
||||
SabnzbdPriority output;
|
||||
Enum.TryParse(queuePriority, out output);
|
||||
Enum.TryParse(queuePriority, out SabnzbdPriority output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,9 +51,7 @@ public SabnzbdAddResponse DownloadNzb(byte[] nzbData, string filename, string ca
|
|||
|
||||
request.AddFormUpload("name", filename, nzbData, "application/x-nzb");
|
||||
|
||||
SabnzbdAddResponse response;
|
||||
|
||||
if (!Json.TryDeserialize<SabnzbdAddResponse>(ProcessRequest(request, settings), out response))
|
||||
if (!Json.TryDeserialize<SabnzbdAddResponse>(ProcessRequest(request, settings), out var response))
|
||||
{
|
||||
response = new SabnzbdAddResponse();
|
||||
response.Status = true;
|
||||
|
|
@ -76,9 +74,7 @@ public string GetVersion(SabnzbdSettings settings)
|
|||
{
|
||||
var request = BuildRequest("version", settings);
|
||||
|
||||
SabnzbdVersionResponse response;
|
||||
|
||||
if (!Json.TryDeserialize<SabnzbdVersionResponse>(ProcessRequest(request, settings), out response))
|
||||
if (!Json.TryDeserialize<SabnzbdVersionResponse>(ProcessRequest(request, settings), out var response))
|
||||
{
|
||||
response = new SabnzbdVersionResponse();
|
||||
}
|
||||
|
|
@ -142,9 +138,7 @@ public string RetryDownload(string id, SabnzbdSettings settings)
|
|||
var request = BuildRequest("retry", settings);
|
||||
request.AddQueryParam("value", id);
|
||||
|
||||
SabnzbdRetryResponse response;
|
||||
|
||||
if (!Json.TryDeserialize<SabnzbdRetryResponse>(ProcessRequest(request, settings), out response))
|
||||
if (!Json.TryDeserialize<SabnzbdRetryResponse>(ProcessRequest(request, settings), out var response))
|
||||
{
|
||||
response = new SabnzbdRetryResponse();
|
||||
response.Status = true;
|
||||
|
|
@ -215,9 +209,7 @@ private string ProcessRequest(HttpRequestBuilder requestBuilder, SabnzbdSettings
|
|||
|
||||
private void CheckForError(HttpResponse response)
|
||||
{
|
||||
SabnzbdJsonError result;
|
||||
|
||||
if (!Json.TryDeserialize<SabnzbdJsonError>(response.Content, out result))
|
||||
if (!Json.TryDeserialize<SabnzbdJsonError>(response.Content, out var result))
|
||||
{
|
||||
//Handle plain text responses from SAB
|
||||
result = new SabnzbdJsonError();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using FluentValidation.Results;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Http;
|
||||
|
|
@ -54,8 +54,7 @@ protected override ValidationFailure ValidateVersion()
|
|||
|
||||
_logger.Debug("Vuze protocol version information: {0}", versionString);
|
||||
|
||||
int version;
|
||||
if (!int.TryParse(versionString, out version) || version < MINIMUM_SUPPORTED_PROTOCOL_VERSION)
|
||||
if (!int.TryParse(versionString, out var version) || version < MINIMUM_SUPPORTED_PROTOCOL_VERSION)
|
||||
{
|
||||
{
|
||||
return new ValidationFailure(string.Empty, "Protocol version not supported, use Vuze 5.0.0.0 or higher with Vuze Web Remote plugin.");
|
||||
|
|
|
|||
|
|
@ -60,8 +60,7 @@ private IEnumerable<IDownloadClient> FilterBlockedClients(IEnumerable<IDownloadC
|
|||
|
||||
foreach (var client in clients)
|
||||
{
|
||||
DownloadClientStatus downloadClientStatus;
|
||||
if (blockedIndexers.TryGetValue(client.Definition.Id, out downloadClientStatus))
|
||||
if (blockedIndexers.TryGetValue(client.Definition.Id, out var downloadClientStatus))
|
||||
{
|
||||
_logger.Debug("Temporarily ignoring download client {0} till {1} due to recent failures.", client.Definition.Name, downloadClientStatus.DisabledTill.Value.ToLocalTime());
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -307,8 +307,7 @@ private List<PendingRelease> IncludeRemoteBooks(List<PendingRelease> releases, D
|
|||
|
||||
List<Book> books;
|
||||
|
||||
RemoteBook knownRemoteBook;
|
||||
if (knownRemoteBooks != null && knownRemoteBooks.TryGetValue(release.Release.Title, out knownRemoteBook))
|
||||
if (knownRemoteBooks != null && knownRemoteBooks.TryGetValue(release.Release.Title, out var knownRemoteBook))
|
||||
{
|
||||
books = knownRemoteBook.Books;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,8 +164,7 @@ public void HandleAsync(IEvent message)
|
|||
_isRunningHealthChecksAfterGracePeriod = false;
|
||||
}
|
||||
|
||||
IEventDrivenHealthCheck[] checks;
|
||||
if (!_eventDrivenHealthChecks.TryGetValue(message.GetType(), out checks))
|
||||
if (!_eventDrivenHealthChecks.TryGetValue(message.GetType(), out var checks))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,8 +61,7 @@ private IEnumerable<IImportList> FilterBlockedImportLists(IEnumerable<IImportLis
|
|||
|
||||
foreach (var importList in importLists)
|
||||
{
|
||||
ImportListStatus blockedImportListStatus;
|
||||
if (blockedImportLists.TryGetValue(importList.Definition.Id, out blockedImportListStatus))
|
||||
if (blockedImportLists.TryGetValue(importList.Definition.Id, out var blockedImportListStatus))
|
||||
{
|
||||
_logger.Debug("Temporarily ignoring import list {0} till {1} due to recent failures.", importList.Definition.Name, blockedImportListStatus.DisabledTill.Value.ToLocalTime());
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -88,8 +88,7 @@ private IEnumerable<IIndexer> FilterBlockedIndexers(IEnumerable<IIndexer> indexe
|
|||
|
||||
foreach (var indexer in indexers)
|
||||
{
|
||||
IndexerStatus blockedIndexerStatus;
|
||||
if (blockedIndexers.TryGetValue(indexer.Definition.Id, out blockedIndexerStatus))
|
||||
if (blockedIndexers.TryGetValue(indexer.Definition.Id, out var blockedIndexerStatus))
|
||||
{
|
||||
_logger.Debug("Temporarily ignoring indexer {0} till {1} due to recent failures.", indexer.Definition.Name, blockedIndexerStatus.DisabledTill.Value.ToLocalTime());
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -129,10 +129,8 @@ protected override List<Language> GetLanguages(XElement item)
|
|||
|
||||
protected override long GetSize(XElement item)
|
||||
{
|
||||
long size;
|
||||
|
||||
var sizeString = TryGetNewznabAttribute(item, "size");
|
||||
if (!sizeString.IsNullOrWhiteSpace() && long.TryParse(sizeString, out size))
|
||||
if (!sizeString.IsNullOrWhiteSpace() && long.TryParse(sizeString, out var size))
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,10 +110,8 @@ protected override List<Language> GetLanguages(XElement item)
|
|||
|
||||
protected override long GetSize(XElement item)
|
||||
{
|
||||
long size;
|
||||
|
||||
var sizeString = TryGetTorznabAttribute(item, "size");
|
||||
if (!sizeString.IsNullOrWhiteSpace() && long.TryParse(sizeString, out size))
|
||||
if (!sizeString.IsNullOrWhiteSpace() && long.TryParse(sizeString, out var size))
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
|
@ -39,8 +39,7 @@ public static DateTime ParseDate(string dateString)
|
|||
{
|
||||
try
|
||||
{
|
||||
DateTime result;
|
||||
if (!DateTime.TryParse(dateString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal, out result))
|
||||
if (!DateTime.TryParse(dateString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal, out var result))
|
||||
{
|
||||
dateString = RemoveTimeZoneRegex.Replace(dateString, "");
|
||||
result = DateTime.Parse(dateString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal);
|
||||
|
|
|
|||
|
|
@ -76,8 +76,7 @@ public void PublishEvent<TEvent>(TEvent @event)
|
|||
EventSubscribers<TEvent> subscribers;
|
||||
lock (_eventSubscribers)
|
||||
{
|
||||
object target;
|
||||
if (!_eventSubscribers.TryGetValue(eventName, out target))
|
||||
if (!_eventSubscribers.TryGetValue(eventName, out var target))
|
||||
{
|
||||
_eventSubscribers[eventName] = target = new EventSubscribers<TEvent>(_serviceFactory);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,13 +73,12 @@ public static decimal ElementAsDecimal(this XElement element, XName name)
|
|||
// This regex corrects the format and hopefully doesn't mess anything else up...
|
||||
var validDateFormat = Regex.Replace(value, @"(.*) ([+-]\d{2})(\d{2}) (.*)", "$1 $2:$3 $4");
|
||||
|
||||
DateTime localDate;
|
||||
if (DateTime.TryParseExact(
|
||||
validDateFormat,
|
||||
"ddd MMM dd HH:mm:ss zzz yyyy",
|
||||
CultureInfo.InvariantCulture,
|
||||
DateTimeStyles.None,
|
||||
out localDate))
|
||||
validDateFormat,
|
||||
"ddd MMM dd HH:mm:ss zzz yyyy",
|
||||
CultureInfo.InvariantCulture,
|
||||
DateTimeStyles.None,
|
||||
out var localDate))
|
||||
{
|
||||
return localDate.ToUniversalTime();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,8 +227,7 @@ public override void Parse(XElement element)
|
|||
var shelfName = shelfElement?.Attribute("name")?.Value;
|
||||
var shelfCountValue = shelfElement?.Attribute("count")?.Value;
|
||||
|
||||
int shelfCount = 0;
|
||||
int.TryParse(shelfCountValue, out shelfCount);
|
||||
int.TryParse(shelfCountValue, out var shelfCount);
|
||||
return new KeyValuePair<string, int>(shelfName, shelfCount);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -144,9 +144,8 @@ public override void Parse(XElement element)
|
|||
|
||||
foreach (var rating in ratings)
|
||||
{
|
||||
int star = 0, count = 0;
|
||||
int.TryParse(rating[0], out star);
|
||||
int.TryParse(rating[1], out count);
|
||||
int.TryParse(rating[0], out var star);
|
||||
int.TryParse(rating[1], out var count);
|
||||
|
||||
ratingDistribution.Add(star, count);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,14 +152,13 @@ public ValidationFailure Test(PushBulletSettings settings)
|
|||
private HttpRequestBuilder BuildDeviceRequest(string deviceId)
|
||||
{
|
||||
var requestBuilder = new HttpRequestBuilder(PUSH_URL).Post();
|
||||
long integerId;
|
||||
|
||||
if (deviceId.IsNullOrWhiteSpace())
|
||||
{
|
||||
return requestBuilder;
|
||||
}
|
||||
|
||||
if (long.TryParse(deviceId, out integerId))
|
||||
if (long.TryParse(deviceId, out var integerId))
|
||||
{
|
||||
requestBuilder.AddFormParameter("device_id", integerId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -647,9 +647,8 @@ public static string ParseReleaseGroup(string title)
|
|||
if (matches.Count != 0)
|
||||
{
|
||||
var group = matches.OfType<Match>().Last().Groups["releasegroup"].Value;
|
||||
int groupIsNumeric;
|
||||
|
||||
if (int.TryParse(group, out groupIsNumeric))
|
||||
if (int.TryParse(group, out _))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
@ -792,8 +791,7 @@ private static ParsedBookInfo ParseBookMatchCollection(MatchCollection matchColl
|
|||
bookTitle = RequestInfoRegex.Replace(bookTitle, "").Trim(' ');
|
||||
releaseVersion = RequestInfoRegex.Replace(releaseVersion, "").Trim(' ');
|
||||
|
||||
int releaseYear;
|
||||
int.TryParse(matchCollection[0].Groups["releaseyear"].Value, out releaseYear);
|
||||
int.TryParse(matchCollection[0].Groups["releaseyear"].Value, out var releaseYear);
|
||||
|
||||
ParsedBookInfo result;
|
||||
|
||||
|
|
@ -810,10 +808,8 @@ private static ParsedBookInfo ParseBookMatchCollection(MatchCollection matchColl
|
|||
|
||||
if (matchCollection[0].Groups["discography"].Success)
|
||||
{
|
||||
int discStart;
|
||||
int discEnd;
|
||||
int.TryParse(matchCollection[0].Groups["startyear"].Value, out discStart);
|
||||
int.TryParse(matchCollection[0].Groups["endyear"].Value, out discEnd);
|
||||
int.TryParse(matchCollection[0].Groups["startyear"].Value, out var discStart);
|
||||
int.TryParse(matchCollection[0].Groups["endyear"].Value, out var discEnd);
|
||||
result.Discography = true;
|
||||
|
||||
if (discStart > 0 && discEnd > 0)
|
||||
|
|
@ -891,9 +887,7 @@ private static string GetReleaseHash(MatchCollection matchCollection)
|
|||
|
||||
private static int ParseNumber(string value)
|
||||
{
|
||||
int number;
|
||||
|
||||
if (int.TryParse(value, out number))
|
||||
if (int.TryParse(value, out var number))
|
||||
{
|
||||
return number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using NzbDrone.Common.Cache;
|
||||
using NzbDrone.Core.Profiles.Releases.TermMatchers;
|
||||
|
||||
|
|
@ -37,8 +36,7 @@ public ITermMatcher GetMatcher(string term)
|
|||
|
||||
private ITermMatcher CreateMatcherInternal(string term)
|
||||
{
|
||||
Regex regex;
|
||||
if (PerlRegexFactory.TryCreateRegex(term, out regex))
|
||||
if (PerlRegexFactory.TryCreateRegex(term, out var regex))
|
||||
{
|
||||
return new RegexTermMatcher(regex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,7 @@ protected override void SetWritePermissions(string path, bool writable)
|
|||
protected void SetWritePermissionsInternal(string path, bool writable, bool setgid)
|
||||
{
|
||||
// Remove Write permissions, we're still owner so we can clean it up, but we'll have to do that explicitly.
|
||||
Stat stat;
|
||||
Syscall.stat(path, out stat);
|
||||
Syscall.stat(path, out var stat);
|
||||
FilePermissions mode = stat.st_mode;
|
||||
|
||||
if (writable)
|
||||
|
|
|
|||
|
|
@ -489,9 +489,7 @@ private uint GetUserId(string user)
|
|||
return UNCHANGED_ID;
|
||||
}
|
||||
|
||||
uint userId;
|
||||
|
||||
if (uint.TryParse(user, out userId))
|
||||
if (uint.TryParse(user, out var userId))
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
|
|
@ -513,9 +511,7 @@ private uint GetGroupId(string group)
|
|||
return UNCHANGED_ID;
|
||||
}
|
||||
|
||||
uint groupId;
|
||||
|
||||
if (uint.TryParse(group, out groupId))
|
||||
if (uint.TryParse(group, out var groupId))
|
||||
{
|
||||
return groupId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,9 +83,7 @@ private static void GetPathComponents(string path, out string[] components, out
|
|||
|
||||
private bool TryFollowFirstSymbolicLink(ref string path)
|
||||
{
|
||||
string[] dirs;
|
||||
int lastIndex;
|
||||
GetPathComponents(path, out dirs, out lastIndex);
|
||||
GetPathComponents(path, out var dirs, out var lastIndex);
|
||||
|
||||
if (lastIndex == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ protected static void InitLogging()
|
|||
{
|
||||
LogManager.Configuration = new LoggingConfiguration();
|
||||
|
||||
var logOutput = TestLogOutput.Console;
|
||||
Enum.TryParse<TestLogOutput>(Environment.GetEnvironmentVariable("READARR_TESTS_LOG_OUTPUT"), out logOutput);
|
||||
Enum.TryParse<TestLogOutput>(Environment.GetEnvironmentVariable("READARR_TESTS_LOG_OUTPUT"), out var logOutput);
|
||||
|
||||
RegisterSentryLogger();
|
||||
|
||||
|
|
|
|||
|
|
@ -100,8 +100,7 @@ private UpdateStartupContext ParseArgs(string[] args)
|
|||
|
||||
private int ParseProcessId(string arg)
|
||||
{
|
||||
int id;
|
||||
if (!int.TryParse(arg, out id) || id <= 0)
|
||||
if (!int.TryParse(arg, out var id) || id <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arg), "Invalid process ID");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,8 +87,7 @@ public override void SetEveryonePermissions(string filename)
|
|||
PropagationFlags.InheritOnly,
|
||||
controlType);
|
||||
|
||||
bool modified;
|
||||
directorySecurity.ModifyAccessRule(AccessControlModification.Add, accessRule, out modified);
|
||||
directorySecurity.ModifyAccessRule(AccessControlModification.Add, accessRule, out var modified);
|
||||
|
||||
if (modified)
|
||||
{
|
||||
|
|
@ -137,11 +136,7 @@ private static long DriveFreeSpaceEx(string folderName)
|
|||
folderName += '\\';
|
||||
}
|
||||
|
||||
ulong free = 0;
|
||||
ulong dummy1 = 0;
|
||||
ulong dummy2 = 0;
|
||||
|
||||
if (GetDiskFreeSpaceEx(folderName, out free, out dummy1, out dummy2))
|
||||
if (GetDiskFreeSpaceEx(folderName, out var free, out var dummy1, out var dummy2))
|
||||
{
|
||||
return (long)free;
|
||||
}
|
||||
|
|
@ -158,11 +153,7 @@ private static long DriveTotalSizeEx(string folderName)
|
|||
folderName += '\\';
|
||||
}
|
||||
|
||||
ulong total = 0;
|
||||
ulong dummy1 = 0;
|
||||
ulong dummy2 = 0;
|
||||
|
||||
if (GetDiskFreeSpaceEx(folderName, out dummy1, out total, out dummy2))
|
||||
if (GetDiskFreeSpaceEx(folderName, out var dummy1, out var total, out var dummy2))
|
||||
{
|
||||
return (long)total;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,8 +66,7 @@ public static FieldMapping[] GetFieldMappings(Type type)
|
|||
{
|
||||
lock (_mappings)
|
||||
{
|
||||
FieldMapping[] result;
|
||||
if (!_mappings.TryGetValue(type, out result))
|
||||
if (!_mappings.TryGetValue(type, out var result))
|
||||
{
|
||||
result = GetFieldMapping(type, "", v => v);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue