Merge pull request #3740 from warwickmm/remove_unused_local_variables

Remove unused local variables
This commit is contained in:
Kenneth Skovhede
2019-04-25 13:22:39 +02:00
committed by GitHub
13 changed files with 18 additions and 46 deletions
+1 -2
View File
@@ -69,14 +69,13 @@ namespace Duplicati.CommandLine
while (true)
{
Duplicati.Library.Main.OperationPhase phase;
float progress;
long filesprocessed;
long filesizeprocessed;
long filecount;
long filesize;
bool counting;
m_output.OperationProgress.UpdateOverall(out phase, out progress, out filesprocessed, out filesizeprocessed, out filecount, out filesize, out counting);
m_output.OperationProgress.UpdateOverall(out _, out progress, out filesprocessed, out filesizeprocessed, out filecount, out filesize, out counting);
var files = Math.Max(0, filecount - filesprocessed);
var size = Math.Max(0, filesize - filesizeprocessed);
+1 -2
View File
@@ -74,8 +74,7 @@ namespace Duplicati.CommandLine.RecoveryTool
continue;
bool result;
Library.Utility.IFilter evfilter;
bool match = filter.Matches(f.Path, out result, out evfilter);
bool match = filter.Matches(f.Path, out result, out _);
if (!match || result)
yield return f;
}
@@ -156,7 +156,6 @@ namespace Duplicati.CommandLine.RecoveryTool
Console.WriteLine("Removing common prefix {0} from files", largestprefix);
var i = 0L;
var errors = 0L;
foreach (var f in List.EnumerateFilesInDList(filelist, filter, options))
{
try
@@ -236,7 +235,6 @@ namespace Duplicati.CommandLine.RecoveryTool
catch (Exception ex)
{
Console.WriteLine(" error: {0}", ex);
errors++;
}
i++;
}
@@ -374,8 +374,7 @@ namespace Duplicati.Library.Backend
{
ulong available;
ulong total;
ulong free;
if (WindowsDriveHelper.GetDiskFreeSpaceEx(directory, out available, out total, out free))
if (WindowsDriveHelper.GetDiskFreeSpaceEx(directory, out available, out total, out _))
{
return new QuotaInfo((long)total, (long)available);
}
+2 -4
View File
@@ -935,10 +935,9 @@ namespace Duplicati.Library.Main
{
if (filter != null)
{
bool includes;
bool excludes;
FilterExpression.AnalyzeFilters(filter, out includes, out excludes);
FilterExpression.AnalyzeFilters(filter, out _, out excludes);
// If there are no excludes, there is no need to keep the folder as a filter
if (excludes)
@@ -1012,8 +1011,7 @@ namespace Duplicati.Library.Main
}
else if (arg.Type == Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Integer)
{
long l;
if (!long.TryParse(value, out l))
if (!long.TryParse(value, out _))
return Strings.Controller.UnsupportedIntegerValue(optionname, value);
}
else if (arg.Type == Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Path)
@@ -57,9 +57,8 @@ namespace Duplicati.Library.Main
var lst = m_lookup[key];
if (lst == null)
lst = m_lookup[key] = new SortedList<string, T>(1);
T tmp;
if (!lst.TryGetValue(hash + ':' + size.ToString(), out tmp))
if (!lst.TryGetValue(hash + ':' + size.ToString(), out _))
{
lst.Add(hash + ':' + size.ToString(), value);
return true;
@@ -113,8 +113,6 @@ namespace Duplicati.Library.Main.Operation
}
long blocksInVolume = 0;
long discardedBlocks = 0;
long discardedSize = 0;
byte[] buffer = new byte[m_options.Blocksize];
var remoteList = db.GetRemoteVolumes().Where(n => n.State == RemoteVolumeState.Uploaded || n.State == RemoteVolumeState.Verified).ToArray();
@@ -203,11 +201,6 @@ namespace Duplicati.Library.Main.Operation
deleteableVolumes = new List<IRemoteVolume>();
}
}
else
{
discardedBlocks++;
discardedSize += e.Value;
}
}
}
@@ -197,10 +197,7 @@ namespace Duplicati.Library.Modules.Builtin
foreach (var guestForBackup in guestsForBackup)
foreach (var pathForBackup in guestForBackup.DataPaths)
{
bool bResult;
Utility.IFilter matchFilter;
if (!filterhandler.Matches(pathForBackup, out bResult, out matchFilter))
if (!filterhandler.Matches(pathForBackup, out _, out _))
{
Logging.Log.WriteInformationMessage(LOGTAG, "IncludeHyperV", "For VM {0} - adding {1}", guestForBackup.Name, pathForBackup);
pathsForBackup.Add(pathForBackup);
@@ -195,10 +195,7 @@ namespace Duplicati.Library.Modules.Builtin
foreach (var dbForBackup in dbsForBackup)
foreach (var pathForBackup in dbForBackup.DataPaths)
{
bool bResult;
Utility.IFilter matchFilter;
if (!filterhandler.Matches(pathForBackup, out bResult, out matchFilter))
if (!filterhandler.Matches(pathForBackup, out _, out _))
{
Logging.Log.WriteInformationMessage(LOGTAG, "IncludeDatabase", "For DB {0} - adding {1}", dbForBackup.Name, pathForBackup);
pathsForBackup.Add(pathForBackup);
@@ -483,8 +483,7 @@ namespace Duplicati.Library.Utility
/// <param name="path">The path to evaluate</param>
public static bool Matches(IFilter filter, string path)
{
IFilter match;
return Matches(filter, path, out match);
return Matches(filter, path, out _);
}
/// <summary>
+2 -3
View File
@@ -45,10 +45,9 @@ namespace Duplicati.Server.Database
if (days == null)
return null;
DayOfWeek dw = DayOfWeek.Monday;
return (from n in days
where Enum.TryParse<DayOfWeek>(n, true, out dw)
where Enum.TryParse<DayOfWeek>(n, true, out _)
select (DayOfWeek)Enum.Parse(typeof(DayOfWeek), n, true))
.ToArray();
}
@@ -104,11 +104,9 @@ namespace Duplicati.Server.WebServer
private bool HasXSRFCookie(HttpServer.IHttpRequest request)
{
DateTime tmpExpirationTimeHolder;
// Clean up expired XSRF cookies
foreach (var k in (from n in m_activexsrf where DateTime.UtcNow > n.Value select n.Key))
m_activexsrf.TryRemove(k, out tmpExpirationTimeHolder);
m_activexsrf.TryRemove(k, out _);
var xsrfcookie = request.Cookies[XSRF_COOKIE_NAME] ?? request.Cookies[Library.Utility.Uri.UrlEncode(XSRF_COOKIE_NAME)];
var value = xsrfcookie == null ? null : xsrfcookie.Value;
@@ -147,15 +145,13 @@ namespace Duplicati.Server.WebServer
return true;
}
}
Tuple<DateTime, string> tmpTuple;
DateTime tmpDateTime;
if (LOGOUT_SCRIPT_URI.Equals(request.Uri.AbsolutePath, StringComparison.OrdinalIgnoreCase))
{
if (!string.IsNullOrWhiteSpace(auth_token))
{
// Remove the active auth token
m_activeTokens.TryRemove(auth_token, out tmpDateTime);
m_activeTokens.TryRemove(auth_token, out _);
}
response.Status = System.Net.HttpStatusCode.NoContent;
@@ -167,7 +163,7 @@ namespace Duplicati.Server.WebServer
{
// Remove expired nonces
foreach(var k in (from n in m_activeNonces where DateTime.UtcNow > n.Value.Item1 select n.Key))
m_activeNonces.TryRemove(k, out tmpTuple);
m_activeNonces.TryRemove(k, out _);
if (input["get-nonce"] != null && !string.IsNullOrWhiteSpace(input["get-nonce"].Value))
{
@@ -233,7 +229,7 @@ namespace Duplicati.Server.WebServer
var pwd = m_activeNonces[nonce].Item2;
// Remove the nonce
m_activeNonces.TryRemove(nonce, out tmpTuple);
m_activeNonces.TryRemove(nonce, out _);
if (pwd != input["password"].Value)
{
@@ -296,7 +292,7 @@ namespace Duplicati.Server.WebServer
return false;
foreach(var k in (from n in m_activeTokens where DateTime.UtcNow > n.Value select n.Key))
m_activeTokens.TryRemove(k, out tmpDateTime);
m_activeTokens.TryRemove(k, out _);
// If we have a valid token, proceed
+1 -2
View File
@@ -75,14 +75,13 @@ namespace Duplicati.Server.WebServer
/// <param name="options">A set of options</param>
public Server(IDictionary<string, string> options)
{
int port;
string portstring;
IEnumerable<int> ports = null;
options.TryGetValue(OPTION_PORT, out portstring);
if (!string.IsNullOrEmpty(portstring))
ports =
from n in portstring.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
where int.TryParse(n, out port)
where int.TryParse(n, out _)
select int.Parse(n);
if (ports == null || !ports.Any())