diff --git a/src/Lidarr.Api.V1/Logs/LogFileControllerBase.cs b/src/Lidarr.Api.V1/Logs/LogFileControllerBase.cs index 6379b89df..102e38b20 100644 --- a/src/Lidarr.Api.V1/Logs/LogFileControllerBase.cs +++ b/src/Lidarr.Api.V1/Logs/LogFileControllerBase.cs @@ -32,7 +32,7 @@ namespace Lidarr.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/Lidarr.Api.V1/Profiles/Quality/QualityProfileSchemaController.cs b/src/Lidarr.Api.V1/Profiles/Quality/QualityProfileSchemaController.cs index 8df7cd2fe..d49beb371 100644 --- a/src/Lidarr.Api.V1/Profiles/Quality/QualityProfileSchemaController.cs +++ b/src/Lidarr.Api.V1/Profiles/Quality/QualityProfileSchemaController.cs @@ -17,7 +17,7 @@ namespace Lidarr.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/Lidarr.Api.V1/Search/SearchController.cs b/src/Lidarr.Api.V1/Search/SearchController.cs index 35d42869c..00315b884 100644 --- a/src/Lidarr.Api.V1/Search/SearchController.cs +++ b/src/Lidarr.Api.V1/Search/SearchController.cs @@ -29,7 +29,7 @@ namespace Lidarr.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/Lidarr.Api.V1/TrackFiles/TrackFileResource.cs b/src/Lidarr.Api.V1/TrackFiles/TrackFileResource.cs index cb22479e2..7ae99aa28 100644 --- a/src/Lidarr.Api.V1/TrackFiles/TrackFileResource.cs +++ b/src/Lidarr.Api.V1/TrackFiles/TrackFileResource.cs @@ -34,7 +34,7 @@ namespace Lidarr.Api.V1.TrackFiles 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/Lidarr.Http/ClientSchema/SchemaBuilder.cs b/src/Lidarr.Http/ClientSchema/SchemaBuilder.cs index d3aa1b745..2346132cb 100644 --- a/src/Lidarr.Http/ClientSchema/SchemaBuilder.cs +++ b/src/Lidarr.Http/ClientSchema/SchemaBuilder.cs @@ -71,7 +71,7 @@ namespace Lidarr.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/NzbDrone.Automation.Test/AutomationTest.cs b/src/NzbDrone.Automation.Test/AutomationTest.cs index 1fc1650c0..4626f6ba8 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 32bfe2477..f833f6492 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 cf3de2d3b..98c20d651 100644 --- a/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs +++ b/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using FluentAssertions; using NUnit.Framework; @@ -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", () => diff --git a/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs b/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs index e298b77e9..28ba64614 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 203171eb9..057c83cfb 100644 --- a/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs +++ b/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs @@ -800,7 +800,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(); @@ -834,7 +834,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 8d8dcf2f9..f6f01fccf 100644 --- a/src/NzbDrone.Common/Disk/OsPath.cs +++ b/src/NzbDrone.Common/Disk/OsPath.cs @@ -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 451c0cd7e..28eda4fd6 100644 --- a/src/NzbDrone.Common/Extensions/FuzzyContains.cs +++ b/src/NzbDrone.Common/Extensions/FuzzyContains.cs @@ -1,4 +1,4 @@ -/* +/* * This file incorporates work covered by the following copyright and * permission notice: * @@ -78,7 +78,7 @@ namespace NzbDrone.Common.Extensions private static Tuple match_bitap(string text, string pattern, double matchThreshold) { // Initialise the alphabet. - Dictionary s = alphabet(pattern); + var s = alphabet(pattern); // don't keep creating new BigInteger(1) var big1 = new BigInteger(1); @@ -88,19 +88,19 @@ namespace NzbDrone.Common.Extensions // Initialise the bit arrays. var matchmask = big1 << (pattern.Length - 1); - int best_loc = -1; + var best_loc = -1; // Empty initialization added to appease C# compiler. var last_rd = Array.Empty(); - for (int d = 0; d < pattern.Length; d++) + for (var d = 0; d < pattern.Length; d++) { // Scan for the best match; each iteration allows for one more error. - int start = 1; - int finish = text.Length + pattern.Length; + var start = 1; + var finish = text.Length + pattern.Length; var rd = new BigInteger[finish + 2]; rd[finish + 1] = (big1 << d) - big1; - for (int j = finish; j >= start; j--) + for (var j = finish; j >= start; j--) { BigInteger charMatch; if (text.Length <= j - 1 || !s.ContainsKey(text[j - 1])) @@ -171,8 +171,8 @@ namespace NzbDrone.Common.Extensions private static Dictionary alphabet(string pattern) { var s = new Dictionary(); - char[] char_pattern = pattern.ToCharArray(); - foreach (char c in char_pattern) + var char_pattern = pattern.ToCharArray(); + foreach (var c in char_pattern) { if (!s.ContainsKey(c)) { @@ -180,8 +180,8 @@ namespace NzbDrone.Common.Extensions } } - int i = 0; - foreach (char c in char_pattern) + var i = 0; + foreach (var c in char_pattern) { s[c] = s[c] | (new BigInteger(1) << (pattern.Length - i - 1)); i++; diff --git a/src/NzbDrone.Common/Extensions/LevenstheinExtensions.cs b/src/NzbDrone.Common/Extensions/LevenstheinExtensions.cs index 825525457..eb20ce7b0 100644 --- a/src/NzbDrone.Common/Extensions/LevenstheinExtensions.cs +++ b/src/NzbDrone.Common/Extensions/LevenstheinExtensions.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Common.Extensions return text.Length * costDelete; } - int[] matrix = new int[other.Length + 1]; + var matrix = new int[other.Length + 1]; for (var i = 1; i < matrix.Length; i++) { @@ -30,13 +30,13 @@ namespace NzbDrone.Common.Extensions for (var i = 0; i < text.Length; i++) { - int topLeft = matrix[0]; + var topLeft = matrix[0]; matrix[0] = matrix[0] + costDelete; for (var j = 0; j < other.Length; j++) { - int top = matrix[j]; - int left = matrix[j + 1]; + var top = matrix[j]; + var left = matrix[j + 1]; var sumIns = top + costInsert; var sumDel = left + costDelete; diff --git a/src/NzbDrone.Common/Extensions/PathExtensions.cs b/src/NzbDrone.Common/Extensions/PathExtensions.cs index 2a1feff2d..d8c24af8e 100644 --- a/src/NzbDrone.Common/Extensions/PathExtensions.cs +++ b/src/NzbDrone.Common/Extensions/PathExtensions.cs @@ -244,13 +244,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 02156b253..adcf50c0f 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 d9d915bb8..31626b925 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 ce7dc7608..71164b43a 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 436b65821..4b2d0306c 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 4c28feb67..bec13eb3a 100644 --- a/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs +++ b/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs @@ -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 f849158f1..4419fe802 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/Datastore/Migration/023_add_release_groups_etcFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/023_add_release_groups_etcFixture.cs index dfcad6cf8..513ac0541 100644 --- a/src/NzbDrone.Core.Test/Datastore/Migration/023_add_release_groups_etcFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/Migration/023_add_release_groups_etcFixture.cs @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration private void GivenTracks(add_release_groups_etc c, int artistid, int albumid, int firstId, int count) { - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { var id = firstId + i; c.Insert.IntoTable("Tracks").Row(new diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/030_add_mediafilerepository_mtimeFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/030_add_mediafilerepository_mtimeFixture.cs index 1abb1d4b6..26ee1aff9 100644 --- a/src/NzbDrone.Core.Test/Datastore/Migration/030_add_mediafilerepository_mtimeFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/Migration/030_add_mediafilerepository_mtimeFixture.cs @@ -65,7 +65,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration private void GivenTrackFiles(add_mediafilerepository_mtime c, List tracks, int albumReleaseId, int albumId, int firstId = 1, bool addTracks = true) { - int id = firstId; + var id = firstId; foreach (var track in tracks) { c.Insert.IntoTable("TrackFiles").Row(new diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs index 9243ba028..f090481de 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_320.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_24.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 df4adae3a..30a3b1ab9 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 11be12b0d..a3e437776 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 1160b474f..7b82fd9a7 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.TrackImport.Aggregation.Aggregators { get { - int i = 0; + var i = 0; foreach (var tokens in tokenList) { @@ -128,7 +128,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.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.TrackImport.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/CandidateServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/CandidateServiceFixture.cs index b016be75c..141e65061 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/CandidateServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/CandidateServiceFixture.cs @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification .Build() .ToList(); - for (int i = 0; i < tracks.Count; i++) + for (var i = 0; i < tracks.Count; i++) { output[i].FileTrackInfo = GivenParsedTrackInfo(tracks[i], release); } diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/IdentificationServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/IdentificationServiceFixture.cs index 24481908d..8b75dbe74 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/IdentificationServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/IdentificationServiceFixture.cs @@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification Mocker.SetConstant(Mocker.Resolve()); // set up the augmenters - List> aggregators = new List> + var aggregators = new List> { Mocker.Resolve() }; @@ -97,7 +97,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification private List GivenArtists(List artists) { var outp = new List(); - for (int i = 0; i < artists.Count; i++) + for (var i = 0; i < artists.Count; i++) { var meta = artists[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 a83c935e0..48c8e490c 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.TrackImport.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.TrackImport.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.TrackImport.Identification { var outp = new List(); - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { var track = Builder .CreateNew() @@ -281,7 +281,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification public void should_separate_many_albums_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(), "artist" + i, "album" + i, 10)); } diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/TrackMappingFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/TrackMappingFixture.cs index c1445bdb9..f7f455c9a 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/TrackMappingFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Identification/TrackMappingFixture.cs @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification .Build() .ToList(); - for (int i = 0; i < tracks.Count; i++) + for (var i = 0; i < tracks.Count; i++) { output[i].FileTrackInfo = GivenParsedTrackInfo(tracks[i], release); } diff --git a/src/NzbDrone.Core.Test/MusicTests/ArtistRepositoryTests/ArtistRepositoryFixture.cs b/src/NzbDrone.Core.Test/MusicTests/ArtistRepositoryTests/ArtistRepositoryFixture.cs index 50c28fe30..966a71183 100644 --- a/src/NzbDrone.Core.Test/MusicTests/ArtistRepositoryTests/ArtistRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/ArtistRepositoryTests/ArtistRepositoryFixture.cs @@ -129,7 +129,7 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistRepositoryTests { GivenArtists(); - string name = "Alice Cooper"; + var name = "Alice Cooper"; AddArtist(name, "ee58c59f-8e7f-4430-b8ca-236c4d3745ae"); AddArtist(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 e5674bcdb..2b40fe98f 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/Configuration/ConfigFileProvider.cs b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 4ad0a360f..f1ac61012 100644 --- a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -139,7 +139,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 0ac96becf..009b6614e 100644 --- a/src/NzbDrone.Core/Datastore/BasicRepository.cs +++ b/src/NzbDrone.Core/Datastore/BasicRepository.cs @@ -203,7 +203,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/023_add_release_groups_etc.cs b/src/NzbDrone.Core/Datastore/Migration/023_add_release_groups_etc.cs index 6a98f8e1e..b39307f9e 100644 --- a/src/NzbDrone.Core/Datastore/Migration/023_add_release_groups_etc.cs +++ b/src/NzbDrone.Core/Datastore/Migration/023_add_release_groups_etc.cs @@ -202,7 +202,7 @@ namespace NzbDrone.Core.Datastore.Migration { while (releaseReader.Read()) { - int albumId = releaseReader.GetInt32(0); + var albumId = releaseReader.GetInt32(0); var albumRelease = Json.Deserialize(releaseReader.GetString(1)); AlbumRelease023 toInsert = null; diff --git a/src/NzbDrone.Core/Datastore/Migration/039_add_root_folder_add_defaults.cs b/src/NzbDrone.Core/Datastore/Migration/039_add_root_folder_add_defaults.cs index 87570fd48..c271f6cda 100644 --- a/src/NzbDrone.Core/Datastore/Migration/039_add_root_folder_add_defaults.cs +++ b/src/NzbDrone.Core/Datastore/Migration/039_add_root_folder_add_defaults.cs @@ -20,8 +20,8 @@ namespace NzbDrone.Core.Datastore.Migration private void SetDefaultOptions(IDbConnection conn, IDbTransaction tran) { - int metadataId = GetMinProfileId(conn, tran, "MetadataProfiles"); - int qualityId = GetMinProfileId(conn, tran, "QualityProfiles"); + var metadataId = GetMinProfileId(conn, tran, "MetadataProfiles"); + var qualityId = GetMinProfileId(conn, tran, "QualityProfiles"); if (metadataId == 0 || qualityId == 0) { diff --git a/src/NzbDrone.Core/Datastore/Migration/045_remove_chown_and_folderchmod_config.cs b/src/NzbDrone.Core/Datastore/Migration/045_remove_chown_and_folderchmod_config.cs index f98400841..bdc58fb2a 100644 --- a/src/NzbDrone.Core/Datastore/Migration/045_remove_chown_and_folderchmod_config.cs +++ b/src/NzbDrone.Core/Datastore/Migration/045_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/063_add_custom_formats.cs b/src/NzbDrone.Core/Datastore/Migration/063_add_custom_formats.cs index d3861725e..09a90de06 100644 --- a/src/NzbDrone.Core/Datastore/Migration/063_add_custom_formats.cs +++ b/src/NzbDrone.Core/Datastore/Migration/063_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 standardTrackFormatIndex = namingConfigReader.GetOrdinal("StandardTrackFormat"); var multiDiscTrackFormatIndex = namingConfigReader.GetOrdinal("MultiDiscTrackFormat"); diff --git a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs index c46be41ee..e4b79f730 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); @@ -264,7 +264,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 870fc63b7..4b012efa0 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/Proxies/DownloadStationTaskProxyV2.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxyV2.cs index dfcdd68fb..6ebb4a7ca 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxyV2.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxyV2.cs @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies else { _logger.Trace("No directory configured in settings; falling back to client default destination folder."); - string defaultDestination = _defaultDestinationProxy.GetDefaultDestination(settings); + var defaultDestination = _defaultDestinationProxy.GetDefaultDestination(settings); if (defaultDestination.IsNotNullOrWhiteSpace()) { @@ -73,7 +73,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies else { _logger.Trace("No directory configured in settings; falling back to client default destination folder."); - string defaultDestination = _defaultDestinationProxy.GetDefaultDestination(settings); + var defaultDestination = _defaultDestinationProxy.GetDefaultDestination(settings); if (defaultDestination.IsNotNullOrWhiteSpace()) { diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs index 4adfded80..0e01e8fc2 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 96f340c4b..b15e1c381 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 a15bb16dd..aa3d31534 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -494,7 +494,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 d219d502a..828010bfd 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -121,7 +121,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 66e967770..ff714e832 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/HealthCheck/Checks/PackageGlobalMessageCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/PackageGlobalMessageCheck.cs index 9299088aa..18e1a9d0d 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/PackageGlobalMessageCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/PackageGlobalMessageCheck.cs @@ -22,7 +22,7 @@ namespace NzbDrone.Core.HealthCheck.Checks } var message = _deploymentInfoProvider.PackageGlobalMessage; - HealthCheckResult result = HealthCheckResult.Notice; + var result = HealthCheckResult.Notice; if (message.StartsWith("Error:")) { diff --git a/src/NzbDrone.Core/ImportLists/HttpImportListBase.cs b/src/NzbDrone.Core/ImportLists/HttpImportListBase.cs index 8907726e2..07f259f4e 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/ImportLists/Spotify/SpotifyImportListBase.cs b/src/NzbDrone.Core/ImportLists/Spotify/SpotifyImportListBase.cs index f852acb1d..57e6ec9df 100644 --- a/src/NzbDrone.Core/ImportLists/Spotify/SpotifyImportListBase.cs +++ b/src/NzbDrone.Core/ImportLists/Spotify/SpotifyImportListBase.cs @@ -138,7 +138,7 @@ namespace NzbDrone.Core.ImportLists.Spotify break; } - return DateTime.TryParseExact(date, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime result) ? result : default(DateTime); + return DateTime.TryParseExact(date, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out var result) ? result : default(DateTime); } public IList MapSpotifyReleases(IList items) diff --git a/src/NzbDrone.Core/ImportLists/Spotify/SpotifyProxy.cs b/src/NzbDrone.Core/ImportLists/Spotify/SpotifyProxy.cs index 72e2464e9..a36a63638 100644 --- a/src/NzbDrone.Core/ImportLists/Spotify/SpotifyProxy.cs +++ b/src/NzbDrone.Core/ImportLists/Spotify/SpotifyProxy.cs @@ -79,7 +79,7 @@ namespace NzbDrone.Core.ImportLists.Spotify where T : BasicModel where TSettings : SpotifySettingsBase, new() { - T result = method(api); + var result = method(api); if (result.HasError()) { // If unauthorized, refresh token and try again diff --git a/src/NzbDrone.Core/IndexerSearch/AlbumSearchService.cs b/src/NzbDrone.Core/IndexerSearch/AlbumSearchService.cs index 498feb5b0..3759c0e04 100644 --- a/src/NzbDrone.Core/IndexerSearch/AlbumSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/AlbumSearchService.cs @@ -74,7 +74,7 @@ namespace NzbDrone.Core.IndexerSearch if (message.ArtistId.HasValue) { - int artistId = message.ArtistId.Value; + var artistId = message.ArtistId.Value; var pagingSpec = new PagingSpec { diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index 1b22b78eb..8a9055a0e 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 77e80df78..1d364318c 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs @@ -136,7 +136,7 @@ namespace NzbDrone.Core.MediaCover private bool EnsureArtistCovers(Artist artist) { - bool updated = false; + var updated = false; var toResize = new List>(); foreach (var cover in artist.Metadata.Value.Images) @@ -196,7 +196,7 @@ namespace NzbDrone.Core.MediaCover public bool EnsureAlbumCovers(Album album) { - bool updated = false; + var updated = false; foreach (var cover in album.Images.Where(e => e.CoverType == MediaCoverTypes.Cover)) { @@ -269,7 +269,7 @@ namespace NzbDrone.Core.MediaCover private void EnsureResizedCovers(Artist artist, MediaCover cover, bool forceResize, Album album = null) { - int[] heights = GetDefaultHeights(cover.CoverType); + var heights = GetDefaultHeights(cover.CoverType); foreach (var height in heights) { diff --git a/src/NzbDrone.Core/MediaFiles/AudioTag.cs b/src/NzbDrone.Core/MediaFiles/AudioTag.cs index 1b0fb21e9..500a94bed 100644 --- a/src/NzbDrone.Core/MediaFiles/AudioTag.cs +++ b/src/NzbDrone.Core/MediaFiles/AudioTag.cs @@ -161,13 +161,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. @@ -222,7 +222,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 @@ -241,22 +241,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/TrackImport/Identification/Distance.cs b/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Distance.cs index 76e74fc6b..12fa48af2 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Distance.cs +++ b/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Distance.cs @@ -102,7 +102,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.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); } @@ -115,7 +115,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.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)); @@ -171,7 +171,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.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/TrackImport/Identification/IdentificationService.cs b/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/IdentificationService.cs index 9db887793..fe6ec82f0 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/IdentificationService.cs +++ b/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/IdentificationService.cs @@ -126,7 +126,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification var releases = GetLocalAlbumReleases(localTracks, config.SingleRelease); - int i = 0; + var i = 0; foreach (var localRelease in releases) { i++; @@ -193,7 +193,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification private void IdentifyRelease(LocalAlbumRelease localAlbumRelease, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config) { var watch = System.Diagnostics.Stopwatch.StartNew(); - bool fingerprinted = false; + var fingerprinted = false; var candidateReleases = _candidateService.GetDbCandidatesFromTags(localAlbumRelease, idOverrides, config.IncludeExisting); @@ -304,7 +304,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification _logger.Debug("Matching {0} track files against {1} candidates", localAlbumRelease.TrackCount, candidateReleases.Count); _logger.Trace("Processing files:\n{0}", string.Join("\n", localAlbumRelease.LocalTracks.Select(x => x.Path))); - double bestDistance = 1.0; + var bestDistance = 1.0; foreach (var candidateRelease in candidateReleases) { @@ -350,10 +350,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification var distances = new Distance[localTracks.Count, mbTracks.Count]; var costs = new double[localTracks.Count, mbTracks.Count]; - for (int col = 0; col < mbTracks.Count; col++) + for (var col = 0; col < mbTracks.Count; col++) { var totalTrackNumber = DistanceCalculator.GetTotalTrackNumber(mbTracks[col], mbTracks); - for (int row = 0; row < localTracks.Count; row++) + for (var row = 0; row < localTracks.Count; row++) { distances[row, col] = DistanceCalculator.TrackDistance(localTracks[row], mbTracks[col], totalTrackNumber, false); costs[row, col] = distances[row, col].NormalizedDistance(); diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Munkres.cs b/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Munkres.cs index 52590f260..209d4e061 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Munkres.cs +++ b/src/NzbDrone.Core/MediaFiles/TrackImport/Identification/Munkres.cs @@ -79,9 +79,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification get { var value = new List>(); - for (int row = 0; row < nrow_orig; row++) + for (var row = 0; row < nrow_orig; row++) { - for (int col = 0; col < ncol_orig; col++) + for (var col = 0; col < ncol_orig; col++) { if (M[row, col] == 1) { @@ -107,9 +107,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification { var newdim = Math.Max(matrix.GetLength(0), matrix.GetLength(1)); var outp = new double[newdim, newdim]; - for (int row = 0; row < matrix.GetLength(0); row++) + for (var row = 0; row < matrix.GetLength(0); row++) { - for (int col = 0; col < matrix.GetLength(1); col++) + for (var col = 0; col < matrix.GetLength(1); col++) { outp[row, col] = matrix[row, col]; } @@ -124,10 +124,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification { double min_in_row; - for (int r = 0; r < n; r++) + for (var r = 0; r < n; r++) { min_in_row = C[r, 0]; - for (int c = 0; c < n; c++) + for (var c = 0; c < n; c++) { if (C[r, c] < min_in_row) { @@ -135,7 +135,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification } } - for (int c = 0; c < n; c++) + for (var c = 0; c < n; c++) { C[r, c] -= min_in_row; } @@ -149,9 +149,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification // matrix. Go to Step 3. private void step_two(ref int step) { - for (int r = 0; r < n; r++) + for (var r = 0; r < n; r++) { - for (int c = 0; c < n; c++) + for (var c = 0; c < n; c++) { if (C[r, c] == 0 && RowCover[r] == 0 && ColCover[c] == 0) { @@ -162,12 +162,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification } } - for (int r = 0; r < n; r++) + for (var r = 0; r < n; r++) { RowCover[r] = 0; } - for (int c = 0; c < n; c++) + for (var c = 0; c < n; c++) { ColCover[c] = 0; } @@ -181,9 +181,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification private void step_three(ref int step) { int colcount; - for (int r = 0; r < n; r++) + for (var r = 0; r < n; r++) { - for (int c = 0; c < n; c++) + for (var c = 0; c < n; c++) { if (M[r, c] == 1) { @@ -193,7 +193,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification } colcount = 0; - for (int c = 0; c < n; c++) + for (var c = 0; c < n; c++) { if (ColCover[c] == 1) { @@ -214,7 +214,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification // methods to support step 4 private void find_a_zero(ref int row, ref int col) { - int r = 0; + var r = 0; int c; bool done; row = -1; @@ -249,8 +249,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification private bool star_in_row(int row) { - bool tmp = false; - for (int c = 0; c < n; c++) + var tmp = false; + for (var c = 0; c < n; c++) { if (M[row, c] == 1) { @@ -264,7 +264,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification private void find_star_in_row(int row, ref int col) { col = -1; - for (int c = 0; c < n; c++) + for (var c = 0; c < n; c++) { if (M[row, c] == 1) { @@ -280,8 +280,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification // Save the smallest uncovered value and Go to Step 6. private void step_four(ref int step) { - int row = -1; - int col = -1; + var row = -1; + var col = -1; bool done; done = false; @@ -317,7 +317,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification private void find_star_in_col(int c, ref int r) { r = -1; - for (int i = 0; i < n; i++) + for (var i = 0; i < n; i++) { if (M[i, c] == 1) { @@ -328,7 +328,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification private void find_prime_in_row(int r, ref int c) { - for (int j = 0; j < n; j++) + for (var j = 0; j < n; j++) { if (M[r, j] == 2) { @@ -339,7 +339,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification private void augment_path() { - for (int p = 0; p < path_count; p++) + for (var p = 0; p < path_count; p++) { if (M[path[p, 0], path[p, 1]] == 1) { @@ -354,12 +354,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification private void clear_covers() { - for (int r = 0; r < n; r++) + for (var r = 0; r < n; r++) { RowCover[r] = 0; } - for (int c = 0; c < n; c++) + for (var c = 0; c < n; c++) { ColCover[c] = 0; } @@ -367,9 +367,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification private void erase_primes() { - for (int r = 0; r < n; r++) + for (var r = 0; r < n; r++) { - for (int c = 0; c < n; c++) + for (var c = 0; c < n; c++) { if (M[r, c] == 2) { @@ -389,8 +389,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification private void step_five(ref int step) { bool done; - int r = -1; - int c = -1; + var r = -1; + var c = -1; path_count = 1; path[path_count - 1, 0] = path_row_0; @@ -428,9 +428,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification // methods to support step 6 private void find_smallest(ref double minval) { - for (int r = 0; r < n; r++) + for (var r = 0; r < n; r++) { - for (int c = 0; c < n; c++) + for (var c = 0; c < n; c++) { if (RowCover[r] == 0 && ColCover[c] == 0) { @@ -448,11 +448,11 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification // altering any stars, primes, or covered lines. private void step_six(ref int step) { - double minval = double.MaxValue; + var minval = double.MaxValue; find_smallest(ref minval); - for (int r = 0; r < n; r++) + for (var r = 0; r < n; r++) { - for (int c = 0; c < n; c++) + for (var c = 0; c < n; c++) { if (RowCover[r] == 1) { @@ -471,7 +471,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification public void Run() { - bool done = false; + var done = false; while (!done) { switch (step) diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportApprovedTracks.cs b/src/NzbDrone.Core/MediaFiles/TrackImport/ImportApprovedTracks.cs index b2081223a..ba54e10c8 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportApprovedTracks.cs +++ b/src/NzbDrone.Core/MediaFiles/TrackImport/ImportApprovedTracks.cs @@ -90,7 +90,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport var albumDecisions = decisions.Where(e => e.Item.Album != null && e.Approved) .GroupBy(e => e.Item.Album.ForeignAlbumId).ToList(); - int iDecision = 1; + var iDecision = 1; foreach (var albumDecision in albumDecisions) { _logger.ProgressInfo($"Importing album {iDecision++}/{albumDecisions.Count}"); diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecisionMaker.cs b/src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecisionMaker.cs index 4ad968ea8..aae1a9e6f 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecisionMaker.cs +++ b/src/NzbDrone.Core/MediaFiles/TrackImport/ImportDecisionMaker.cs @@ -100,7 +100,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport downloadClientItemInfo = Parser.Parser.ParseAlbumTitle(downloadClientItem.Title); } - int i = 1; + var i = 1; foreach (var file in files) { _logger.ProgressInfo($"Reading file {i++}/{files.Count}"); diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/NotUnpackingSpecification.cs b/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/NotUnpackingSpecification.cs index 8f95b3e4c..135210839 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/NotUnpackingSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/NotUnpackingSpecification.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.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/UpdateTrackFileService.cs b/src/NzbDrone.Core/MediaFiles/UpdateTrackFileService.cs index d4aac29a0..953bc6148 100644 --- a/src/NzbDrone.Core/MediaFiles/UpdateTrackFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/UpdateTrackFileService.cs @@ -64,7 +64,7 @@ namespace NzbDrone.Core.MediaFiles var relDate = album.ReleaseDate.Value; // avoiding false +ve checks and set date skewing by not using UTC (Windows) - DateTime oldDateTime = _diskProvider.FileGetLastWrite(trackFilePath); + var oldDateTime = _diskProvider.FileGetLastWrite(trackFilePath); if (OsInfo.IsNotWindows && relDate < EpochTime) { diff --git a/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs b/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs index 298ac4ea5..ca6aea09c 100644 --- a/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs +++ b/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs @@ -126,7 +126,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 c830e74e0..87b9340dc 100644 --- a/src/NzbDrone.Core/Messaging/Commands/CommandQueueManager.cs +++ b/src/NzbDrone.Core/Messaging/Commands/CommandQueueManager.cs @@ -139,7 +139,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/SearchArtistComparer.cs b/src/NzbDrone.Core/MetadataSource/SearchArtistComparer.cs index 13a6f8201..7d253826d 100644 --- a/src/NzbDrone.Core/MetadataSource/SearchArtistComparer.cs +++ b/src/NzbDrone.Core/MetadataSource/SearchArtistComparer.cs @@ -35,7 +35,7 @@ namespace NzbDrone.Core.MetadataSource public int Compare(Artist x, Artist y) { - int result = 0; + var result = 0; // Prefer exact matches result = Compare(x, y, s => CleanPunctuation(s.Name).Equals(CleanPunctuation(SearchQuery))); diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 5bb23a8bf..53644c089 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -190,7 +190,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook { var slug = lowerTitle.Split(':')[1].Trim(); - bool isValid = Guid.TryParse(slug, out var searchGuid); + var isValid = Guid.TryParse(slug, out var searchGuid); if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || isValid == false) { @@ -252,7 +252,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook { var slug = lowerTitle.Split(':')[1].Trim(); - bool isValid = Guid.TryParse(slug, out var searchGuid); + var isValid = Guid.TryParse(slug, out var searchGuid); if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || isValid == false) { @@ -432,7 +432,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook private static Album MapAlbum(AlbumResource resource, Dictionary artistDict) { - Album album = new Album(); + var album = new Album(); album.ForeignAlbumId = resource.Id; album.OldForeignAlbumIds = resource.OldIds; album.Title = resource.Title; @@ -475,7 +475,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook private static AlbumRelease MapRelease(ReleaseResource resource, Dictionary artistDict) { - AlbumRelease release = new AlbumRelease(); + var release = new AlbumRelease(); release.ForeignReleaseId = resource.Id; release.OldForeignReleaseIds = resource.OldIds; release.Title = resource.Title; @@ -490,7 +490,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook var allTracks = resource.Tracks.Select(x => MapTrack(x, artistDict)); if (!allMedia.Any()) { - foreach (int n in allTracks.Select(x => x.MediumNumber).Distinct()) + foreach (var n in allTracks.Select(x => x.MediumNumber).Distinct()) { allMedia.Add(new Medium { Name = "Unknown", Number = n, Format = "Unknown" }); } @@ -514,7 +514,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook private static Medium MapMedium(MediumResource resource) { - Medium medium = new Medium + var medium = new Medium { Name = resource.Name, Number = resource.Position, @@ -526,7 +526,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook private static Track MapTrack(TrackResource resource, Dictionary artistDict) { - Track track = new Track + var track = new Track { ArtistMetadata = artistDict[resource.ArtistId], Title = resource.TrackName, @@ -545,7 +545,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook private static ArtistMetadata MapArtistMetadata(ArtistResource resource) { - ArtistMetadata artist = new ArtistMetadata(); + var artist = new ArtistMetadata(); artist.Name = resource.ArtistName; artist.Aliases = resource.ArtistAliases; diff --git a/src/NzbDrone.Core/Music/Model/PrimaryAlbumType.cs b/src/NzbDrone.Core/Music/Model/PrimaryAlbumType.cs index 068bf1779..c4bb4e9f3 100644 --- a/src/NzbDrone.Core/Music/Model/PrimaryAlbumType.cs +++ b/src/NzbDrone.Core/Music/Model/PrimaryAlbumType.cs @@ -87,7 +87,7 @@ namespace NzbDrone.Core.Music return Album; } - PrimaryAlbumType albumType = All.FirstOrDefault(v => v.Id == id); + var albumType = All.FirstOrDefault(v => v.Id == id); if (albumType == null) { diff --git a/src/NzbDrone.Core/Music/Model/ReleaseStatus.cs b/src/NzbDrone.Core/Music/Model/ReleaseStatus.cs index b22f08ba2..f9352fcdf 100644 --- a/src/NzbDrone.Core/Music/Model/ReleaseStatus.cs +++ b/src/NzbDrone.Core/Music/Model/ReleaseStatus.cs @@ -85,7 +85,7 @@ namespace NzbDrone.Core.Music return Official; } - ReleaseStatus albumType = All.FirstOrDefault(v => v.Id == id); + var albumType = All.FirstOrDefault(v => v.Id == id); if (albumType == null) { diff --git a/src/NzbDrone.Core/Music/Model/SecondaryAlbumType.cs b/src/NzbDrone.Core/Music/Model/SecondaryAlbumType.cs index 9b19b1ee2..622e20687 100644 --- a/src/NzbDrone.Core/Music/Model/SecondaryAlbumType.cs +++ b/src/NzbDrone.Core/Music/Model/SecondaryAlbumType.cs @@ -100,7 +100,7 @@ namespace NzbDrone.Core.Music return Studio; } - SecondaryAlbumType albumType = All.FirstOrDefault(v => v.Id == id); + var albumType = All.FirstOrDefault(v => v.Id == id); if (albumType == null) { diff --git a/src/NzbDrone.Core/Music/Repositories/ArtistMetadataRepository.cs b/src/NzbDrone.Core/Music/Repositories/ArtistMetadataRepository.cs index df8a39a06..1f54aa3e5 100644 --- a/src/NzbDrone.Core/Music/Repositories/ArtistMetadataRepository.cs +++ b/src/NzbDrone.Core/Music/Repositories/ArtistMetadataRepository.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Core.Datastore; @@ -32,7 +32,7 @@ namespace NzbDrone.Core.Music var existingMetadata = FindById(data.Select(x => x.ForeignArtistId).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/Music/Services/AddArtistService.cs b/src/NzbDrone.Core/Music/Services/AddArtistService.cs index 20261afb2..2b484902e 100644 --- a/src/NzbDrone.Core/Music/Services/AddArtistService.cs +++ b/src/NzbDrone.Core/Music/Services/AddArtistService.cs @@ -154,7 +154,7 @@ namespace NzbDrone.Core.Music if (_artistService.ArtistPathExists(path)) { var basepath = path; - int i = 0; + var i = 0; do { i++; diff --git a/src/NzbDrone.Core/Music/Services/RefreshAlbumService.cs b/src/NzbDrone.Core/Music/Services/RefreshAlbumService.cs index 02e283ad5..ea99b7276 100644 --- a/src/NzbDrone.Core/Music/Services/RefreshAlbumService.cs +++ b/src/NzbDrone.Core/Music/Services/RefreshAlbumService.cs @@ -324,7 +324,7 @@ namespace NzbDrone.Core.Music public bool RefreshAlbumInfo(List albums, List remoteAlbums, bool forceAlbumRefresh, bool forceUpdateFileTags, DateTime? lastUpdate) { - bool updated = false; + var updated = false; HashSet updatedMusicbrainzAlbums = null; diff --git a/src/NzbDrone.Core/Music/Services/RefreshArtistService.cs b/src/NzbDrone.Core/Music/Services/RefreshArtistService.cs index a093b20b1..433a17bae 100644 --- a/src/NzbDrone.Core/Music/Services/RefreshArtistService.cs +++ b/src/NzbDrone.Core/Music/Services/RefreshArtistService.cs @@ -106,7 +106,7 @@ namespace NzbDrone.Core.Music protected override UpdateResult UpdateEntity(Artist local, Artist remote) { - UpdateResult result = UpdateResult.None; + var result = UpdateResult.None; if (!local.Metadata.Value.Equals(remote.Metadata.Value)) { @@ -324,7 +324,7 @@ namespace NzbDrone.Core.Music private void RefreshSelectedArtists(List artistIds, bool isNew, CommandTrigger trigger) { - bool updated = false; + var updated = false; var artists = _artistService.GetArtists(artistIds); foreach (var artist in artists) diff --git a/src/NzbDrone.Core/Music/Services/RefreshEntityServiceBase.cs b/src/NzbDrone.Core/Music/Services/RefreshEntityServiceBase.cs index ffc8ab07b..27d2d0f13 100644 --- a/src/NzbDrone.Core/Music/Services/RefreshEntityServiceBase.cs +++ b/src/NzbDrone.Core/Music/Services/RefreshEntityServiceBase.cs @@ -114,7 +114,7 @@ namespace NzbDrone.Core.Music public bool RefreshEntityInfo(TEntity local, List remoteList, bool forceChildRefresh, bool forceUpdateFileTags, DateTime? lastUpdate) { - bool updated = false; + var updated = false; LogProgress(local); @@ -201,7 +201,7 @@ namespace NzbDrone.Core.Music public bool RefreshEntityInfo(List localList, List remoteList, bool forceChildRefresh, bool forceUpdateFileTags) { - bool updated = false; + var updated = false; foreach (var entity in localList) { updated |= RefreshEntityInfo(entity, remoteList, forceChildRefresh, forceUpdateFileTags, null); diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index d1151c5f5..2535c9296 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -423,7 +423,7 @@ namespace NzbDrone.Core.Organizer { var pattern = string.Empty; - for (int i = 0; i < tracks.Count; i++) + for (var i = 0; i < tracks.Count; i++) { var patternToReplace = i == 0 ? basePattern : formatPattern; @@ -437,7 +437,7 @@ namespace NzbDrone.Core.Organizer { var pattern = string.Empty; - for (int i = 0; i < tracks.Count; i++) + for (var i = 0; i < tracks.Count; i++) { var patternToReplace = i == 0 ? basePattern : formatPattern; diff --git a/src/NzbDrone.Core/Parser/FingerprintingService.cs b/src/NzbDrone.Core/Parser/FingerprintingService.cs index dbc8bdba7..3304d12f7 100644 --- a/src/NzbDrone.Core/Parser/FingerprintingService.cs +++ b/src/NzbDrone.Core/Parser/FingerprintingService.cs @@ -98,7 +98,7 @@ namespace NzbDrone.Core.Parser path = "fpcalc"; // check that the command exists - Process p = new Process(); + var p = new Process(); p.StartInfo.FileName = path; p.StartInfo.Arguments = "-version"; p.StartInfo.UseShellExecute = false; @@ -110,7 +110,7 @@ namespace NzbDrone.Core.Parser 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); } catch @@ -136,7 +136,7 @@ namespace NzbDrone.Core.Parser return null; } - Process p = new Process(); + var p = new Process(); p.StartInfo.FileName = _fpcalcPath; p.StartInfo.Arguments = $"-version"; p.StartInfo.UseShellExecute = false; @@ -146,7 +146,7 @@ namespace NzbDrone.Core.Parser 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); if (p.ExitCode != 0) @@ -241,7 +241,7 @@ namespace NzbDrone.Core.Parser { if (IsSetup() && File.Exists(file)) { - Process p = new Process(); + var p = new Process(); p.StartInfo.FileName = _fpcalcPath; p.StartInfo.Arguments = $"{_fpcalcArgs} \"{file}\""; p.StartInfo.UseShellExecute = false; @@ -251,14 +251,14 @@ namespace NzbDrone.Core.Parser _logger.Trace("Executing {0} {1}", p.StartInfo.FileName, p.StartInfo.Arguments); - StringBuilder output = new StringBuilder(); - StringBuilder error = new StringBuilder(); + var output = new StringBuilder(); + var error = new StringBuilder(); // see https://stackoverflow.com/questions/139593/processstartinfo-hanging-on-waitforexit-why?lq=1 // this is most likely overkill... - using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false)) + using (var outputWaitHandle = new AutoResetEvent(false)) { - using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false)) + using (var errorWaitHandle = new AutoResetEvent(false)) { DataReceivedEventHandler outputHandler = (sender, e) => { @@ -353,7 +353,7 @@ namespace NzbDrone.Core.Parser .Build(); var sb = new StringBuilder($"client={_acoustIdApiKey}&format=json&meta=recordingids&batch=1", 2000); - for (int i = 0; i < toLookup.Count; i++) + for (var i = 0; i < toLookup.Count; i++) { sb.Append($"&duration.{i}={toLookup[i].Item2.Duration:F0}&fingerprint.{i}={toLookup[i].Item2.Fingerprint}"); } diff --git a/src/NzbDrone.Core/Parser/Model/ParsedAlbumInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedAlbumInfo.cs index 94c2746e0..0fb1b700e 100644 --- a/src/NzbDrone.Core/Parser/Model/ParsedAlbumInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ParsedAlbumInfo.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Parser.Model public override string ToString() { - string albumString = "[Unknown Album]"; + var albumString = "[Unknown Album]"; if (AlbumTitle != null) { diff --git a/src/NzbDrone.Core/Parser/Model/ParsedTrackInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedTrackInfo.cs index f4df7e47f..236957f92 100644 --- a/src/NzbDrone.Core/Parser/Model/ParsedTrackInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ParsedTrackInfo.cs @@ -38,7 +38,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 da3f39b7e..795bb88e7 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -629,9 +629,9 @@ namespace NzbDrone.Core.Parser // TODO: Split into separate method and write unit tests for. var parts = artistName.Split('.'); artistName = ""; - 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) @@ -665,7 +665,7 @@ namespace NzbDrone.Core.Parser artistName = artistName.Trim(' '); - ParsedTrackInfo result = new ParsedTrackInfo(); + var result = new ParsedTrackInfo(); result.ArtistTitle = artistName; result.ArtistTitleInfo = GetArtistTitleInfo(result.ArtistTitle); diff --git a/src/NzbDrone.Core/Parser/QualityParser.cs b/src/NzbDrone.Core/Parser/QualityParser.cs index 532843623..3f0cc4e76 100644 --- a/src/NzbDrone.Core/Parser/QualityParser.cs +++ b/src/NzbDrone.Core/Parser/QualityParser.cs @@ -635,7 +635,7 @@ namespace NzbDrone.Core.Parser result.Revision.IsRepack = true; } - Match versionRegexResult = VersionRegex.Match(normalizedName); + var versionRegexResult = VersionRegex.Match(normalizedName); if (versionRegexResult.Success) { @@ -643,7 +643,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 aa3c31446..82b728507 100644 --- a/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs +++ b/src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs @@ -145,7 +145,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 27dd31dbd..855a9371b 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, Album album) { - 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.Core/Validation/GuidValidator.cs b/src/NzbDrone.Core/Validation/GuidValidator.cs index 152a06fd5..99a491acd 100644 --- a/src/NzbDrone.Core/Validation/GuidValidator.cs +++ b/src/NzbDrone.Core/Validation/GuidValidator.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Validation return false; } - return Guid.TryParse(context.PropertyValue.ToString(), out Guid guidOutput); + return Guid.TryParse(context.PropertyValue.ToString(), out var guidOutput); } } } 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 f3c12023f..a6a07118b 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 = Environment.CurrentManagedThreadId; + var threadId = Environment.CurrentManagedThreadId; 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 7855c76b8..00654ce6d 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:\\Lidarr\\".AsOsAgnostic(); + var targetFolder = "c:\\Lidarr\\".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:\\Lidarr\\".AsOsAgnostic(); - string targetProcess = "c:\\Lidarr\\Lidarr.Console".AsOsAgnostic().ProcessNameToExe(); + var targetFolder = "c:\\Lidarr\\".AsOsAgnostic(); + var targetProcess = "c:\\Lidarr\\Lidarr.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 6d23fc968..ffea890bf 100644 --- a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs +++ b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs @@ -150,7 +150,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/ServiceHelpers/ServiceInstall/ServiceHelper.cs b/src/ServiceHelpers/ServiceInstall/ServiceHelper.cs index 923b2d076..808111481 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 c54ba9258..f51919dad 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); }