diff --git a/src/NzbDrone.Automation.Test/AutomationTest.cs b/src/NzbDrone.Automation.Test/AutomationTest.cs index 5cbee98a2..615e73cb6 100644 --- a/src/NzbDrone.Automation.Test/AutomationTest.cs +++ b/src/NzbDrone.Automation.Test/AutomationTest.cs @@ -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) diff --git a/src/NzbDrone.Automation.Test/PageModel/PageBase.cs b/src/NzbDrone.Automation.Test/PageModel/PageBase.cs index fbb0bcf43..76c98cce1 100644 --- a/src/NzbDrone.Automation.Test/PageModel/PageBase.cs +++ b/src/NzbDrone.Automation.Test/PageModel/PageBase.cs @@ -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) diff --git a/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs b/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs index 5c26b2f20..ec3b5f3a8 100644 --- a/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs +++ b/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs @@ -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(); - 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(rollingExpiry: true); - for (int i = 0; i < 10; i++) + for (var i = 0; i < 10; i++) { _cachedString.Get("key", () => diff --git a/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs b/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs index 07363e2d2..336feb18e 100644 --- a/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs +++ b/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs @@ -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; diff --git a/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs b/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs index 48afe91c3..7595c05b7 100644 --- a/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs +++ b/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs @@ -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() @@ -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() @@ -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() diff --git a/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs b/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs index e1018556a..2613c7e63 100644 --- a/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs +++ b/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs @@ -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; diff --git a/src/NzbDrone.Common/ArchiveService.cs b/src/NzbDrone.Common/ArchiveService.cs index 2dee4d822..4cd6f6835 100644 --- a/src/NzbDrone.Common/ArchiveService.cs +++ b/src/NzbDrone.Common/ArchiveService.cs @@ -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(); diff --git a/src/NzbDrone.Common/ConvertBase32.cs b/src/NzbDrone.Common/ConvertBase32.cs index 3ee7803d5..bf36e61d5 100644 --- a/src/NzbDrone.Common/ConvertBase32.cs +++ b/src/NzbDrone.Common/ConvertBase32.cs @@ -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; diff --git a/src/NzbDrone.Common/Disk/OsPath.cs b/src/NzbDrone.Common/Disk/OsPath.cs index 24c444fc3..f6f01fccf 100644 --- a/src/NzbDrone.Common/Disk/OsPath.cs +++ b/src/NzbDrone.Common/Disk/OsPath.cs @@ -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(); - 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]); } diff --git a/src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs index aba718098..bbc8581ef 100644 --- a/src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs +++ b/src/NzbDrone.Common/EnvironmentInfo/OsInfo.cs @@ -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; diff --git a/src/NzbDrone.Common/Extensions/FuzzyContains.cs b/src/NzbDrone.Common/Extensions/FuzzyContains.cs index 443184591..32339ff77 100644 --- a/src/NzbDrone.Common/Extensions/FuzzyContains.cs +++ b/src/NzbDrone.Common/Extensions/FuzzyContains.cs @@ -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 curr = text[j - 1]; - bool take = true; + var curr = text[j - 1]; + var take = true; if (!s.TryGetValue(curr, out var charMatch)) { diff --git a/src/NzbDrone.Common/Extensions/PathExtensions.cs b/src/NzbDrone.Common/Extensions/PathExtensions.cs index e4c18d849..0a396c088 100644 --- a/src/NzbDrone.Common/Extensions/PathExtensions.cs +++ b/src/NzbDrone.Common/Extensions/PathExtensions.cs @@ -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]) { diff --git a/src/NzbDrone.Common/Extensions/StringExtensions.cs b/src/NzbDrone.Common/Extensions/StringExtensions.cs index 6b6f04b8e..6ca2bf1db 100644 --- a/src/NzbDrone.Common/Extensions/StringExtensions.cs +++ b/src/NzbDrone.Common/Extensions/StringExtensions.cs @@ -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) diff --git a/src/NzbDrone.Common/HashUtil.cs b/src/NzbDrone.Common/HashUtil.cs index 3d31fe2ea..0705ad4ac 100644 --- a/src/NzbDrone.Common/HashUtil.cs +++ b/src/NzbDrone.Common/HashUtil.cs @@ -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++) diff --git a/src/NzbDrone.Common/Http/HttpUri.cs b/src/NzbDrone.Common/Http/HttpUri.cs index 9cc3b8fec..17130b4a2 100644 --- a/src/NzbDrone.Common/Http/HttpUri.cs +++ b/src/NzbDrone.Common/Http/HttpUri.cs @@ -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()) { diff --git a/src/NzbDrone.Common/Http/Proxy/HttpProxySettings.cs b/src/NzbDrone.Common/Http/Proxy/HttpProxySettings.cs index 58a7541da..09367ea24 100644 --- a/src/NzbDrone.Common/Http/Proxy/HttpProxySettings.cs +++ b/src/NzbDrone.Common/Http/Proxy/HttpProxySettings.cs @@ -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("*")) { diff --git a/src/NzbDrone.Common/Instrumentation/CleansingJsonVisitor.cs b/src/NzbDrone.Common/Instrumentation/CleansingJsonVisitor.cs index 1e32d399f..34df2dff3 100644 --- a/src/NzbDrone.Common/Instrumentation/CleansingJsonVisitor.cs +++ b/src/NzbDrone.Common/Instrumentation/CleansingJsonVisitor.cs @@ -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); } diff --git a/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs b/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs index 81f05a97e..c4de52e5b 100644 --- a/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs +++ b/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs @@ -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}}"; diff --git a/src/NzbDrone.Common/Serializer/Newtonsoft.Json/JsonVisitor.cs b/src/NzbDrone.Common/Serializer/Newtonsoft.Json/JsonVisitor.cs index 0e69a0ae0..093de5b99 100644 --- a/src/NzbDrone.Common/Serializer/Newtonsoft.Json/JsonVisitor.cs +++ b/src/NzbDrone.Common/Serializer/Newtonsoft.Json/JsonVisitor.cs @@ -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); } diff --git a/src/NzbDrone.Common/Serializer/Newtonsoft.Json/UnderscoreStringEnumConverter.cs b/src/NzbDrone.Common/Serializer/Newtonsoft.Json/UnderscoreStringEnumConverter.cs index 06084b07a..b202253b6 100644 --- a/src/NzbDrone.Common/Serializer/Newtonsoft.Json/UnderscoreStringEnumConverter.cs +++ b/src/NzbDrone.Common/Serializer/Newtonsoft.Json/UnderscoreStringEnumConverter.cs @@ -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])) { diff --git a/src/NzbDrone.Common/Serializer/System.Text.Json/STJVersionConverter.cs b/src/NzbDrone.Common/Serializer/System.Text.Json/STJVersionConverter.cs index 70ad492c3..6fd024f7d 100644 --- a/src/NzbDrone.Common/Serializer/System.Text.Json/STJVersionConverter.cs +++ b/src/NzbDrone.Common/Serializer/System.Text.Json/STJVersionConverter.cs @@ -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) diff --git a/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs b/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs index 770ca59a7..e337b453c 100644 --- a/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs +++ b/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -137,7 +137,7 @@ namespace NzbDrone.Common.TPL /// An enumerable of the tasks currently scheduled. protected sealed override IEnumerable GetScheduledTasks() { - bool lockTaken = false; + var lockTaken = false; try { Monitor.TryEnter(_tasks, ref lockTaken); diff --git a/src/NzbDrone.Console/ConsoleApp.cs b/src/NzbDrone.Console/ConsoleApp.cs index ef85745bf..7355ad07b 100644 --- a/src/NzbDrone.Console/ConsoleApp.cs +++ b/src/NzbDrone.Console/ConsoleApp.cs @@ -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); diff --git a/src/NzbDrone.Core.Test/Datastore/BasicRepositoryFixture.cs b/src/NzbDrone.Core.Test/Datastore/BasicRepositoryFixture.cs index 9f0cf4b92..8070f9fda 100644 --- a/src/NzbDrone.Core.Test/Datastore/BasicRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/BasicRepositoryFixture.cs @@ -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]; } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs index 9ef5cbf81..8b12714bd 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs @@ -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(), diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/ScanWatchFolderFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/ScanWatchFolderFixture.cs index 0c184d349..afd403e94 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/ScanWatchFolderFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/ScanWatchFolderFixture.cs @@ -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); diff --git a/src/NzbDrone.Core.Test/FluentTest.cs b/src/NzbDrone.Core.Test/FluentTest.cs index a17f142e3..1747c44f2 100644 --- a/src/NzbDrone.Core.Test/FluentTest.cs +++ b/src/NzbDrone.Core.Test/FluentTest.cs @@ -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); diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/DownloadClientRootFolderCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/DownloadClientRootFolderCheckFixture.cs index 831e9de1a..f3e826fd6 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/DownloadClientRootFolderCheckFixture.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/DownloadClientRootFolderCheckFixture.cs @@ -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); diff --git a/src/NzbDrone.Core.Test/Instrumentation/DatabaseTargetFixture.cs b/src/NzbDrone.Core.Test/Instrumentation/DatabaseTargetFixture.cs index 69f4d25d6..254de6c63 100644 --- a/src/NzbDrone.Core.Test/Instrumentation/DatabaseTargetFixture.cs +++ b/src/NzbDrone.Core.Test/Instrumentation/DatabaseTargetFixture.cs @@ -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(); } diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Aggregation/AggregateFilenameInfoFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Aggregation/AggregateFilenameInfoFixture.cs index 6bdcd39ad..84b3746ad 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Aggregation/AggregateFilenameInfoFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Aggregation/AggregateFilenameInfoFixture.cs @@ -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 GivenFilenames(string[] fields, string fieldSeparator, string whitespace) { var outp = new List(); - for (int i = 1; i <= 3; i++) + for (var i = 1; i <= 3; i++) { var components = new List(); foreach (var field in fields) @@ -161,7 +161,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Aggregation.Aggregators private void VerifyDataAuto(List 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; diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/IdentificationServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/IdentificationServiceFixture.cs index 7151cf4de..37f13d958 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/IdentificationServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/IdentificationServiceFixture.cs @@ -71,7 +71,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification Mocker.SetConstant(Mocker.Resolve()); // set up the augmenters - List> aggregators = new List> + var aggregators = new List> { Mocker.Resolve() }; @@ -89,7 +89,7 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification private List GivenAuthors(List authors) { var outp = new List(); - 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; diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/TrackGroupingServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/TrackGroupingServiceFixture.cs index 8054ef108..3257c07ec 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/TrackGroupingServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/TrackGroupingServiceFixture.cs @@ -30,17 +30,17 @@ namespace NzbDrone.Core.Test.MediaFiles.BookImport.Identification static RandomValueNamerShortStrings() { AllowedChars = new List(); - 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(); - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { var track = Builder .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(); - 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)); } diff --git a/src/NzbDrone.Core.Test/MetadataSource/Goodreads/Resources/WorkResourcesFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/Goodreads/Resources/WorkResourcesFixture.cs index 8650674ab..0f066511d 100644 --- a/src/NzbDrone.Core.Test/MetadataSource/Goodreads/Resources/WorkResourcesFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/Goodreads/Resources/WorkResourcesFixture.cs @@ -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(() => 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); diff --git a/src/NzbDrone.Core.Test/MusicTests/ArtistRepositoryTests/ArtistRepositoryFixture.cs b/src/NzbDrone.Core.Test/MusicTests/ArtistRepositoryTests/ArtistRepositoryFixture.cs index d1cc675d7..32c0337cc 100644 --- a/src/NzbDrone.Core.Test/MusicTests/ArtistRepositoryTests/ArtistRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/ArtistRepositoryTests/ArtistRepositoryFixture.cs @@ -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"); diff --git a/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs index afb42e4f0..bf6588ff9 100644 --- a/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs @@ -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]); } diff --git a/src/NzbDrone.Core.Test/Profiles/Delay/DelayProfileServiceFixture.cs b/src/NzbDrone.Core.Test/Profiles/Delay/DelayProfileServiceFixture.cs index c0770aa81..587de3258 100644 --- a/src/NzbDrone.Core.Test/Profiles/Delay/DelayProfileServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Profiles/Delay/DelayProfileServiceFixture.cs @@ -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]; diff --git a/src/NzbDrone.Core/Books/Repositories/AuthorMetadataRepository.cs b/src/NzbDrone.Core/Books/Repositories/AuthorMetadataRepository.cs index 15ede62d9..d9c187af2 100644 --- a/src/NzbDrone.Core/Books/Repositories/AuthorMetadataRepository.cs +++ b/src/NzbDrone.Core/Books/Repositories/AuthorMetadataRepository.cs @@ -32,7 +32,7 @@ namespace NzbDrone.Core.Books var existingMetadata = FindById(data.Select(x => x.ForeignAuthorId).ToList()); var updateMetadataList = new List(); var addMetadataList = new List(); - int upToDateMetadataCount = 0; + var upToDateMetadataCount = 0; foreach (var meta in data) { diff --git a/src/NzbDrone.Core/Books/Services/AddAuthorService.cs b/src/NzbDrone.Core/Books/Services/AddAuthorService.cs index 966f0263a..b284ea3df 100644 --- a/src/NzbDrone.Core/Books/Services/AddAuthorService.cs +++ b/src/NzbDrone.Core/Books/Services/AddAuthorService.cs @@ -132,7 +132,7 @@ namespace NzbDrone.Core.Books if (_authorService.AuthorPathExists(path)) { var basepath = path; - int i = 0; + var i = 0; do { i++; diff --git a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs index f76a60b63..94eaa67a8 100644 --- a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -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; diff --git a/src/NzbDrone.Core/Datastore/BasicRepository.cs b/src/NzbDrone.Core/Datastore/BasicRepository.cs index 20880e0fd..2f7797383 100644 --- a/src/NzbDrone.Core/Datastore/BasicRepository.cs +++ b/src/NzbDrone.Core/Datastore/BasicRepository.cs @@ -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) { diff --git a/src/NzbDrone.Core/Datastore/Converters/CommandConverter.cs b/src/NzbDrone.Core/Datastore/Converters/CommandConverter.cs index e2f77c6f0..790464f3f 100644 --- a/src/NzbDrone.Core/Datastore/Converters/CommandConverter.cs +++ b/src/NzbDrone.Core/Datastore/Converters/CommandConverter.cs @@ -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(); } diff --git a/src/NzbDrone.Core/Datastore/Migration/006_remove_chown_and_folderchmod_config.cs b/src/NzbDrone.Core/Datastore/Migration/006_remove_chown_and_folderchmod_config.cs index d9912e40e..eedee9fa4 100644 --- a/src/NzbDrone.Core/Datastore/Migration/006_remove_chown_and_folderchmod_config.cs +++ b/src/NzbDrone.Core/Datastore/Migration/006_remove_chown_and_folderchmod_config.cs @@ -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'"; diff --git a/src/NzbDrone.Core/Datastore/Migration/026_add_custom_formats.cs b/src/NzbDrone.Core/Datastore/Migration/026_add_custom_formats.cs index 1bde2abbf..a42b6106c 100644 --- a/src/NzbDrone.Core/Datastore/Migration/026_add_custom_formats.cs +++ b/src/NzbDrone.Core/Datastore/Migration/026_add_custom_formats.cs @@ -231,11 +231,11 @@ namespace NzbDrone.Core.Datastore.Migration { var updatedNamingConfigs = new List(); - 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"); diff --git a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs index 0da570e2c..5f6a0c06b 100644 --- a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs +++ b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs @@ -201,7 +201,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework public virtual IList ReadDbSchema() { - IList 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 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 indexes = new List(); diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs index 370cdffb2..d5aab0486 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs @@ -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; diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs index 792e983ca..0d579f6cd 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs @@ -63,7 +63,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation var items = new List(); long totalRemainingSize = 0; - long globalSpeed = nzbTasks.Where(t => t.Status == DownloadStationTaskStatus.Downloading) + var globalSpeed = nzbTasks.Where(t => t.Status == DownloadStationTaskStatus.Downloading) .Select(GetDownloadSpeed) .Sum(); diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs index f97a26ec9..d77b90b73 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs @@ -223,7 +223,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget protected IEnumerable GetCategories(Dictionary config) { - for (int i = 1; i < 100; i++) + for (var i = 1; i < 100; i++) { var name = config.GetValueOrDefault("Category" + i + ".Name"); diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs index 06735be73..c821addd7 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -496,7 +496,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent return null; } - Dictionary labels = Proxy.GetLabels(Settings); + var labels = Proxy.GetLabels(Settings); if (Settings.MusicCategory.IsNotNullOrWhiteSpace() && !labels.ContainsKey(Settings.MusicCategory)) { diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdStringArrayConverter.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdStringArrayConverter.cs index bca2353a1..b5ab193ce 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdStringArrayConverter.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdStringArrayConverter.cs @@ -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]); } diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs index 132b83695..9c0a7991c 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -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(); - 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) diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs index 3f1f2b262..ef5644057 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -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") { diff --git a/src/NzbDrone.Core/Download/Extensions/XmlExtensions.cs b/src/NzbDrone.Core/Download/Extensions/XmlExtensions.cs index bce66c8bc..b4571d6e8 100644 --- a/src/NzbDrone.Core/Download/Extensions/XmlExtensions.cs +++ b/src/NzbDrone.Core/Download/Extensions/XmlExtensions.cs @@ -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) diff --git a/src/NzbDrone.Core/Fluent.cs b/src/NzbDrone.Core/Fluent.cs index 41f031816..541d843f7 100644 --- a/src/NzbDrone.Core/Fluent.cs +++ b/src/NzbDrone.Core/Fluent.cs @@ -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; diff --git a/src/NzbDrone.Core/ImportLists/HttpImportListBase.cs b/src/NzbDrone.Core/ImportLists/HttpImportListBase.cs index 192f5562e..3cc05bfcf 100644 --- a/src/NzbDrone.Core/ImportLists/HttpImportListBase.cs +++ b/src/NzbDrone.Core/ImportLists/HttpImportListBase.cs @@ -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); diff --git a/src/NzbDrone.Core/IndexerSearch/BookSearchService.cs b/src/NzbDrone.Core/IndexerSearch/BookSearchService.cs index c30a801d7..04bdf55be 100644 --- a/src/NzbDrone.Core/IndexerSearch/BookSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/BookSearchService.cs @@ -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 { diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index 6a225f497..c8feaf841 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -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); diff --git a/src/NzbDrone.Core/Languages/Language.cs b/src/NzbDrone.Core/Languages/Language.cs index 1a634e6d6..84716e587 100644 --- a/src/NzbDrone.Core/Languages/Language.cs +++ b/src/NzbDrone.Core/Languages/Language.cs @@ -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) { diff --git a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs index 680321d8c..6d03053e3 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs @@ -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); } diff --git a/src/NzbDrone.Core/MediaFiles/AudioTag.cs b/src/NzbDrone.Core/MediaFiles/AudioTag.cs index 2ac6ecc91..e45e43ea5 100644 --- a/src/NzbDrone.Core/MediaFiles/AudioTag.cs +++ b/src/NzbDrone.Core/MediaFiles/AudioTag.cs @@ -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?); } } diff --git a/src/NzbDrone.Core/MediaFiles/BookImport/Identification/Distance.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/Distance.cs index 5d1fcda9a..70ab83420 100644 --- a/src/NzbDrone.Core/MediaFiles/BookImport/Identification/Distance.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/Distance.cs @@ -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(arr, c => char.IsLetterOrDigit(c)); @@ -223,7 +223,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification public void AddPriority(string key, List values, List options) where T : IEquatable { - for (int i = 0; i < options.Count; i++) + for (var i = 0; i < options.Count; i++) { if (values.Contains(options[i])) { diff --git a/src/NzbDrone.Core/MediaFiles/BookImport/Identification/IdentificationService.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/IdentificationService.cs index 0b8e24472..d0086dbc5 100644 --- a/src/NzbDrone.Core/MediaFiles/BookImport/Identification/IdentificationService.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/IdentificationService.cs @@ -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 candidateReleases = _candidateService.GetDbCandidatesFromTags(localBookRelease, idOverrides, config.IncludeExisting); diff --git a/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/NotUnpackingSpecification.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/NotUnpackingSpecification.cs index 4edf1382d..87f571544 100644 --- a/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/NotUnpackingSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Specifications/NotUnpackingSpecification.cs @@ -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)) diff --git a/src/NzbDrone.Core/MediaFiles/EpubTag/Readers/SchemaReader.cs b/src/NzbDrone.Core/MediaFiles/EpubTag/Readers/SchemaReader.cs index 1d2efd16b..9dd214983 100644 --- a/src/NzbDrone.Core/MediaFiles/EpubTag/Readers/SchemaReader.cs +++ b/src/NzbDrone.Core/MediaFiles/EpubTag/Readers/SchemaReader.cs @@ -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; } diff --git a/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs b/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs index bf127486c..4bdae3aba 100644 --- a/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs +++ b/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs @@ -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(); diff --git a/src/NzbDrone.Core/Messaging/Commands/CommandQueueManager.cs b/src/NzbDrone.Core/Messaging/Commands/CommandQueueManager.cs index cf11f4320..4005c0be1 100644 --- a/src/NzbDrone.Core/Messaging/Commands/CommandQueueManager.cs +++ b/src/NzbDrone.Core/Messaging/Commands/CommandQueueManager.cs @@ -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; diff --git a/src/NzbDrone.Core/MetadataSource/Goodreads/Extensions/XmlExtensions.cs b/src/NzbDrone.Core/MetadataSource/Goodreads/Extensions/XmlExtensions.cs index d1fa80361..2a5b5ec4b 100644 --- a/src/NzbDrone.Core/MetadataSource/Goodreads/Extensions/XmlExtensions.cs +++ b/src/NzbDrone.Core/MetadataSource/Goodreads/Extensions/XmlExtensions.cs @@ -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 ParseChildren(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; } } } diff --git a/src/NzbDrone.Core/MetadataSource/Goodreads/Resources/PaginationModel.cs b/src/NzbDrone.Core/MetadataSource/Goodreads/Resources/PaginationModel.cs index f93ec2e06..99bfd1148 100644 --- a/src/NzbDrone.Core/MetadataSource/Goodreads/Resources/PaginationModel.cs +++ b/src/NzbDrone.Core/MetadataSource/Goodreads/Resources/PaginationModel.cs @@ -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; diff --git a/src/NzbDrone.Core/Notifications/Email/Email.cs b/src/NzbDrone.Core/Notifications/Email/Email.cs index 198337ca1..01452ee0f 100644 --- a/src/NzbDrone.Core/Notifications/Email/Email.cs +++ b/src/NzbDrone.Core/Notifications/Email/Email.cs @@ -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); } diff --git a/src/NzbDrone.Core/Parser/Model/ParsedBookInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedBookInfo.cs index bfb4e30fb..6517c4447 100644 --- a/src/NzbDrone.Core/Parser/Model/ParsedBookInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ParsedBookInfo.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Parser.Model public override string ToString() { - string bookString = "[Unknown Book]"; + var bookString = "[Unknown Book]"; if (BookTitle != null) { diff --git a/src/NzbDrone.Core/Parser/Model/ParsedTrackInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedTrackInfo.cs index 932ab117e..cfa10fba6 100644 --- a/src/NzbDrone.Core/Parser/Model/ParsedTrackInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ParsedTrackInfo.cs @@ -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()) { diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 90bdd0676..c3723dacb 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -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) diff --git a/src/NzbDrone.Core/Parser/QualityParser.cs b/src/NzbDrone.Core/Parser/QualityParser.cs index 36bb2a913..08a2ca975 100644 --- a/src/NzbDrone.Core/Parser/QualityParser.cs +++ b/src/NzbDrone.Core/Parser/QualityParser.cs @@ -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) { diff --git a/src/NzbDrone.Core/Profiles/Delay/DelayProfileService.cs b/src/NzbDrone.Core/Profiles/Delay/DelayProfileService.cs index 1e119b760..f8a94ff26 100644 --- a/src/NzbDrone.Core/Profiles/Delay/DelayProfileService.cs +++ b/src/NzbDrone.Core/Profiles/Delay/DelayProfileService.cs @@ -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) { diff --git a/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs b/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs index 27d5b89b7..a4254b86b 100644 --- a/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs +++ b/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs @@ -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)) diff --git a/src/NzbDrone.Core/Qualities/QualityDefinitionService.cs b/src/NzbDrone.Core/Qualities/QualityDefinitionService.cs index 968a69407..0aea96a75 100644 --- a/src/NzbDrone.Core/Qualities/QualityDefinitionService.cs +++ b/src/NzbDrone.Core/Qualities/QualityDefinitionService.cs @@ -66,8 +66,8 @@ namespace NzbDrone.Core.Qualities private void InsertMissingDefinitions() { - List insertList = new List(); - List updateList = new List(); + var insertList = new List(); + var updateList = new List(); 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 updateList = new List(); + var updateList = new List(); var allDefinitions = Quality.DefaultQualityDefinitions.OrderBy(d => d.Weight).ToList(); var existingDefinitions = _repo.All().ToList(); diff --git a/src/NzbDrone.Core/Qualities/QualityModel.cs b/src/NzbDrone.Core/Qualities/QualityModel.cs index 93bbe4857..566c98080 100644 --- a/src/NzbDrone.Core/Qualities/QualityModel.cs +++ b/src/NzbDrone.Core/Qualities/QualityModel.cs @@ -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; diff --git a/src/NzbDrone.Core/Qualities/QualityModelComparer.cs b/src/NzbDrone.Core/Qualities/QualityModelComparer.cs index 46e408e93..b3812ed90 100644 --- a/src/NzbDrone.Core/Qualities/QualityModelComparer.cs +++ b/src/NzbDrone.Core/Qualities/QualityModelComparer.cs @@ -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) { diff --git a/src/NzbDrone.Core/Queue/QueueService.cs b/src/NzbDrone.Core/Queue/QueueService.cs index c37a9a114..113496b6e 100644 --- a/src/NzbDrone.Core/Queue/QueueService.cs +++ b/src/NzbDrone.Core/Queue/QueueService.cs @@ -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")) { diff --git a/src/NzbDrone.Mono.Test/DiskProviderTests/DiskProviderFixture.cs b/src/NzbDrone.Mono.Test/DiskProviderTests/DiskProviderFixture.cs index 25a02fd43..a09a68a98 100644 --- a/src/NzbDrone.Mono.Test/DiskProviderTests/DiskProviderFixture.cs +++ b/src/NzbDrone.Mono.Test/DiskProviderTests/DiskProviderFixture.cs @@ -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) { diff --git a/src/NzbDrone.Mono/EnvironmentInfo/VersionAdapters/ReleaseFileVersionAdapter.cs b/src/NzbDrone.Mono/EnvironmentInfo/VersionAdapters/ReleaseFileVersionAdapter.cs index 78dcceec6..9347176b2 100644 --- a/src/NzbDrone.Mono/EnvironmentInfo/VersionAdapters/ReleaseFileVersionAdapter.cs +++ b/src/NzbDrone.Mono/EnvironmentInfo/VersionAdapters/ReleaseFileVersionAdapter.cs @@ -28,7 +28,7 @@ namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters var fullName = ""; var version = ""; - bool success = false; + var success = false; foreach (var releaseFile in releaseFiles) { diff --git a/src/NzbDrone.Test.Common/ConcurrencyCounter.cs b/src/NzbDrone.Test.Common/ConcurrencyCounter.cs index 6ee4554db..7e1985651 100644 --- a/src/NzbDrone.Test.Common/ConcurrencyCounter.cs +++ b/src/NzbDrone.Test.Common/ConcurrencyCounter.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Test.Common public int Start() { - int threadId = Thread.CurrentThread.ManagedThreadId; + var threadId = Thread.CurrentThread.ManagedThreadId; lock (_mutex) { _threads[threadId] = 1; diff --git a/src/NzbDrone.Test.Common/ExceptionVerification.cs b/src/NzbDrone.Test.Common/ExceptionVerification.cs index bcf417434..413769fd9 100644 --- a/src/NzbDrone.Test.Common/ExceptionVerification.cs +++ b/src/NzbDrone.Test.Common/ExceptionVerification.cs @@ -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 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); diff --git a/src/NzbDrone.Update.Test/StartNzbDroneService.cs b/src/NzbDrone.Update.Test/StartNzbDroneService.cs index 52a319aab..c71080993 100644 --- a/src/NzbDrone.Update.Test/StartNzbDroneService.cs +++ b/src/NzbDrone.Update.Test/StartNzbDroneService.cs @@ -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().Setup(c => c.Start(ServiceProvider.SERVICE_NAME)).Throws(new InvalidOperationException()); diff --git a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs index 3f6802ddf..98aa49122 100644 --- a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs +++ b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs @@ -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); diff --git a/src/NzbDrone.Windows.Test/DiskProviderTests/FreeSpaceFixture.cs b/src/NzbDrone.Windows.Test/DiskProviderTests/FreeSpaceFixture.cs index fdb0b0988..1cda90713 100644 --- a/src/NzbDrone.Windows.Test/DiskProviderTests/FreeSpaceFixture.cs +++ b/src/NzbDrone.Windows.Test/DiskProviderTests/FreeSpaceFixture.cs @@ -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) { diff --git a/src/Readarr.Api.V1/BookFiles/BookFileResource.cs b/src/Readarr.Api.V1/BookFiles/BookFileResource.cs index f54a39f20..01b8d51c6 100644 --- a/src/Readarr.Api.V1/BookFiles/BookFileResource.cs +++ b/src/Readarr.Api.V1/BookFiles/BookFileResource.cs @@ -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; diff --git a/src/Readarr.Api.V1/Logs/LogFileModuleBase.cs b/src/Readarr.Api.V1/Logs/LogFileModuleBase.cs index 500e497ad..6c1c996a7 100644 --- a/src/Readarr.Api.V1/Logs/LogFileModuleBase.cs +++ b/src/Readarr.Api.V1/Logs/LogFileModuleBase.cs @@ -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); diff --git a/src/Readarr.Api.V1/Profiles/Quality/QualityProfileSchemaController.cs b/src/Readarr.Api.V1/Profiles/Quality/QualityProfileSchemaController.cs index d7955d8e8..85a46b6cf 100644 --- a/src/Readarr.Api.V1/Profiles/Quality/QualityProfileSchemaController.cs +++ b/src/Readarr.Api.V1/Profiles/Quality/QualityProfileSchemaController.cs @@ -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(); } diff --git a/src/Readarr.Api.V1/Search/SearchController.cs b/src/Readarr.Api.V1/Search/SearchController.cs index c6dfc99b0..e09e0182a 100644 --- a/src/Readarr.Api.V1/Search/SearchController.cs +++ b/src/Readarr.Api.V1/Search/SearchController.cs @@ -29,7 +29,7 @@ namespace Readarr.Api.V1.Search private static IEnumerable MapToResource(IEnumerable results) { - int id = 1; + var id = 1; foreach (var result in results) { var resource = new SearchResource(); diff --git a/src/Readarr.Http/ClientSchema/SchemaBuilder.cs b/src/Readarr.Http/ClientSchema/SchemaBuilder.cs index d53ddb831..54a4e64f1 100644 --- a/src/Readarr.Http/ClientSchema/SchemaBuilder.cs +++ b/src/Readarr.Http/ClientSchema/SchemaBuilder.cs @@ -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; } diff --git a/src/ServiceHelpers/ServiceInstall/ServiceHelper.cs b/src/ServiceHelpers/ServiceInstall/ServiceHelper.cs index 721db77a6..1750123cd 100644 --- a/src/ServiceHelpers/ServiceInstall/ServiceHelper.cs +++ b/src/ServiceHelpers/ServiceInstall/ServiceHelper.cs @@ -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); } diff --git a/src/ServiceHelpers/ServiceUninstall/ServiceHelper.cs b/src/ServiceHelpers/ServiceUninstall/ServiceHelper.cs index 09b249fda..a78f0d69c 100644 --- a/src/ServiceHelpers/ServiceUninstall/ServiceHelper.cs +++ b/src/ServiceHelpers/ServiceUninstall/ServiceHelper.cs @@ -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); }