Use 'var' instead of explicit type

(cherry picked from commit 12374f7f0038e5b25548f5ab3f71122410832393)
pull/8624/head
Bogdan 12 months ago
parent 8762588ef0
commit c987824174

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

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
@ -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)

@ -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<string>();
for (int i = 0; i < 10; i++)
for (var i = 0; i < 10; i++)
{
_cachedString.Get("key",
() =>

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

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

@ -786,7 +786,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();
@ -820,7 +820,7 @@ namespace NzbDrone.Common.Test.Http
{
try
{
string url = $"https://{_httpBinHost}/response-headers?Set-Cookie={Uri.EscapeDataString(malformedCookie)}";
var url = $"https://{_httpBinHost}/response-headers?Set-Cookie={Uri.EscapeDataString(malformedCookie)}";
var requestSet = new HttpRequest(url);
requestSet.AllowAutoRedirect = false;

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

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

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

@ -126,9 +126,9 @@ namespace NzbDrone.Common.Extensions
private static IEnumerable<T> InternalDropLast<T>(IEnumerable<T> source, int n)
{
Queue<T> buffer = new Queue<T>(n + 1);
var buffer = new Queue<T>(n + 1);
foreach (T x in source)
foreach (var x in source)
{
buffer.Enqueue(x);

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

@ -245,13 +245,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])
{

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

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

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

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

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

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

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

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

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

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

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

@ -79,7 +79,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);

@ -108,7 +108,7 @@ namespace NzbDrone.Core.Test.Extras
private void WithExistingFiles(List<string> files)
{
foreach (string file in files)
foreach (var file in files)
{
WithExistingFile(file);
}

@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles
results.Count.Should().Be(expectedOutputs.Length);
for (int i = 0; i < expectedOutputs.Length; i++)
for (var i = 0; i < expectedOutputs.Length; i++)
{
results[i].RelativePath.AsOsAgnostic().PathEquals(expectedOutputs[i].AsOsAgnostic()).Should().Be(true);
}
@ -141,7 +141,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles
results.Count.Should().Be(expectedOutputs.Length);
for (int i = 0; i < expectedOutputs.Length; i++)
for (var i = 0; i < expectedOutputs.Length; i++)
{
results[i].RelativePath.AsOsAgnostic().PathEquals(expectedOutputs[i].AsOsAgnostic()).Should().Be(true);
}

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

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

@ -211,7 +211,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
_capabilities.SupportedMovieSearchParameters = new[] { "q" };
_capabilities.TextSearchEngine = "raw";
MovieSearchCriteria movieRawSearchCriteria = new MovieSearchCriteria
var movieRawSearchCriteria = new MovieSearchCriteria
{
Movie = new Movies.Movie { Title = "Some Movie & Title: Words", Year = 2021, TmdbId = 123 },
SceneTitles = new List<string> { "Some Movie & Title: Words" }
@ -232,7 +232,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
_capabilities.SupportedMovieSearchParameters = new[] { "q" };
_capabilities.TextSearchEngine = "sphinx";
MovieSearchCriteria movieRawSearchCriteria = new MovieSearchCriteria
var movieRawSearchCriteria = new MovieSearchCriteria
{
Movie = new Movies.Movie { Title = "Some Movie & Title: Words", Year = 2021, TmdbId = 123 },
SceneTitles = new List<string> { "Some Movie & Title: Words" }

@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test.IndexerTests.PTPTests
{
var authResponse = new PassThePopcornAuthResponse { Result = "Ok" };
System.IO.StringWriter authStream = new System.IO.StringWriter();
var authStream = new System.IO.StringWriter();
Json.Serialize(authResponse, authStream);
var responseJson = ReadAllText(fileName);

@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.InstrumentationTests
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();
}

@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Specifications
{
_localMovie.Path = paths.First().ToString().AsOsAgnostic();
string[] filePaths = paths.Cast<string>().Select(x => x.AsOsAgnostic()).ToArray();
var filePaths = paths.Cast<string>().Select(x => x.AsOsAgnostic()).ToArray();
Mocker.GetMock<IDiskProvider>()
.Setup(s => s.GetFiles(_localMovie.Path.GetParentPath(), SearchOption.TopDirectoryOnly))
@ -69,7 +69,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Specifications
{
_localMovie.Path = paths.First().ToString().AsOsAgnostic();
string[] filePaths = paths.Cast<string>().Select(x => x.AsOsAgnostic()).ToArray();
var filePaths = paths.Cast<string>().Select(x => x.AsOsAgnostic()).ToArray();
Mocker.GetMock<IDiskProvider>()
.Setup(s => s.GetFiles(_localMovie.Path.GetParentPath(), SearchOption.TopDirectoryOnly))
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Specifications
{
_localMovie.Path = paths.First().ToString().AsOsAgnostic();
string[] filePaths = paths.Cast<string>().Select(x => x.AsOsAgnostic()).ToArray();
var filePaths = paths.Cast<string>().Select(x => x.AsOsAgnostic()).ToArray();
Mocker.GetMock<IDiskProvider>()
.Setup(s => s.GetFiles(_localMovie.Path.GetParentPath(), SearchOption.TopDirectoryOnly))
@ -105,7 +105,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Specifications
{
_localMovie.Path = paths.First().ToString().AsOsAgnostic();
string[] filePaths = paths.Cast<string>().Select(x => x.AsOsAgnostic()).ToArray();
var filePaths = paths.Cast<string>().Select(x => x.AsOsAgnostic()).ToArray();
Mocker.GetMock<IDiskProvider>()
.Setup(s => s.GetFiles(_localMovie.Path.GetParentPath(), SearchOption.TopDirectoryOnly))

@ -40,13 +40,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(Encoding.Default.GetBytes(hash));
@ -65,17 +65,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]);
}

@ -4,7 +4,6 @@ using FluentAssertions.Execution;
using NUnit.Framework;
using NzbDrone.Core.Languages;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ParserTests
@ -72,7 +71,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("[sam] Toward the Terra (1980) [BD 1080p TrueHD].mkv", "Toward the Terra", "sam", 1980)]
public void should_parse_anime_movie_title(string postTitle, string title, string releaseGroup, int year)
{
ParsedMovieInfo movie = Parser.Parser.ParseMovieTitle(postTitle);
var movie = Parser.Parser.ParseMovieTitle(postTitle);
using (new AssertionScope())
{
movie.PrimaryMovieTitle.Should().Be(title);
@ -89,7 +88,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("[Kulot] Violet Evergarden Gaiden Eien to Jidou Shuki Ningyou [Dual-Audio][BDRip 1920x804 HEVC FLACx2] [91FC62A8].mkv", "Violet Evergarden Gaiden Eien to Jidou Shuki Ningyou", "Kulot")]
public void should_parse_anime_movie_title_without_year(string postTitle, string title, string releaseGroup)
{
ParsedMovieInfo movie = Parser.Parser.ParseMovieTitle(postTitle);
var movie = Parser.Parser.ParseMovieTitle(postTitle);
using (new AssertionScope())
{
movie.PrimaryMovieTitle.Should().Be(title);
@ -127,7 +126,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("Kick.Ass.2.2013.German.DTS.DL.720p.BluRay.x264-Pate_", "Kick Ass 2", "", 2013, Description = "underscore at the end")]
public void should_parse_german_movie(string postTitle, string title, string edition, int year)
{
ParsedMovieInfo movie = Parser.Parser.ParseMovieTitle(postTitle);
var movie = Parser.Parser.ParseMovieTitle(postTitle);
using (new AssertionScope())
{
movie.PrimaryMovieTitle.Should().Be(title);

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using NUnit.Framework;
@ -25,9 +25,9 @@ namespace NzbDrone.Core.Test.ParserTests.RomanNumeralTests
[Order(0)]
public void should_convert_arabic_numeral_to_roman_numeral([Range(1, 20)] int arabicNumeral)
{
RomanNumeral romanNumeral = new RomanNumeral(arabicNumeral);
var romanNumeral = new RomanNumeral(arabicNumeral);
string expectedValue = _arabicToRomanNumeralsMapping[arabicNumeral];
var expectedValue = _arabicToRomanNumeralsMapping[arabicNumeral];
Assert.AreEqual(romanNumeral.ToRomanNumeral(), expectedValue);
}
@ -36,9 +36,9 @@ namespace NzbDrone.Core.Test.ParserTests.RomanNumeralTests
[Order(1)]
public void should_convert_roman_numeral_to_arabic_numeral([Range(1, 20)] int arabicNumeral)
{
RomanNumeral romanNumeral = new RomanNumeral(_arabicToRomanNumeralsMapping[arabicNumeral]);
var romanNumeral = new RomanNumeral(_arabicToRomanNumeralsMapping[arabicNumeral]);
int expectecdValue = arabicNumeral;
var expectecdValue = arabicNumeral;
Assert.AreEqual(romanNumeral.ToInt(), expectecdValue);
}

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
@ -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];

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

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

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

@ -1,4 +1,4 @@
using System.Data;
using System.Data;
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
@ -17,11 +17,11 @@ namespace NzbDrone.Core.Datastore.Migration
private void ConvertConfig(IDbConnection conn, IDbTransaction tran)
{
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())
{
while (namingConfigReader.Read())
{
@ -36,7 +36,7 @@ namespace NzbDrone.Core.Datastore.Migration
var movieFolderFormat = string.Format("{0} {1}", movieTitlePattern, movieYearPattern);
using (IDbCommand updateCmd = conn.CreateCommand())
using (var updateCmd = conn.CreateCommand())
{
var text = string.Format("UPDATE \"NamingConfig\" " +
"SET \"StandardMovieFormat\" = '{0}', " +

@ -1,4 +1,4 @@
using System.Data;
using System.Data;
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
@ -15,11 +15,11 @@ namespace NzbDrone.Core.Datastore.Migration
private void SetSortTitles(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand getSeriesCmd = conn.CreateCommand())
using (var getSeriesCmd = conn.CreateCommand())
{
getSeriesCmd.Transaction = tran;
getSeriesCmd.CommandText = @"SELECT ""Id"", ""Title"" FROM ""Movies""";
using (IDataReader seriesReader = getSeriesCmd.ExecuteReader())
using (var seriesReader = getSeriesCmd.ExecuteReader())
{
while (seriesReader.Read())
{
@ -28,7 +28,7 @@ namespace NzbDrone.Core.Datastore.Migration
var sortTitle = Parser.Parser.NormalizeTitle(title).ToLower();
using (IDbCommand updateCmd = conn.CreateCommand())
using (var updateCmd = conn.CreateCommand())
{
updateCmd.Transaction = tran;
updateCmd.CommandText = "UPDATE \"Movies\" SET \"SortTitle\" = ? WHERE \"Id\" = ?";

@ -1,4 +1,4 @@
using System.Data;
using System.Data;
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
@ -14,11 +14,11 @@ namespace NzbDrone.Core.Datastore.Migration
private void SetSortTitles(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand getSeriesCmd = conn.CreateCommand())
using (var getSeriesCmd = conn.CreateCommand())
{
getSeriesCmd.Transaction = tran;
getSeriesCmd.CommandText = @"SELECT ""Id"", ""Title"" FROM ""Movies""";
using (IDataReader seriesReader = getSeriesCmd.ExecuteReader())
using (var seriesReader = getSeriesCmd.ExecuteReader())
{
while (seriesReader.Read())
{
@ -27,7 +27,7 @@ namespace NzbDrone.Core.Datastore.Migration
var sortTitle = Parser.Parser.NormalizeTitle(title).ToLower();
using (IDbCommand updateCmd = conn.CreateCommand())
using (var updateCmd = conn.CreateCommand())
{
updateCmd.Transaction = tran;
updateCmd.CommandText = "UPDATE \"Movies\" SET \"SortTitle\" = ? WHERE \"Id\" = ?";

@ -1,4 +1,4 @@
using System.Data;
using System.Data;
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
@ -16,11 +16,11 @@ namespace NzbDrone.Core.Datastore.Migration
private void SetSortTitles(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand getSeriesCmd = conn.CreateCommand())
using (var getSeriesCmd = conn.CreateCommand())
{
getSeriesCmd.Transaction = tran;
getSeriesCmd.CommandText = @"SELECT ""Id"", ""RelativePath"" FROM ""MovieFiles""";
using (IDataReader seriesReader = getSeriesCmd.ExecuteReader())
using (var seriesReader = getSeriesCmd.ExecuteReader())
{
while (seriesReader.Read())
{
@ -36,7 +36,7 @@ namespace NzbDrone.Core.Datastore.Migration
edition = result.Edition ?? Parser.Parser.ParseEdition(result.SimpleReleaseTitle);
}
using (IDbCommand updateCmd = conn.CreateCommand())
using (var updateCmd = conn.CreateCommand())
{
updateCmd.Transaction = tran;
updateCmd.CommandText = "UPDATE \"MovieFiles\" SET \"Edition\" = ? WHERE \"Id\" = ?";

@ -1,4 +1,4 @@
using System.Data;
using System.Data;
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
@ -14,11 +14,11 @@ namespace NzbDrone.Core.Datastore.Migration
private void SetTitleSlug(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand getSeriesCmd = conn.CreateCommand())
using (var getSeriesCmd = conn.CreateCommand())
{
getSeriesCmd.Transaction = tran;
getSeriesCmd.CommandText = @"SELECT ""Id"", ""Title"", ""Year"", ""TmdbId"" FROM ""Movies""";
using (IDataReader seriesReader = getSeriesCmd.ExecuteReader())
using (var seriesReader = getSeriesCmd.ExecuteReader())
{
while (seriesReader.Read())
{
@ -29,7 +29,7 @@ namespace NzbDrone.Core.Datastore.Migration
var titleSlug = Parser.Parser.ToUrlSlug(title + "-" + tmdbId);
using (IDbCommand updateCmd = conn.CreateCommand())
using (var updateCmd = conn.CreateCommand())
{
updateCmd.Transaction = tran;
updateCmd.CommandText = "UPDATE \"Movies\" SET \"TitleSlug\" = ? WHERE \"Id\" = ?";

@ -1,4 +1,4 @@
using System.Data;
using System.Data;
using System.Text;
using System.Text.RegularExpressions;
using FluentMigrator;
@ -16,18 +16,18 @@ namespace NzbDrone.Core.Datastore.Migration
private void SetTitleSlug(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand getSeriesCmd = conn.CreateCommand())
using (var getSeriesCmd = conn.CreateCommand())
{
getSeriesCmd.Transaction = tran;
getSeriesCmd.CommandText = @"SELECT ""Id"", ""Value"" FROM ""Config"" WHERE ""Key"" = 'filedate'";
using (IDataReader seriesReader = getSeriesCmd.ExecuteReader())
using (var seriesReader = getSeriesCmd.ExecuteReader())
{
while (seriesReader.Read())
{
var id = seriesReader.GetInt32(0);
var value = seriesReader.GetString(1);
using (IDbCommand updateCmd = conn.CreateCommand())
using (var updateCmd = conn.CreateCommand())
{
updateCmd.Transaction = tran;
updateCmd.CommandText = "UPDATE \"Config\" SET \"Value\" = 'Release' WHERE \"Id\" = ?";

@ -14,7 +14,7 @@ namespace NzbDrone.Core.Datastore.Migration
private void DeleteUniqueIndex(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand getSeriesCmd = conn.CreateCommand())
using (var getSeriesCmd = conn.CreateCommand())
{
getSeriesCmd.Transaction = tran;
getSeriesCmd.CommandText = @"DROP INDEX ""IX_Movies_ImdbId""";

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using FluentMigrator;
@ -193,8 +193,8 @@ namespace NzbDrone.Core.Datastore.Migration
{
while (definitionsReader.Read())
{
int id = definitionsReader.GetInt32(0);
int quality = definitionsReader.GetInt32(1);
var id = definitionsReader.GetInt32(0);
var quality = definitionsReader.GetInt32(1);
definitions.Add(new QualityDefinition125 { Id = id, Quality = quality });
}
}

@ -1,4 +1,4 @@
using System.Data;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
@ -26,12 +26,12 @@ namespace NzbDrone.Core.Datastore.Migration
private void AddExisting(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand getSeriesCmd = conn.CreateCommand())
using (var getSeriesCmd = conn.CreateCommand())
{
getSeriesCmd.Transaction = tran;
getSeriesCmd.CommandText = @"SELECT ""Key"", ""Value"" FROM ""Config"" WHERE ""Key"" = 'importexclusions'";
TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
using (IDataReader seriesReader = getSeriesCmd.ExecuteReader())
var textInfo = new CultureInfo("en-US", false).TextInfo;
using (var seriesReader = getSeriesCmd.ExecuteReader())
{
while (seriesReader.Read())
{
@ -45,7 +45,7 @@ namespace NzbDrone.Core.Datastore.Migration
textInfo.ToTitleCase(string.Join(" ", x.Split('-').DropLast(1))));
}).ToList();
using (IDbCommand updateCmd = conn.CreateCommand())
using (var updateCmd = conn.CreateCommand())
{
updateCmd.Transaction = tran;
updateCmd.CommandText = "INSERT INTO \"ImportExclusions\" (tmdbid, MovieTitle) VALUES " + string.Join(", ", importExclusions);

@ -38,12 +38,12 @@ namespace NzbDrone.Core.Datastore.Migration
var languageConverter = new EmbeddedDocumentConverter<List<Language>>(new LanguageIntConverter());
var profileLanguages = new Dictionary<int, int>();
using (IDbCommand getProfileCmd = conn.CreateCommand())
using (var getProfileCmd = conn.CreateCommand())
{
getProfileCmd.Transaction = tran;
getProfileCmd.CommandText = "SELECT \"Id\", \"Language\" FROM \"Profiles\"";
IDataReader profilesReader = getProfileCmd.ExecuteReader();
var profilesReader = getProfileCmd.ExecuteReader();
while (profilesReader.Read())
{
var profileId = profilesReader.GetInt32(0);
@ -65,11 +65,11 @@ namespace NzbDrone.Core.Datastore.Migration
var movieLanguages = new Dictionary<int, int>();
using (IDbCommand getSeriesCmd = conn.CreateCommand())
using (var getSeriesCmd = conn.CreateCommand())
{
getSeriesCmd.Transaction = tran;
getSeriesCmd.CommandText = @"SELECT ""Id"", ""ProfileId"" FROM ""Movies""";
using (IDataReader moviesReader = getSeriesCmd.ExecuteReader())
using (var moviesReader = getSeriesCmd.ExecuteReader())
{
while (moviesReader.Read())
{
@ -86,11 +86,11 @@ namespace NzbDrone.Core.Datastore.Migration
var movieFileLanguages = new Dictionary<int, List<Language>>();
var releaseLanguages = new Dictionary<string, List<Language>>();
using (IDbCommand getSeriesCmd = conn.CreateCommand())
using (var getSeriesCmd = conn.CreateCommand())
{
getSeriesCmd.Transaction = tran;
getSeriesCmd.CommandText = @"SELECT ""Id"", ""MovieId"", ""SceneName"", ""MediaInfo"" FROM ""MovieFiles""";
using (IDataReader movieFilesReader = getSeriesCmd.ExecuteReader())
using (var movieFilesReader = getSeriesCmd.ExecuteReader())
{
while (movieFilesReader.Read())
{
@ -136,11 +136,11 @@ namespace NzbDrone.Core.Datastore.Migration
var historyLanguages = new Dictionary<int, List<Language>>();
using (IDbCommand getSeriesCmd = conn.CreateCommand())
using (var getSeriesCmd = conn.CreateCommand())
{
getSeriesCmd.Transaction = tran;
getSeriesCmd.CommandText = @"SELECT ""Id"", ""SourceTitle"", ""MovieId"" FROM ""History""";
using (IDataReader historyReader = getSeriesCmd.ExecuteReader())
using (var historyReader = getSeriesCmd.ExecuteReader())
{
while (historyReader.Read())
{
@ -173,11 +173,11 @@ namespace NzbDrone.Core.Datastore.Migration
var blacklistLanguages = new Dictionary<int, List<Language>>();
using (IDbCommand getSeriesCmd = conn.CreateCommand())
using (var getSeriesCmd = conn.CreateCommand())
{
getSeriesCmd.Transaction = tran;
getSeriesCmd.CommandText = @"SELECT ""Id"", ""SourceTitle"", ""MovieId"" FROM ""Blacklist""";
using (IDataReader blacklistReader = getSeriesCmd.ExecuteReader())
using (var blacklistReader = getSeriesCmd.ExecuteReader())
{
while (blacklistReader.Read())
{
@ -209,7 +209,7 @@ namespace NzbDrone.Core.Datastore.Migration
var movieFileIds = group.Select(v => v.ToString()).Join(",");
using (IDbCommand updateMovieFilesCmd = conn.CreateCommand())
using (var updateMovieFilesCmd = conn.CreateCommand())
{
updateMovieFilesCmd.Transaction = tran;
if (conn.GetType().FullName == "Npgsql.NpgsqlConnection")
@ -235,7 +235,7 @@ namespace NzbDrone.Core.Datastore.Migration
var historyIds = group.Select(v => v.ToString()).Join(",");
using (IDbCommand updateHistoryCmd = conn.CreateCommand())
using (var updateHistoryCmd = conn.CreateCommand())
{
updateHistoryCmd.Transaction = tran;
if (conn.GetType().FullName == "Npgsql.NpgsqlConnection")
@ -261,7 +261,7 @@ namespace NzbDrone.Core.Datastore.Migration
var blacklistIds = group.Select(v => v.ToString()).Join(",");
using (IDbCommand updateBlacklistCmd = conn.CreateCommand())
using (var updateBlacklistCmd = conn.CreateCommand())
{
updateBlacklistCmd.Transaction = tran;
if (conn.GetType().FullName == "Npgsql.NpgsqlConnection")

@ -77,7 +77,7 @@ namespace NzbDrone.Core.Datastore.Migration
foreach (var profile in profiles.OrderBy(p => p.Id))
{
using (IDbCommand insertNewLanguageProfileCmd = conn.CreateCommand())
using (var insertNewLanguageProfileCmd = conn.CreateCommand())
{
insertNewLanguageProfileCmd.Transaction = tran;

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

@ -748,7 +748,7 @@ namespace NzbDrone.Core.Datastore.Migration
var tokens = mediaInfoLanguages.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).ToList();
var cultures = CultureInfo.GetCultures(CultureTypes.NeutralCultures);
for (int i = 0; i < tokens.Count; i++)
for (var i = 0; i < tokens.Count; i++)
{
if (tokens[i] == "Swedis")
{

@ -45,10 +45,10 @@ namespace NzbDrone.Core.Datastore.Migration
return;
}
foreach (NotificationEntity201 notification in discordSlackNotifications)
foreach (var notification in discordSlackNotifications)
{
SlackNotificationSettings201 settings = JsonSerializer.Deserialize<SlackNotificationSettings201>(notification.Settings, _serializerSettings);
DiscordNotificationSettings201 discordSettings = new DiscordNotificationSettings201
var settings = JsonSerializer.Deserialize<SlackNotificationSettings201>(notification.Settings, _serializerSettings);
var discordSettings = new DiscordNotificationSettings201
{
Avatar = settings.Icon,
GrabFields = new List<int> { 0, 1, 2, 3, 5, 6, 7, 8, 9 },

@ -60,7 +60,7 @@ namespace NzbDrone.Core.Datastore.Migration
{
while (definitionsReader.Read())
{
string path = definitionsReader.GetString(0);
var path = definitionsReader.GetString(0);
rootPaths.Add(path);
}
}

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

@ -203,7 +203,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;

@ -39,7 +39,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())
{
@ -72,7 +72,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())
{

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

@ -1,4 +1,4 @@
namespace NzbDrone.Core.Download.Clients.FreeboxDownload
namespace NzbDrone.Core.Download.Clients.FreeboxDownload
{
public static class EncodingForBase64
{
@ -9,7 +9,7 @@
return null;
}
byte[] textAsBytes = System.Text.Encoding.UTF8.GetBytes(text);
var textAsBytes = System.Text.Encoding.UTF8.GetBytes(text);
return System.Convert.ToBase64String(textAsBytes);
}
@ -20,7 +20,7 @@
return null;
}
byte[] textAsBytes = System.Convert.FromBase64String(encodedText);
var textAsBytes = System.Convert.FromBase64String(encodedText);
return System.Text.Encoding.UTF8.GetString(textAsBytes);
}
}

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

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

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

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

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

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

@ -83,7 +83,7 @@ namespace NzbDrone.Core.Extras
continue;
}
for (int i = 0; i < _extraFileManagers.Count; i++)
for (var i = 0; i < _extraFileManagers.Count; i++)
{
if (_extraFileManagers[i].CanImportFile(localMovie, movieFile, file, extension, isReadOnly))
{
@ -93,7 +93,7 @@ namespace NzbDrone.Core.Extras
}
}
for (int i = 0; i < _extraFileManagers.Count; i++)
for (var i = 0; i < _extraFileManagers.Count; i++)
{
_extraFileManagers[i].ImportFiles(localMovie, movieFile, managedFiles[i], isReadOnly);
}

@ -133,7 +133,7 @@ namespace NzbDrone.Core.Extras.Others
}
}
foreach (string file in matchingFiles)
foreach (var file in matchingFiles)
{
try
{

@ -177,7 +177,7 @@ namespace NzbDrone.Core.Extras.Subtitles
var subtitleFiles = new List<SubtitleFile>();
foreach (string file in matchingFiles)
foreach (var file in matchingFiles)
{
var language = LanguageParser.ParseSubtitleLanguage(file);
var extension = Path.GetExtension(file);

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -95,17 +95,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;

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

@ -35,7 +35,7 @@ namespace NzbDrone.Core.ImportLists.CouchPotato
foreach (var item in responseData)
{
int tmdbid = item.info?.tmdb_id ?? 0;
var tmdbid = item.info?.tmdb_id ?? 0;
// Fix weird error reported by Madmanali93
if (item.type != null && item.releases != null)
@ -54,7 +54,7 @@ namespace NzbDrone.Core.ImportLists.CouchPotato
{
// snatched,missing,available,downloaded
// done,seeding
bool isCompleted = item.releases.Any(rel => (rel.status == "done" || rel.status == "seeding"));
var isCompleted = item.releases.Any(rel => (rel.status == "done" || rel.status == "seeding"));
if (!isCompleted)
{
movies.AddIfNotNull(new ImportListMovie()

@ -68,7 +68,7 @@ namespace NzbDrone.Core.ImportLists
var importListLocal = importList;
var blockedLists = _importListStatusService.GetBlockedProviders().ToDictionary(v => v.ProviderId, v => v);
if (blockedLists.TryGetValue(importList.Definition.Id, out ImportListStatus blockedListStatus))
if (blockedLists.TryGetValue(importList.Definition.Id, out var blockedListStatus))
{
_logger.Debug("Temporarily ignoring list {0} till {1} due to recent failures.", importList.Definition.Name, blockedListStatus.DisabledTill.Value.ToLocalTime());
result.AnyFailure |= true; // Ensure we don't clean if a list is down

@ -54,7 +54,7 @@ namespace NzbDrone.Core.ImportLists
try
{
for (int i = 0; i < pageableRequestChain.Tiers; i++)
for (var i = 0; i < pageableRequestChain.Tiers; i++)
{
var pageableRequests = pageableRequestChain.GetTier(i);
foreach (var pageableRequest in pageableRequests)

@ -36,7 +36,7 @@ namespace NzbDrone.Core.ImportLists.Plex
var tmdbIdString = FindGuid(item.Guids, "tmdb");
var imdbId = FindGuid(item.Guids, "imdb");
int.TryParse(tmdbIdString, out int tmdbId);
int.TryParse(tmdbIdString, out var tmdbId);
movies.AddIfNotNull(new ImportListMovie()
{

@ -68,7 +68,7 @@ namespace NzbDrone.Core.IndexerSearch
};
pagingSpec.FilterExpressions.Add(v => v.Monitored == true);
List<Movie> movies = _movieService.MoviesWithoutFiles(pagingSpec).Records.ToList();
var movies = _movieService.MoviesWithoutFiles(pagingSpec).Records.ToList();
var queue = _queueService.GetQueue().Where(q => q.Movie != null).Select(q => q.Movie.Id);
var missing = movies.Where(e => !queue.Contains(e.Id)).ToList();
@ -88,7 +88,7 @@ namespace NzbDrone.Core.IndexerSearch
pagingSpec.FilterExpressions.Add(v => v.Monitored == true);
List<Movie> movies = _movieCutoffService.MoviesWhereCutoffUnmet(pagingSpec).Records.ToList();
var movies = _movieCutoffService.MoviesWhereCutoffUnmet(pagingSpec).Records.ToList();
var queue = _queueService.GetQueue().Where(q => q.Movie != null).Select(q => q.Movie.Id);
var missing = movies.Where(e => !queue.Contains(e.Id)).ToList();

@ -113,7 +113,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);

@ -184,7 +184,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)
{

@ -147,7 +147,7 @@ namespace NzbDrone.Core.MediaCover
private bool EnsureCovers(Movie movie)
{
bool updated = false;
var updated = false;
var toResize = new List<Tuple<MediaCover, bool>>();
foreach (var cover in movie.MovieMetadata.Value.Images)

@ -329,7 +329,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Manual
var imported = new List<ImportResult>();
var importedTrackedDownload = new List<ManuallyImportedFile>();
for (int i = 0; i < message.Files.Count; i++)
for (var i = 0; i < message.Files.Count; i++)
{
_logger.ProgressTrace("Processing file {0} of {1}", i + 1, message.Files.Count);

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

@ -125,8 +125,8 @@ namespace NzbDrone.Core.Messaging.Commands
_cancellationTokenSource = new CancellationTokenSource();
var envLimit = Environment.GetEnvironmentVariable("THREAD_LIMIT") ?? $"{THREAD_LIMIT}";
int threadLimit = THREAD_LIMIT;
if (int.TryParse(envLimit, out int parsedLimit))
var threadLimit = THREAD_LIMIT;
if (int.TryParse(envLimit, out var parsedLimit))
{
threadLimit = parsedLimit;
}
@ -136,7 +136,7 @@ namespace NzbDrone.Core.Messaging.Commands
_logger.Info("Starting {} threads for tasks.", threadLimit);
for (int i = 0; i < threadLimit + 1; i++)
for (var i = 0; i < threadLimit + 1; i++)
{
var thread = new Thread(ExecuteCommands);
thread.Start();

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

@ -35,7 +35,7 @@ namespace NzbDrone.Core.MetadataSource
public int Compare(Movie x, Movie y)
{
int result = 0;
var result = 0;
// Prefer exact matches
result = Compare(x, y, s => CleanPunctuation(s.Title).Equals(CleanPunctuation(SearchQuery)));

@ -427,7 +427,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
{
var slug = lowerTitle.Split(':')[1].Trim();
string imdbid = slug;
var imdbid = slug;
if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace))
{
@ -449,7 +449,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
{
var slug = lowerTitle.Split(':')[1].Trim();
int tmdbid = -1;
var tmdbid = -1;
if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || !int.TryParse(slug, out tmdbid))
{

@ -70,7 +70,7 @@ namespace NzbDrone.Core.Movies.AlternativeTitles
public List<AlternativeTitle> UpdateTitles(List<AlternativeTitle> titles, MovieMetadata movieMetadata)
{
int movieMetadataId = movieMetadata.Id;
var movieMetadataId = movieMetadata.Id;
// First update the movie ids so we can correlate them later.
titles.ForEach(t => t.MovieMetadataId = movieMetadataId);

@ -59,7 +59,7 @@ namespace NzbDrone.Core.Movies.Credits
public List<Credit> UpdateCredits(List<Credit> credits, MovieMetadata movieMetadata)
{
int movieMetadataId = movieMetadata.Id;
var movieMetadataId = movieMetadata.Id;
// First update the movie ids so we can correlate them later.
credits.ForEach(t => t.MovieMetadataId = movieMetadataId);

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

@ -43,7 +43,7 @@ namespace NzbDrone.Core.Movies.Translations
public List<MovieTranslation> UpdateTranslations(List<MovieTranslation> translations, MovieMetadata movieMetadata)
{
int movieMetadataId = movieMetadata.Id;
var movieMetadataId = movieMetadata.Id;
// First update the movie ids so we can correlate them later
translations.ForEach(t => t.MovieMetadataId = movieMetadataId);

@ -247,7 +247,7 @@ namespace NzbDrone.Core.Notifications.Discord
{
var attachments = new List<Embed>();
foreach (RenamedMovieFile renamedFile in renamedFiles)
foreach (var renamedFile in renamedFiles)
{
attachments.Add(new Embed
{

@ -300,7 +300,7 @@ namespace NzbDrone.Core.Notifications
public void Handle(MoviesDeletedEvent message)
{
foreach (Movie movie in message.Movies)
foreach (var movie in message.Movies)
{
var deleteMessage = new MovieDeleteMessage(movie, message.DeleteFiles);

@ -60,7 +60,7 @@ namespace NzbDrone.Core.Notifications.Slack
{
var attachments = new List<Attachment>();
foreach (RenamedMovieFile renamedFile in renamedFiles)
foreach (var renamedFile in renamedFiles)
{
attachments.Add(new Attachment
{

@ -224,11 +224,11 @@ namespace NzbDrone.Core.Organizer
{
var colonReplacementFormat = colonReplacement.GetFormatString();
string result = name;
var result = name;
string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" };
string[] goodCharacters = { "+", "+", "", "", "!", "-", colonReplacementFormat, "", "" };
for (int i = 0; i < badCharacters.Length; i++)
for (var i = 0; i < badCharacters.Length; i++)
{
result = result.Replace(badCharacters[i], replace ? goodCharacters[i] : string.Empty);
}
@ -414,7 +414,7 @@ namespace NzbDrone.Core.Organizer
}
}
for (int i = 0; i < tokens.Count; i++)
for (var i = 0; i < tokens.Count; i++)
{
try
{

@ -393,7 +393,7 @@ namespace NzbDrone.Core.Parser
return isoLanguage?.Language ?? Language.Unknown;
}
foreach (Language language in Language.All)
foreach (var language in Language.All)
{
if (simpleFilename.EndsWith(language.ToString(), StringComparison.OrdinalIgnoreCase))
{

@ -437,7 +437,7 @@ namespace NzbDrone.Core.Parser
value = Regex.Replace(value, @"\s", "-", RegexOptions.Compiled);
// Should invalid characters be replaced with dash or empty string?
string replaceCharacter = invalidDashReplacement ? "-" : string.Empty;
var replaceCharacter = invalidDashReplacement ? "-" : string.Empty;
// Remove invalid chars
value = Regex.Replace(value, @"[^a-z0-9\s-_]", replaceCharacter, RegexOptions.Compiled);
@ -593,9 +593,9 @@ namespace NzbDrone.Core.Parser
var parts = movieName.Split('.');
movieName = "";
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)

@ -95,9 +95,9 @@ namespace NzbDrone.Core.Parser.RomanNumerals
}
text = text.ToUpper();
int len = 0;
var len = 0;
for (int i = 0; i < 3; i++)
for (var i = 0; i < 3; i++)
{
if (text.StartsWith(Thousands[i]))
{
@ -113,7 +113,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals
len = 0;
}
for (int i = 0; i < 9; i++)
for (var i = 0; i < 9; i++)
{
if (text.StartsWith(Hundreds[i]))
{
@ -129,7 +129,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals
len = 0;
}
for (int i = 0; i < 9; i++)
for (var i = 0; i < 9; i++)
{
if (text.StartsWith(Tens[i]))
{
@ -145,7 +145,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals
len = 0;
}
for (int i = 0; i < 9; i++)
for (var i = 0; i < 9; i++)
{
if (text.StartsWith(Units[i]))
{

@ -26,32 +26,32 @@ namespace NzbDrone.Core.Parser.RomanNumerals
_arabicRomanNumeralsMapping = new HashSet<ArabicRomanNumeral>();
_simpleArabicNumeralMappings = new Dictionary<SimpleArabicNumeral, SimpleRomanNumeral>();
foreach (int arabicNumeral in Enumerable.Range(1, DICTIONARY_PREPOPULATION_SIZE + 1))
foreach (var arabicNumeral in Enumerable.Range(1, DICTIONARY_PREPOPULATION_SIZE + 1))
{
GenerateRomanNumerals(arabicNumeral, out var romanNumeralAsString, out var arabicNumeralAsString);
ArabicRomanNumeral arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeralAsString);
var arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeralAsString);
_arabicRomanNumeralsMapping.Add(arm);
SimpleArabicNumeral sam = new SimpleArabicNumeral(arabicNumeral);
SimpleRomanNumeral srm = new SimpleRomanNumeral(romanNumeralAsString);
var sam = new SimpleArabicNumeral(arabicNumeral);
var srm = new SimpleRomanNumeral(romanNumeralAsString);
_simpleArabicNumeralMappings.Add(sam, srm);
}
}
private static void GenerateRomanNumerals(int arabicNumeral, out string romanNumeral, out string arabicNumeralAsString)
{
RomanNumeral romanNumeralObject = new RomanNumeral(arabicNumeral);
var romanNumeralObject = new RomanNumeral(arabicNumeral);
romanNumeral = romanNumeralObject.ToRomanNumeral();
arabicNumeralAsString = Convert.ToString(arabicNumeral);
}
private static HashSet<ArabicRomanNumeral> GenerateAdditionalMappings(int offset, int length)
{
HashSet<ArabicRomanNumeral> additionalArabicRomanNumerals = new HashSet<ArabicRomanNumeral>();
foreach (int arabicNumeral in Enumerable.Range(offset, length))
var additionalArabicRomanNumerals = new HashSet<ArabicRomanNumeral>();
foreach (var arabicNumeral in Enumerable.Range(offset, length))
{
GenerateRomanNumerals(arabicNumeral, out var romanNumeral, out var arabicNumeralAsString);
ArabicRomanNumeral arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeral);
var arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeral);
additionalArabicRomanNumerals.Add(arm);
}
@ -78,7 +78,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals
return new HashSet<ArabicRomanNumeral>(_arabicRomanNumeralsMapping.Take(upToArabicNumber));
}
HashSet<ArabicRomanNumeral> largerMapping = GenerateAdditionalMappings(DICTIONARY_PREPOPULATION_SIZE + 1, upToArabicNumber);
var largerMapping = GenerateAdditionalMappings(DICTIONARY_PREPOPULATION_SIZE + 1, upToArabicNumber);
_arabicRomanNumeralsMapping = (HashSet<ArabicRomanNumeral>)_arabicRomanNumeralsMapping.Union(largerMapping);
}
@ -123,12 +123,12 @@ namespace NzbDrone.Core.Parser.RomanNumerals
private static Dictionary<SimpleArabicNumeral, SimpleRomanNumeral> GenerateAdditionalSimpleNumerals(int offset,
int length)
{
Dictionary<SimpleArabicNumeral, SimpleRomanNumeral> moreNumerals = new Dictionary<SimpleArabicNumeral, SimpleRomanNumeral>();
foreach (int arabicNumeral in Enumerable.Range(offset, length))
var moreNumerals = new Dictionary<SimpleArabicNumeral, SimpleRomanNumeral>();
foreach (var arabicNumeral in Enumerable.Range(offset, length))
{
GenerateRomanNumerals(arabicNumeral, out var romanNumeral, out _);
SimpleArabicNumeral san = new SimpleArabicNumeral(arabicNumeral);
SimpleRomanNumeral srn = new SimpleRomanNumeral(romanNumeral);
var san = new SimpleArabicNumeral(arabicNumeral);
var srn = new SimpleRomanNumeral(romanNumeral);
moreNumerals.Add(san, srn);
}

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

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

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

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

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save