Use 'var' instead of explicit type

(cherry picked from commit 12374f7f0038e5b25548f5ab3f71122410832393)

Closes #2559
pull/2572/head
Bogdan 12 months ago
parent 89dd4d3271
commit d1aff31593

@ -68,7 +68,7 @@ namespace NzbDrone.Automation.Test
{
try
{
Screenshot image = ((ITakesScreenshot)driver).GetScreenshot();
var image = ((ITakesScreenshot)driver).GetScreenshot();
image.SaveAsFile($"./{name}_test_screenshot.png", ScreenshotImageFormat.Png);
}
catch (Exception ex)

@ -37,7 +37,7 @@ namespace NzbDrone.Automation.Test.PageModel
{
try
{
IWebElement element = d.FindElement(By.ClassName("followingBalls"));
var element = d.FindElement(By.ClassName("followingBalls"));
return !element.Displayed;
}
catch (NoSuchElementException)

@ -65,9 +65,9 @@ namespace NzbDrone.Common.Test.CacheTests
[Test]
public void should_store_null()
{
int hitCount = 0;
var hitCount = 0;
for (int i = 0; i < 10; i++)
for (var i = 0; i < 10; i++)
{
_cachedString.Get("key", () =>
{
@ -83,10 +83,10 @@ namespace NzbDrone.Common.Test.CacheTests
[Platform(Exclude = "MacOsX")]
public void should_honor_ttl()
{
int hitCount = 0;
var hitCount = 0;
_cachedString = new Cached<string>();
for (int i = 0; i < 10; i++)
for (var i = 0; i < 10; i++)
{
_cachedString.Get("key",
() =>
@ -107,10 +107,10 @@ namespace NzbDrone.Common.Test.CacheTests
[Platform(Exclude = "MacOsX")]
public void should_clear_expired_when_they_expire()
{
int hitCount = 0;
var hitCount = 0;
_cachedString = new Cached<string>(rollingExpiry: true);
for (int i = 0; i < 10; i++)
for (var i = 0; i < 10; i++)
{
_cachedString.Get("key",
() =>

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using FluentAssertions;
using Moq;
using NUnit.Framework;
@ -142,7 +142,7 @@ namespace NzbDrone.Common.Test
[Test]
public void SaveDictionary_should_save_proper_value()
{
int port = 20555;
var port = 20555;
var dic = Subject.GetConfigDictionary();
dic["Port"] = 20555;
@ -155,9 +155,9 @@ namespace NzbDrone.Common.Test
[Test]
public void SaveDictionary_should_only_save_specified_values()
{
int port = 20555;
int origSslPort = 20551;
int sslPort = 20552;
var port = 20555;
var origSslPort = 20551;
var sslPort = 20552;
var dic = Subject.GetConfigDictionary();
dic["Port"] = port;

@ -43,7 +43,7 @@ namespace NzbDrone.Common.Test.DiskTests
[Test]
public void should_not_contain_recycling_bin_for_root_of_drive()
{
string root = @"C:\".AsOsAgnostic();
var root = @"C:\".AsOsAgnostic();
SetupFolders(root);
Mocker.GetMock<IDiskProvider>()
@ -56,7 +56,7 @@ namespace NzbDrone.Common.Test.DiskTests
[Test]
public void should_not_contain_system_volume_information()
{
string root = @"C:\".AsOsAgnostic();
var root = @"C:\".AsOsAgnostic();
SetupFolders(root);
Mocker.GetMock<IDiskProvider>()
@ -69,7 +69,7 @@ namespace NzbDrone.Common.Test.DiskTests
[Test]
public void should_not_contain_recycling_bin_or_system_volume_information_for_root_of_drive()
{
string root = @"C:\".AsOsAgnostic();
var root = @"C:\".AsOsAgnostic();
SetupFolders(root);
Mocker.GetMock<IDiskProvider>()

@ -791,7 +791,7 @@ namespace NzbDrone.Common.Test.Http
try
{
// the date is bad in the below - should be 13-Jul-2026
string malformedCookie = @"__cfduid=d29e686a9d65800021c66faca0a29b4261436890790; expires=Mon, 13-Jul-26 16:19:50 GMT; path=/; HttpOnly";
var malformedCookie = @"__cfduid=d29e686a9d65800021c66faca0a29b4261436890790; expires=Mon, 13-Jul-26 16:19:50 GMT; path=/; HttpOnly";
var requestSet = new HttpRequestBuilder($"https://{_httpBinHost}/response-headers")
.AddQueryParam("Set-Cookie", malformedCookie)
.Build();
@ -825,7 +825,7 @@ namespace NzbDrone.Common.Test.Http
{
try
{
string url = $"https://{_httpBinHost}/response-headers?Set-Cookie={Uri.EscapeDataString(malformedCookie)}";
var url = $"https://{_httpBinHost}/response-headers?Set-Cookie={Uri.EscapeDataString(malformedCookie)}";
var requestSet = new HttpRequest(url);
requestSet.AllowAutoRedirect = false;

@ -74,17 +74,17 @@ namespace NzbDrone.Common
continue; // Ignore directories
}
string entryFileName = zipEntry.Name;
var entryFileName = zipEntry.Name;
// to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName);
// Optionally match entrynames against a selection list here to skip as desired.
// The unpacked length is available in the zipEntry.Size property.
byte[] buffer = new byte[4096]; // 4K is optimum
Stream zipStream = zipFile.GetInputStream(zipEntry);
var buffer = new byte[4096]; // 4K is optimum
var zipStream = zipFile.GetInputStream(zipEntry);
// Manipulate the output filename here as desired.
string fullZipToPath = Path.Combine(destination, entryFileName);
string directoryName = Path.GetDirectoryName(fullZipToPath);
var fullZipToPath = Path.Combine(destination, entryFileName);
var directoryName = Path.GetDirectoryName(fullZipToPath);
if (directoryName.Length > 0)
{
Directory.CreateDirectory(directoryName);
@ -93,7 +93,7 @@ namespace NzbDrone.Common
// Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size
// of the file, but does not waste memory.
// The "using" will close the stream even if an exception occurs.
using (FileStream streamWriter = File.Create(fullZipToPath))
using (var streamWriter = File.Create(fullZipToPath))
{
StreamUtils.Copy(zipStream, streamWriter, buffer);
}
@ -106,7 +106,7 @@ namespace NzbDrone.Common
Stream inStream = File.OpenRead(compressedFile);
Stream gzipStream = new GZipInputStream(inStream);
TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream, null);
var tarArchive = TarArchive.CreateInputTarArchive(gzipStream, null);
tarArchive.ExtractContents(destination);
tarArchive.Close();

@ -1,4 +1,4 @@
namespace NzbDrone.Common
namespace NzbDrone.Common
{
public static class ConvertBase32
{
@ -6,17 +6,17 @@
public static byte[] FromBase32String(string str)
{
int numBytes = str.Length * 5 / 8;
byte[] bytes = new byte[numBytes];
var numBytes = str.Length * 5 / 8;
var bytes = new byte[numBytes];
// all UPPERCASE chars
str = str.ToUpper();
int bitBuffer = 0;
int bitBufferCount = 0;
int index = 0;
var bitBuffer = 0;
var bitBufferCount = 0;
var index = 0;
for (int i = 0; i < str.Length; i++)
for (var i = 0; i < str.Length; i++)
{
bitBuffer = (bitBuffer << 5) | ValidChars.IndexOf(str[i]);
bitBufferCount += 5;

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using NzbDrone.Common.Extensions;
@ -255,7 +255,7 @@ namespace NzbDrone.Common.Disk
var stringComparison = (Kind == OsPathKind.Windows || other.Kind == OsPathKind.Windows) ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture;
for (int i = 0; i < leftFragments.Length; i++)
for (var i = 0; i < leftFragments.Length; i++)
{
if (!string.Equals(leftFragments[i], rightFragments[i], stringComparison))
{
@ -372,12 +372,12 @@ namespace NzbDrone.Common.Disk
var newFragments = new List<string>();
for (int j = i; j < rightFragments.Length; j++)
for (var j = i; j < rightFragments.Length; j++)
{
newFragments.Add("..");
}
for (int j = i; j < leftFragments.Length; j++)
for (var j = i; j < leftFragments.Length; j++)
{
newFragments.Add(leftFragments[j]);
}

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@ -107,7 +107,7 @@ namespace NzbDrone.Common.EnvironmentInfo
private static string RunAndCapture(string filename, string args)
{
Process p = new Process();
var p = new Process();
p.StartInfo.FileName = filename;
p.StartInfo.Arguments = args;
p.StartInfo.UseShellExecute = false;
@ -117,7 +117,7 @@ namespace NzbDrone.Common.EnvironmentInfo
p.Start();
// To avoid deadlocks, always read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
var output = p.StandardOutput.ReadToEnd();
p.WaitForExit(1000);
return output;

@ -136,7 +136,7 @@ namespace NzbDrone.Common.Extensions
for (var j = finish; j >= start; j--)
{
T charMatch = charMatches[j - 1];
var charMatch = charMatches[j - 1];
if (d == 0)
{
@ -181,7 +181,7 @@ namespace NzbDrone.Common.Extensions
// match. But check anyway.
var score = BitapScore(d, pattern);
bool isOnWordBoundary = true;
var isOnWordBoundary = true;
if (wordDelimiters != null)
{
@ -233,8 +233,8 @@ namespace NzbDrone.Common.Extensions
return new List<char>();
}
char curr = text[j - 1];
bool take = true;
var curr = text[j - 1];
var take = true;
if (!s.TryGetValue(curr, out var charMatch))
{

@ -255,13 +255,13 @@ namespace NzbDrone.Common.Extensions
var firstPath = paths.First();
var length = firstPath.Length;
for (int i = 1; i < paths.Count; i++)
for (var i = 1; i < paths.Count; i++)
{
var path = paths[i];
length = Math.Min(length, path.Length);
for (int characterIndex = 0; characterIndex < length; characterIndex++)
for (var characterIndex = 0; characterIndex < length; characterIndex++)
{
if (path[characterIndex] != firstPath[characterIndex])
{

@ -188,11 +188,11 @@ namespace NzbDrone.Common.Extensions
{
double weightDenom = Math.Max(a.Length, b.Length);
double sum = 0;
for (int i = 0; i < a.Length; i++)
for (var i = 0; i < a.Length; i++)
{
double high = 0.0;
int indexDistance = 0;
for (int x = 0; x < b.Length; x++)
var high = 0.0;
var indexDistance = 0;
for (var x = 0; x < b.Length; x++)
{
var coef = LevenshteinCoefficient(a[i], b[x]);
if (coef > high)

@ -1,4 +1,4 @@
using System;
using System;
using System.Text;
namespace NzbDrone.Common
@ -7,9 +7,9 @@ namespace NzbDrone.Common
{
public static string CalculateCrc(string input)
{
uint mCrc = 0xffffffff;
byte[] bytes = Encoding.UTF8.GetBytes(input);
foreach (byte myByte in bytes)
var mCrc = 0xffffffff;
var bytes = Encoding.UTF8.GetBytes(input);
foreach (var myByte in bytes)
{
mCrc ^= (uint)myByte << 24;
for (var i = 0; i < 8; i++)

@ -22,7 +22,7 @@ namespace NzbDrone.Common.Http
public HttpUri(string scheme, string host, int? port, string path, string query, string fragment)
{
StringBuilder builder = new StringBuilder();
var builder = new StringBuilder();
if (scheme.IsNotNullOrWhiteSpace())
{

@ -1,4 +1,4 @@
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Common.Http.Proxy
{
@ -30,7 +30,7 @@ namespace NzbDrone.Common.Http.Proxy
if (!string.IsNullOrWhiteSpace(BypassFilter))
{
var hostlist = BypassFilter.Split(',');
for (int i = 0; i < hostlist.Length; i++)
for (var i = 0; i < hostlist.Length; i++)
{
if (hostlist[i].StartsWith("*"))
{

@ -1,4 +1,4 @@
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq;
using NzbDrone.Common.Serializer;
namespace NzbDrone.Common.Instrumentation
@ -16,7 +16,7 @@ namespace NzbDrone.Common.Instrumentation
}
}
foreach (JToken token in json)
foreach (var token in json)
{
Visit(token);
}

@ -94,7 +94,7 @@ namespace NzbDrone.Common.Instrumentation
private static void RegisterDebugger()
{
DebuggerTarget target = new DebuggerTarget();
var target = new DebuggerTarget();
target.Name = "debuggerLogger";
target.Layout = "[${level}] [${threadid}] ${logger}: ${message} ${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}${exception:format=Data}${newline}}";

@ -1,4 +1,4 @@
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq;
namespace NzbDrone.Common.Serializer
{
@ -60,7 +60,7 @@ namespace NzbDrone.Common.Serializer
public virtual void Visit(JArray json)
{
foreach (JToken token in json)
foreach (var token in json)
{
Visit(token);
}
@ -72,7 +72,7 @@ namespace NzbDrone.Common.Serializer
public virtual void Visit(JObject json)
{
foreach (JProperty property in json.Properties())
foreach (var property in json.Properties())
{
Visit(property);
}

@ -42,7 +42,7 @@ namespace NzbDrone.Common.Serializer
var enumText = value.ToString();
var builder = new StringBuilder(enumText.Length + 4);
builder.Append(char.ToLower(enumText[0]));
for (int i = 1; i < enumText.Length; i++)
for (var i = 1; i < enumText.Length; i++)
{
if (char.IsUpper(enumText[i]))
{

@ -18,7 +18,7 @@ namespace NzbDrone.Common.Serializer
{
try
{
Version v = new Version(reader.GetString());
var v = new Version(reader.GetString());
return v;
}
catch (Exception)

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@ -137,7 +137,7 @@ namespace NzbDrone.Common.TPL
/// <returns>An enumerable of the tasks currently scheduled.</returns>
protected sealed override IEnumerable<Task> GetScheduledTasks()
{
bool lockTaken = false;
var lockTaken = false;
try
{
Monitor.TryEnter(_tasks, ref lockTaken);

@ -110,7 +110,7 @@ namespace NzbDrone.Console
}
System.Console.WriteLine("Non-recoverable failure, waiting for user intervention...");
for (int i = 0; i < 3600; i++)
for (var i = 0; i < 3600; i++)
{
System.Threading.Thread.Sleep(1000);

@ -197,7 +197,7 @@ namespace NzbDrone.Core.Test.Datastore
Subject.SetFields(_basicList, x => x.Interval);
for (int i = 0; i < _basicList.Count; i++)
for (var i = 0; i < _basicList.Count; i++)
{
_basicList[i].LastExecution = executionBackup[i];
}

@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void should_return_true_if_cutoffs_are_met_but_is_a_revision_upgrade()
{
QualityProfile profile = new QualityProfile
var profile = new QualityProfile
{
Cutoff = Quality.MP3.Id,
Items = Qualities.QualityFixture.GetDefaultQualities(),
@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void should_return_false_if_quality_profile_does_not_allow_upgrades_but_cutoff_is_set_to_highest_quality()
{
QualityProfile profile = new QualityProfile
var profile = new QualityProfile
{
Cutoff = Quality.FLAC.Id,
Items = Qualities.QualityFixture.GetDefaultQualities(),

@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
VerifySingleItem(DownloadItemStatus.Downloading);
// If we keep changing the file every 20ms we should stay Downloading.
for (int i = 0; i < 10; i++)
for (var i = 0; i < 10; i++)
{
TestLogger.Info("Iteration {0}", i);

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using FluentAssertions;
@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test
[Test]
public void ToBestDateTime_DayOfWeek()
{
for (int i = 2; i < 7; i++)
for (var i = 2; i < 7; i++)
{
var dateTime = DateTime.Today.AddDays(i);

@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
[Test]
public void should_return_ok_if_not_downloading_to_root_folder()
{
string rootFolderPath = "c:\\Test2".AsOsAgnostic();
var rootFolderPath = "c:\\Test2".AsOsAgnostic();
GivenRootFolder(rootFolderPath);

@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.Instrumentation
public void write_long_log()
{
var message = string.Empty;
for (int i = 0; i < 100; i++)
for (var i = 0; i < 100; i++)
{
message += Guid.NewGuid();
}

@ -100,7 +100,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Aggregation.Aggregators
{
get
{
int i = 0;
var i = 0;
foreach (var tokens in tokenList)
{
@ -128,7 +128,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Aggregation.Aggregators
private List<string> GivenFilenames(string[] fields, string fieldSeparator, string whitespace)
{
var outp = new List<string>();
for (int i = 1; i <= 3; i++)
for (var i = 1; i <= 3; i++)
{
var components = new List<string>();
foreach (var field in fields)
@ -161,7 +161,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Aggregation.Aggregators
private void VerifyDataAuto(List<LocalBook> tracks, string[] tokens, string whitespace)
{
for (int i = 1; i <= tracks.Count; i++)
for (var i = 1; i <= tracks.Count; i++)
{
var info = tracks[i - 1].FileTrackInfo;

@ -71,7 +71,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification
Mocker.SetConstant<ICandidateService>(Mocker.Resolve<CandidateService>());
// set up the augmenters
List<IAggregate<LocalEdition>> aggregators = new List<IAggregate<LocalEdition>>
var aggregators = new List<IAggregate<LocalEdition>>
{
Mocker.Resolve<AggregateFilenameInfo>()
};
@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification
private List<Author> GivenAuthors(List<AuthorTestCase> authors)
{
var outp = new List<Author>();
for (int i = 0; i < authors.Count; i++)
for (var i = 0; i < authors.Count; i++)
{
var meta = authors[i].MetadataProfile;
meta.Id = i + 1;

@ -30,17 +30,17 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification
static RandomValueNamerShortStrings()
{
AllowedChars = new List<char>();
for (char c = 'a'; c < 'z'; c++)
for (var c = 'a'; c < 'z'; c++)
{
AllowedChars.Add(c);
}
for (char c = 'A'; c < 'Z'; c++)
for (var c = 'A'; c < 'Z'; c++)
{
AllowedChars.Add(c);
}
for (char c = '0'; c < '9'; c++)
for (var c = '0'; c < '9'; c++)
{
AllowedChars.Add(c);
}
@ -48,17 +48,17 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification
protected override string GetString(MemberInfo memberInfo)
{
int length = _generator.Next(1, 100);
var length = _generator.Next(1, 100);
char[] chars = new char[length];
var chars = new char[length];
for (int i = 0; i < length; i++)
for (var i = 0; i < length; i++)
{
int index = _generator.Next(0, AllowedChars.Count - 1);
var index = _generator.Next(0, AllowedChars.Count - 1);
chars[i] = AllowedChars[index];
}
byte[] bytes = Encoding.UTF8.GetBytes(chars);
var bytes = Encoding.UTF8.GetBytes(chars);
return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
}
}
@ -90,7 +90,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification
{
var outp = new List<LocalBook>();
for (int i = 0; i < count; i++)
for (var i = 0; i < count; i++)
{
var track = Builder<LocalBook>
.CreateNew()
@ -283,7 +283,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification
public void should_separate_many_books_in_same_directory()
{
var tracks = new List<LocalBook>();
for (int i = 0; i < 100; i++)
for (var i = 0; i < 100; i++)
{
tracks.AddRange(GivenTracks($"C:\\music".AsOsAgnostic(), "author" + i, "book" + i, 10));
}

@ -14,8 +14,8 @@ namespace NzbDrone.Core.Test.MetadataSource.Goodreads.Resources
[Test]
public void parse_non_work()
{
XElement element = new XElement("Dummy", "entry");
WorkResource work = new WorkResource();
var element = new XElement("Dummy", "entry");
var work = new WorkResource();
Assert.Throws<NullReferenceException>(() => work.Parse(element));
@ -27,11 +27,11 @@ namespace NzbDrone.Core.Test.MetadataSource.Goodreads.Resources
[Test]
public void parse_minimal_work()
{
XElement element = new XElement("work",
var element = new XElement("work",
new XElement("original_title", "Book Title"),
new XElement("id", "123456789"));
WorkResource work = new WorkResource();
var work = new WorkResource();
work.Parse(element);
@ -44,12 +44,12 @@ namespace NzbDrone.Core.Test.MetadataSource.Goodreads.Resources
[Test]
public void parse_minimal_work_with_surrounding_tags()
{
XElement element = new XElement("series_works",
var element = new XElement("series_works",
new XElement("work",
new XElement("original_title", "Book Title"),
new XElement("id", "123456789")));
WorkResource work = new WorkResource();
var work = new WorkResource();
work.Parse(element);

@ -115,7 +115,7 @@ namespace NzbDrone.Core.Test.MusicTests.AuthorRepositoryTests
{
GivenAuthors();
string name = "Alice Cooper";
var name = "Alice Cooper";
AddAuthor(name, "ee58c59f-8e7f-4430-b8ca-236c4d3745ae");
AddAuthor(name, "4d7928cd-7ed2-4282-8c29-c0c9f966f1bd");

@ -39,13 +39,13 @@ namespace NzbDrone.Core.Test.ParserTests
[Test]
public void should_not_parse_md5()
{
string hash = "CRAPPY TEST SEED";
var hash = "CRAPPY TEST SEED";
var hashAlgo = System.Security.Cryptography.MD5.Create();
var repetitions = 100;
var success = 0;
for (int i = 0; i < repetitions; i++)
for (var i = 0; i < repetitions; i++)
{
var hashData = hashAlgo.ComputeHash(System.Text.Encoding.Default.GetBytes(hash));
@ -64,17 +64,17 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase(40)]
public void should_not_parse_random(int length)
{
string charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var hashAlgo = new Random();
var repetitions = 500;
var success = 0;
for (int i = 0; i < repetitions; i++)
for (var i = 0; i < repetitions; i++)
{
StringBuilder hash = new StringBuilder(length);
var hash = new StringBuilder(length);
for (int x = 0; x < length; x++)
for (var x = 0; x < length; x++)
{
hash.Append(charset[hashAlgo.Next() % charset.Length]);
}

@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.Profiles.Delay
var moving = _last;
var result = Subject.Reorder(moving.Id, null).OrderBy(d => d.Order).ToList();
for (int i = 1; i < result.Count; i++)
for (var i = 1; i < result.Count; i++)
{
var delayProfile = result[i];

@ -32,7 +32,7 @@ namespace NzbDrone.Core.Books
var existingMetadata = FindById(data.Select(x => x.ForeignAuthorId).ToList());
var updateMetadataList = new List<AuthorMetadata>();
var addMetadataList = new List<AuthorMetadata>();
int upToDateMetadataCount = 0;
var upToDateMetadataCount = 0;
foreach (var meta in data)
{

@ -132,7 +132,7 @@ namespace NzbDrone.Core.Books
if (_authorService.AuthorPathExists(path))
{
var basepath = path;
int i = 0;
var i = 0;
do
{
i++;

@ -140,7 +140,7 @@ namespace NzbDrone.Core.Configuration
{
const string defaultValue = "*";
string bindAddress = GetValue("BindAddress", defaultValue);
var bindAddress = GetValue("BindAddress", defaultValue);
if (string.IsNullOrWhiteSpace(bindAddress))
{
return defaultValue;

@ -215,7 +215,7 @@ namespace NzbDrone.Core.Datastore
using (var conn = _database.OpenConnection())
{
using (IDbTransaction tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
using (var tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
{
foreach (var model in models)
{

@ -18,7 +18,7 @@ namespace NzbDrone.Core.Datastore.Converters
}
string contract;
using (JsonDocument body = JsonDocument.Parse(stringValue))
using (var body = JsonDocument.Parse(stringValue))
{
contract = body.RootElement.GetProperty("name").GetString();
}

@ -17,7 +17,7 @@ namespace NzbDrone.Core.Datastore.Migration
private void ConvertFileChmodToFolderChmod(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand getFileChmodCmd = conn.CreateCommand())
using (var getFileChmodCmd = conn.CreateCommand())
{
getFileChmodCmd.Transaction = tran;
getFileChmodCmd.CommandText = @"SELECT ""Value"" FROM ""Config"" WHERE ""Key"" = 'filechmod'";
@ -32,7 +32,7 @@ namespace NzbDrone.Core.Datastore.Migration
var folderChmodNum = fileChmodNum | ((fileChmodNum & 0x124) >> 2);
var folderChmod = Convert.ToString(folderChmodNum, 8).PadLeft(3, '0');
using (IDbCommand insertCmd = conn.CreateCommand())
using (var insertCmd = conn.CreateCommand())
{
insertCmd.Transaction = tran;
insertCmd.CommandText = "INSERT INTO \"Config\" (\"Key\", \"Value\") VALUES ('chmodfolder', ?)";
@ -42,7 +42,7 @@ namespace NzbDrone.Core.Datastore.Migration
}
}
using (IDbCommand deleteCmd = conn.CreateCommand())
using (var deleteCmd = conn.CreateCommand())
{
deleteCmd.Transaction = tran;
deleteCmd.CommandText = "DELETE FROM \"Config\" WHERE \"Key\" = 'filechmod'";

@ -231,11 +231,11 @@ namespace NzbDrone.Core.Datastore.Migration
{
var updatedNamingConfigs = new List<object>();
using (IDbCommand namingConfigCmd = conn.CreateCommand())
using (var namingConfigCmd = conn.CreateCommand())
{
namingConfigCmd.Transaction = tran;
namingConfigCmd.CommandText = @"SELECT * FROM ""NamingConfig"" LIMIT 1";
using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader())
using (var namingConfigReader = namingConfigCmd.ExecuteReader())
{
var standardBookFormatIndex = namingConfigReader.GetOrdinal("StandardBookFormat");

@ -201,7 +201,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
public virtual IList<TableDefinition> ReadDbSchema()
{
IList<TableDefinition> tables = ReadTables();
var tables = ReadTables();
foreach (var table in tables)
{
table.Indexes = ReadIndexes(table.SchemaName, table.Name);
@ -270,7 +270,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
protected virtual IList<IndexDefinition> ReadIndexes(string schemaName, string tableName)
{
var sqlCommand = string.Format(@"SELECT type, name, sql FROM sqlite_master WHERE tbl_name = '{0}' AND type = 'index' AND name NOT LIKE 'sqlite_auto%';", tableName);
DataTable table = Read(sqlCommand).Tables[0];
var table = Read(sqlCommand).Tables[0];
IList<IndexDefinition> indexes = new List<IndexDefinition>();

@ -202,7 +202,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
private JsonRpcRequestBuilder BuildRequest(DelugeSettings settings)
{
string url = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, settings.UrlBase);
var url = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, settings.UrlBase);
var requestBuilder = new JsonRpcRequestBuilder(url);
requestBuilder.LogResponseContent = true;

@ -63,7 +63,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
var items = new List<DownloadClientItem>();
long totalRemainingSize = 0;
long globalSpeed = nzbTasks.Where(t => t.Status == DownloadStationTaskStatus.Downloading)
var globalSpeed = nzbTasks.Where(t => t.Status == DownloadStationTaskStatus.Downloading)
.Select(GetDownloadSpeed)
.Sum();

@ -223,7 +223,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
protected IEnumerable<NzbgetCategory> GetCategories(Dictionary<string, string> config)
{
for (int i = 1; i < 100; i++)
for (var i = 1; i < 100; i++)
{
var name = config.GetValueOrDefault("Category" + i + ".Name");

@ -496,7 +496,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
return null;
}
Dictionary<string, QBittorrentLabel> labels = Proxy.GetLabels(Settings);
var labels = Proxy.GetLabels(Settings);
if (Settings.MusicCategory.IsNotNullOrWhiteSpace() && !labels.ContainsKey(Settings.MusicCategory))
{

@ -14,7 +14,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters
var stringArray = (string[])value;
writer.WriteStartArray();
for (int i = 0; i < stringArray.Length; i++)
for (var i = 0; i < stringArray.Length; i++)
{
writer.WriteValue(stringArray[i]);
}

@ -124,7 +124,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
_logger.Debug("Retrieved metadata of {0} torrents in client", torrents.Count);
var items = new List<DownloadClientItem>();
foreach (RTorrentTorrent torrent in torrents)
foreach (var torrent in torrents)
{
// Don't concern ourselves with categories other than specified
if (Settings.MusicCategory.IsNotNullOrWhiteSpace() && torrent.Category != Settings.MusicCategory)

@ -215,7 +215,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
{
var config = _proxy.GetConfig(Settings);
OsPath destDir = new OsPath(null);
var destDir = new OsPath(null);
if (config.GetValueOrDefault("dir_active_download_flag") == "true")
{

@ -32,13 +32,13 @@ namespace NzbDrone.Core.Download.Extensions
public static long ElementAsLong(this XElement element, XName name)
{
var el = element.Element(name);
return long.TryParse(el?.Value, out long value) ? value : default;
return long.TryParse(el?.Value, out var value) ? value : default;
}
public static int ElementAsInt(this XElement element, XName name)
{
var el = element.Element(name);
return int.TryParse(el?.Value, out int value) ? value : default(int);
return int.TryParse(el?.Value, out var value) ? value : default(int);
}
public static int GetIntResponse(this XDocument document)

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -105,17 +105,17 @@ namespace NzbDrone.Core
}
var cs = s.ToCharArray();
int length = 0;
int i = 0;
var length = 0;
var i = 0;
while (i < cs.Length)
{
int charSize = 1;
var charSize = 1;
if (i < (cs.Length - 1) && char.IsSurrogate(cs[i]))
{
charSize = 2;
}
int byteSize = Encoding.UTF8.GetByteCount(cs, i, charSize);
var byteSize = Encoding.UTF8.GetByteCount(cs, i, charSize);
if ((byteSize + length) <= maxLength)
{
i = i + charSize;

@ -53,7 +53,7 @@ namespace NzbDrone.Core.ImportLists
var pageableRequestChain = pageableRequestChainSelector(generator);
for (int i = 0; i < pageableRequestChain.Tiers; i++)
for (var i = 0; i < pageableRequestChain.Tiers; i++)
{
var pageableRequests = pageableRequestChain.GetTier(i);

@ -74,7 +74,7 @@ namespace NzbDrone.Core.IndexerSearch
if (message.AuthorId.HasValue)
{
int authorId = message.AuthorId.Value;
var authorId = message.AuthorId.Value;
var pagingSpec = new PagingSpec<Book>
{

@ -92,7 +92,7 @@ namespace NzbDrone.Core.Indexers
lastReleaseInfo = _indexerStatusService.GetLastRssSyncReleaseInfo(Definition.Id);
}
for (int i = 0; i < pageableRequestChain.Tiers; i++)
for (var i = 0; i < pageableRequestChain.Tiers; i++)
{
var pageableRequests = pageableRequestChain.GetTier(i);

@ -156,7 +156,7 @@ namespace NzbDrone.Core.Languages
return Unknown;
}
Language language = All.FirstOrDefault(v => v.Id == id);
var language = All.FirstOrDefault(v => v.Id == id);
if (language == null)
{

@ -240,7 +240,7 @@ namespace NzbDrone.Core.MediaCover
private void EnsureResizedCovers(Author author, MediaCover cover, bool forceResize, Book book = null)
{
int[] heights = GetDefaultHeights(cover.CoverType);
var heights = GetDefaultHeights(cover.CoverType);
foreach (var height in heights)
{
@ -319,7 +319,7 @@ namespace NzbDrone.Core.MediaCover
}
var split = range.Split('/');
if (split.Length == 2 && long.TryParse(split[1], out long length))
if (split.Length == 2 && long.TryParse(split[1], out var length))
{
return length;
}
@ -332,7 +332,7 @@ namespace NzbDrone.Core.MediaCover
EnsureAuthorCovers(message.Author);
var books = _bookService.GetBooksByAuthor(message.Author.Id);
foreach (Book book in books)
foreach (var book in books)
{
EnsureBookCovers(book);
}

@ -143,13 +143,13 @@ namespace NzbDrone.Core.MediaFiles
OriginalYear = OriginalReleaseDate.HasValue ? (uint)OriginalReleaseDate?.Year : 0;
foreach (ICodec codec in file.Properties.Codecs)
foreach (var codec in file.Properties.Codecs)
{
IAudioCodec acodec = codec as IAudioCodec;
var acodec = codec as IAudioCodec;
if (acodec != null && (acodec.MediaTypes & MediaTypes.Audio) != MediaTypes.None)
{
int bitrate = acodec.AudioBitrate;
var bitrate = acodec.AudioBitrate;
if (bitrate == 0)
{
// Taglib can't read bitrate for Opus.
@ -204,7 +204,7 @@ namespace NzbDrone.Core.MediaFiles
private int EstimateBitrate(TagLib.File file, string path)
{
int bitrate = 0;
var bitrate = 0;
try
{
// Taglib File.Length is unreliable so use System.IO
@ -223,22 +223,22 @@ namespace NzbDrone.Core.MediaFiles
private DateTime? ReadId3Date(TagLib.Id3v2.Tag tag, string dateTag)
{
string date = tag.GetTextAsString(dateTag);
var date = tag.GetTextAsString(dateTag);
if (tag.Version == 4)
{
// the unabused TDRC/TDOR tags
return DateTime.TryParse(date, out DateTime result) ? result : default(DateTime?);
return DateTime.TryParse(date, out var result) ? result : default(DateTime?);
}
else if (dateTag == "TDRC")
{
// taglib maps the v3 TYER and TDAT to TDRC but does it incorrectly
return DateTime.TryParseExact(date, "yyyy-dd-MM", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime result) ? result : default(DateTime?);
return DateTime.TryParseExact(date, "yyyy-dd-MM", CultureInfo.InvariantCulture, DateTimeStyles.None, out var result) ? result : default(DateTime?);
}
else
{
// taglib maps the v3 TORY to TDRC so we just get a year
return int.TryParse(date, out int year) && year >= 1860 && year <= DateTime.UtcNow.Year + 1 ? new DateTime(year, 1, 1) : default(DateTime?);
return int.TryParse(date, out var year) && year >= 1860 && year <= DateTime.UtcNow.Year + 1 ? new DateTime(year, 1, 1) : default(DateTime?);
}
}

@ -109,7 +109,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification
var diff = Math.Abs(value - target);
if (diff > 0)
{
for (int i = 0; i < diff; i++)
for (var i = 0; i < diff; i++)
{
Add(key, 1.0);
}
@ -122,7 +122,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification
private static string Clean(string input)
{
char[] arr = input.ToLower().RemoveAccent().ToCharArray();
var arr = input.ToLower().RemoveAccent().ToCharArray();
arr = Array.FindAll<char>(arr, c => char.IsLetterOrDigit(c));
@ -223,7 +223,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification
public void AddPriority<T>(string key, List<T> values, List<T> options)
where T : IEquatable<T>
{
for (int i = 0; i < options.Count; i++)
for (var i = 0; i < options.Count; i++)
{
if (values.Contains(options[i]))
{

@ -78,7 +78,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification
var releases = GetLocalBookReleases(localTracks, config.SingleRelease);
int i = 0;
var i = 0;
foreach (var localRelease in releases)
{
i++;
@ -126,7 +126,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification
private void IdentifyRelease(LocalEdition localBookRelease, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config)
{
var watch = System.Diagnostics.Stopwatch.StartNew();
bool usedRemote = false;
var usedRemote = false;
IEnumerable<CandidateEdition> candidateReleases = _candidateService.GetDbCandidatesFromTags(localBookRelease, idOverrides, config.IncludeExisting);

@ -33,7 +33,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Specifications
foreach (var workingFolder in _configService.DownloadClientWorkingFolders.Split('|'))
{
DirectoryInfo parent = Directory.GetParent(item.Path);
var parent = Directory.GetParent(item.Path);
while (parent != null)
{
if (parent.Name.StartsWith(workingFolder))

@ -1,6 +1,5 @@
using System.IO.Compression;
using System.IO.Compression;
using System.Threading.Tasks;
using VersOne.Epub.Schema;
namespace VersOne.Epub.Internal
{
@ -12,7 +11,7 @@ namespace VersOne.Epub.Internal
var rootFilePath = await RootFilePathReader.GetRootFilePathAsync(epubArchive).ConfigureAwait(false);
var contentDirectoryPath = ZipPathUtils.GetDirectoryPath(rootFilePath);
result.ContentDirectoryPath = contentDirectoryPath;
EpubPackage package = await PackageReader.ReadPackageAsync(epubArchive, rootFilePath).ConfigureAwait(false);
var package = await PackageReader.ReadPackageAsync(epubArchive, rootFilePath).ConfigureAwait(false);
result.Package = package;
return result;
}

@ -122,7 +122,7 @@ namespace NzbDrone.Core.Messaging.Commands
{
_cancellationTokenSource = new CancellationTokenSource();
for (int i = 0; i < THREAD_LIMIT; i++)
for (var i = 0; i < THREAD_LIMIT; i++)
{
var thread = new Thread(ExecuteCommands);
thread.Start();

@ -138,7 +138,7 @@ namespace NzbDrone.Core.Messaging.Commands
public CommandModel Push(string commandName, DateTime? lastExecutionTime, DateTime? lastStartTime, CommandPriority priority = CommandPriority.Normal, CommandTrigger trigger = CommandTrigger.Unspecified)
{
dynamic command = GetCommand(commandName);
var command = GetCommand(commandName);
command.LastExecutionTime = lastExecutionTime;
command.LastStartTime = lastStartTime;
command.Trigger = trigger;

@ -21,43 +21,43 @@ namespace NzbDrone.Core.MetadataSource.Goodreads
public static long ElementAsLong(this XElement element, XName name)
{
var el = element.Element(name);
return long.TryParse(el?.Value, out long value) ? value : default(long);
return long.TryParse(el?.Value, out var value) ? value : default(long);
}
public static long? ElementAsNullableLong(this XElement element, XName name)
{
var el = element.Element(name);
return long.TryParse(el?.Value, out long value) ? new long?(value) : null;
return long.TryParse(el?.Value, out var value) ? new long?(value) : null;
}
public static int ElementAsInt(this XElement element, XName name)
{
var el = element.Element(name);
return int.TryParse(el?.Value, out int value) ? value : default(int);
return int.TryParse(el?.Value, out var value) ? value : default(int);
}
public static int? ElementAsNullableInt(this XElement element, XName name)
{
var el = element.Element(name);
return int.TryParse(el?.Value, out int value) ? new int?(value) : null;
return int.TryParse(el?.Value, out var value) ? new int?(value) : null;
}
public static decimal ElementAsDecimal(this XElement element, XName name)
{
var el = element.Element(name);
return decimal.TryParse(el?.Value, out decimal value) ? value : default(decimal);
return decimal.TryParse(el?.Value, out var value) ? value : default(decimal);
}
public static decimal? ElementAsNullableDecimal(this XElement element, XName name)
{
var el = element.Element(name);
return decimal.TryParse(el?.Value, out decimal value) ? new decimal?(value) : null;
return decimal.TryParse(el?.Value, out var value) ? new decimal?(value) : null;
}
public static DateTime? ElementAsDate(this XElement element, XName name)
{
var el = element.Element(name);
return DateTime.TryParseExact(el?.Value, "yyyy/MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime date)
return DateTime.TryParseExact(el?.Value, "yyyy/MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var date)
? new DateTime?(date)
: null;
}
@ -99,7 +99,7 @@ namespace NzbDrone.Core.MetadataSource.Goodreads
public static DateTime? ElementAsMonthYear(this XElement element, XName name)
{
var el = element.Element(name);
return DateTime.TryParseExact(el?.Value, "MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime date)
return DateTime.TryParseExact(el?.Value, "MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out var date)
? new DateTime?(date)
: null;
}
@ -152,7 +152,7 @@ namespace NzbDrone.Core.MetadataSource.Goodreads
public static bool ElementAsBool(this XElement element, XName name)
{
var el = element.Element(name);
return bool.TryParse(el?.Value, out bool value) ? value : false;
return bool.TryParse(el?.Value, out var value) ? value : false;
}
public static List<T> ParseChildren<T>(this XElement element, XName parentName, XName childName)
@ -222,19 +222,19 @@ namespace NzbDrone.Core.MetadataSource.Goodreads
public static int AttributeAsInt(this XElement element, XName attributeName)
{
var attr = element.Attribute(attributeName);
return int.TryParse(attr?.Value, out int value) ? value : default(int);
return int.TryParse(attr?.Value, out var value) ? value : default(int);
}
public static long? AttributeAsNullableLong(this XElement element, XName attributeName)
{
var attr = element.Attribute(attributeName);
return long.TryParse(attr?.Value, out long value) ? new long?(value) : null;
return long.TryParse(attr?.Value, out var value) ? new long?(value) : null;
}
public static bool AttributeAsBool(this XElement element, XName attributeName)
{
var attr = element.Attribute(attributeName);
return bool.TryParse(attr?.Value, out bool value) ? value : false;
return bool.TryParse(attr?.Value, out var value) ? value : false;
}
}
}

@ -45,9 +45,9 @@ namespace NzbDrone.Core.MetadataSource.Goodreads
endAttribute != null &&
totalAttribute != null)
{
int.TryParse(startAttribute.Value, out int start);
int.TryParse(endAttribute.Value, out int end);
int.TryParse(totalAttribute.Value, out int total);
int.TryParse(startAttribute.Value, out var start);
int.TryParse(endAttribute.Value, out var end);
int.TryParse(totalAttribute.Value, out var total);
Start = start;
End = end;

@ -135,7 +135,7 @@ namespace NzbDrone.Core.Notifications.Email
{
if (MediaFileExtensions.TextExtensions.Contains(System.IO.Path.GetExtension(url)))
{
byte[] bytes = System.IO.File.ReadAllBytes(url);
var bytes = System.IO.File.ReadAllBytes(url);
builder.Attachments.Add(url, bytes);
_logger.Trace("Attaching ebook file: {0}", url);
}

@ -24,7 +24,7 @@ namespace NzbDrone.Core.Parser.Model
public override string ToString()
{
string bookString = "[Unknown Book]";
var bookString = "[Unknown Book]";
if (BookTitle != null)
{

@ -49,7 +49,7 @@ namespace NzbDrone.Core.Parser.Model
public override string ToString()
{
string trackString = "[Unknown Track]";
var trackString = "[Unknown Track]";
if (TrackNumbers != null && TrackNumbers.Any())
{

@ -716,9 +716,9 @@ namespace NzbDrone.Core.Parser
// TODO: Split into separate method and write unit tests for.
var parts = authorName.Split('.');
authorName = "";
int n = 0;
bool previousAcronym = false;
string nextPart = "";
var n = 0;
var previousAcronym = false;
var nextPart = "";
foreach (var part in parts)
{
if (parts.Length >= n + 2)

@ -253,7 +253,7 @@ namespace NzbDrone.Core.Parser
result.Revision.IsRepack = true;
}
Match versionRegexResult = VersionRegex.Match(normalizedName);
var versionRegexResult = VersionRegex.Match(normalizedName);
if (versionRegexResult.Success)
{
@ -261,7 +261,7 @@ namespace NzbDrone.Core.Parser
}
//TODO: re-enable this when we have a reliable way to determine real
MatchCollection realRegexResult = RealRegex.Matches(name);
var realRegexResult = RealRegex.Matches(name);
if (realRegexResult.Count > 0)
{

@ -53,7 +53,7 @@ namespace NzbDrone.Core.Profiles.Delay
var all = All().OrderBy(d => d.Order).ToList();
for (int i = 0; i < all.Count; i++)
for (var i = 0; i < all.Count; i++)
{
if (all[i].Id == 1)
{

@ -296,7 +296,7 @@ namespace NzbDrone.Core.Profiles.Metadata
var names = profiles.Select(x => x.Name).ToList();
int i = 1;
var i = 1;
emptyProfile.Name = $"{NONE_PROFILE_NAME}.{i}";
while (names.Contains(emptyProfile.Name))

@ -66,8 +66,8 @@ namespace NzbDrone.Core.Qualities
private void InsertMissingDefinitions()
{
List<QualityDefinition> insertList = new List<QualityDefinition>();
List<QualityDefinition> updateList = new List<QualityDefinition>();
var insertList = new List<QualityDefinition>();
var updateList = new List<QualityDefinition>();
var allDefinitions = Quality.DefaultQualityDefinitions.OrderBy(d => d.Weight).ToList();
var existingDefinitions = _repo.All().ToList();
@ -110,7 +110,7 @@ namespace NzbDrone.Core.Qualities
public void Execute(ResetQualityDefinitionsCommand message)
{
List<QualityDefinition> updateList = new List<QualityDefinition>();
var updateList = new List<QualityDefinition>();
var allDefinitions = Quality.DefaultQualityDefinitions.OrderBy(d => d.Weight).ToList();
var existingDefinitions = _repo.All().ToList();

@ -34,7 +34,7 @@ namespace NzbDrone.Core.Qualities
unchecked
{
// Overflow is fine, just wrap
int hash = 17;
var hash = 17;
hash = (hash * 23) + Revision.GetHashCode();
hash = (hash * 23) + Quality.GetHashCode();
return hash;

@ -44,7 +44,7 @@ namespace NzbDrone.Core.Qualities
public int Compare(QualityModel left, QualityModel right, bool respectGroupOrder)
{
int result = Compare(left.Quality, right.Quality, respectGroupOrder);
var result = Compare(left.Quality, right.Quality, respectGroupOrder);
if (result == 0)
{

@ -62,7 +62,7 @@ namespace NzbDrone.Core.Queue
private Queue MapQueueItem(TrackedDownload trackedDownload, Book book)
{
bool downloadForced = false;
var downloadForced = false;
var history = _historyService.Find(trackedDownload.DownloadItem.DownloadId, EntityHistoryEventType.Grabbed).FirstOrDefault();
if (history != null && history.Data.ContainsKey("downloadForced"))
{

@ -58,7 +58,7 @@ namespace NzbDrone.Mono.Test.DiskProviderTests
{
// Remove Write permissions, we're still owner so we can clean it up, but we'll have to do that explicitly.
Syscall.stat(path, out var stat);
FilePermissions mode = stat.st_mode;
var mode = stat.st_mode;
if (writable)
{

@ -28,7 +28,7 @@ namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters
var fullName = "";
var version = "";
bool success = false;
var success = false;
foreach (var releaseFile in releaseFiles)
{

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

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@ -44,10 +44,10 @@ namespace NzbDrone.Test.Common
private static string GetLogsString(IEnumerable<LogEventInfo> logs)
{
string errors = "";
var errors = "";
foreach (var log in logs)
{
string exception = "";
var exception = "";
if (log.Exception != null)
{
exception = string.Format("[{0}: {1}]", log.Exception.GetType(), log.Exception.Message);

@ -17,7 +17,7 @@ namespace NzbDrone.Update.Test
[Test]
public void should_start_service_if_app_type_was_serivce()
{
string targetFolder = "c:\\Readarr\\".AsOsAgnostic();
var targetFolder = "c:\\Readarr\\".AsOsAgnostic();
Subject.Start(AppType.Service, targetFolder);
@ -27,8 +27,8 @@ namespace NzbDrone.Update.Test
[Test]
public void should_start_console_if_app_type_was_service_but_start_failed_because_of_permissions()
{
string targetFolder = "c:\\Readarr\\".AsOsAgnostic();
string targetProcess = "c:\\Readarr\\Readarr.Console".AsOsAgnostic().ProcessNameToExe();
var targetFolder = "c:\\Readarr\\".AsOsAgnostic();
var targetProcess = "c:\\Readarr\\Readarr.Console".AsOsAgnostic().ProcessNameToExe();
Mocker.GetMock<IServiceProvider>().Setup(c => c.Start(ServiceProvider.SERVICE_NAME)).Throws(new InvalidOperationException());

@ -149,7 +149,7 @@ namespace NzbDrone.Update.UpdateEngine
_terminateNzbDrone.Terminate(processId);
_logger.Info("Waiting for external auto-restart.");
for (int i = 0; i < 10; i++)
for (var i = 0; i < 10; i++)
{
System.Threading.Thread.Sleep(1000);

@ -1,4 +1,4 @@
using System.IO;
using System.IO;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Test.DiskTests;
@ -19,7 +19,7 @@ namespace NzbDrone.Windows.Test.DiskProviderTests
public void should_throw_if_drive_doesnt_exist()
{
// Find a drive that doesn't exist.
for (char driveletter = 'Z'; driveletter > 'D'; driveletter--)
for (var driveletter = 'Z'; driveletter > 'D'; driveletter--)
{
if (new DriveInfo(driveletter.ToString()).IsReady)
{

@ -32,7 +32,7 @@ namespace Readarr.Api.V1.BookFiles
return 0;
}
int qualityWeight = Quality.DefaultQualityDefinitions.Single(q => q.Quality == quality.Quality).Weight;
var qualityWeight = Quality.DefaultQualityDefinitions.Single(q => q.Quality == quality.Quality).Weight;
qualityWeight += quality.Revision.Real * 10;
qualityWeight += quality.Revision.Version;
return qualityWeight;

@ -32,7 +32,7 @@ namespace Readarr.Api.V1.Logs
var files = GetLogFiles().ToList();
for (int i = 0; i < files.Count; i++)
for (var i = 0; i < files.Count; i++)
{
var file = files[i];
var filename = Path.GetFileName(file);

@ -17,7 +17,7 @@ namespace Readarr.Api.V1.Profiles.Quality
[HttpGet]
public QualityProfileResource GetSchema()
{
QualityProfile qualityProfile = _profileService.GetDefaultProfile(string.Empty);
var qualityProfile = _profileService.GetDefaultProfile(string.Empty);
return qualityProfile.ToResource();
}

@ -29,7 +29,7 @@ namespace Readarr.Api.V1.Search
private static IEnumerable<SearchResource> MapToResource(IEnumerable<object> results)
{
int id = 1;
var id = 1;
foreach (var result in results)
{
var resource = new SearchResource();

@ -71,7 +71,7 @@ namespace Readarr.Http.ClientSchema
result = GetFieldMapping(type, "", v => v);
// Renumber al the field Orders since nested settings will have dupe Orders.
for (int i = 0; i < result.Length; i++)
for (var i = 0; i < result.Length; i++)
{
result[i].Field.Order = i;
}

@ -12,7 +12,7 @@ namespace ServiceInstall
private static bool IsAnAdministrator()
{
WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}

@ -12,7 +12,7 @@ namespace ServiceUninstall
private static bool IsAnAdministrator()
{
WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}

Loading…
Cancel
Save