Skip to content

Commit

Permalink
discard some variables (#10014)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Jun 22, 2024
1 parent 22b3be2 commit 10cd7bd
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 21 deletions.
5 changes: 2 additions & 3 deletions src/NuGetGallery.Core/Infrastructure/MessageQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ public static void Enqueue<T>(string queueName, T payload)
if (Enabled)
{
var queue = _queues.GetOrAdd(queueName, _ => new ConcurrentQueue<object>());

object __;
while (queue.Count > (MaxPerQueue - 1) && queue.TryDequeue(out __)) { }

while (queue.Count > (MaxPerQueue - 1) && queue.TryDequeue(out _)) { }
queue.Enqueue(payload);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,6 @@ public virtual async Task<bool> ChangePassword(User user, string oldPassword, st
{
var hasPassword = user.Credentials.Any(
c => c.Type.StartsWith(CredentialTypes.Password.Prefix, StringComparison.OrdinalIgnoreCase));
Credential _;
if (hasPassword && !ValidatePasswordCredential(user.Credentials, oldPassword, out _))
{
// Invalid old password!
Expand Down
3 changes: 1 addition & 2 deletions src/NuGetGallery/App_Start/LatestVersionRouteConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public bool Match(HttpContextBase httpContext, Route route, string parameterName
|| route.Url.Equals(LatestPackageRouteVerifier.SupportedRoutes.LatestUrlWithPreleaseAndVersionString, StringComparison.InvariantCultureIgnoreCase))
return true;

NuGetVersion ignored;
return NuGetVersion.TryParse(versionText, out ignored);
return NuGetVersion.TryParse(versionText, out _);
}
}
}
3 changes: 1 addition & 2 deletions src/NuGetGallery/App_Start/VersionRouteConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public bool Match(HttpContextBase httpContext, Route route, string parameterName
return true;
}

NuGetVersion ignored;
return NuGetVersion.TryParse(versionText, out ignored);
return NuGetVersion.TryParse(versionText, out _);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ private void SetUpCustomValidator(CustomValidator validator) {
}

protected void DateValidator_ServerValidate(object source, ServerValidateEventArgs args) {
DateTime dummyResult;
args.IsValid = DateTime.TryParse(args.Value, out dummyResult);
args.IsValid = DateTime.TryParse(args.Value, out _);
}

protected override void ExtractValues(IOrderedDictionary dictionary) {
Expand Down
3 changes: 1 addition & 2 deletions src/NuGetGallery/Queries/AutocompleteServiceQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ internal string BuildQueryString(
queryString += "&testData=true";
}

NuGetVersion semVerLevelVersion;
if (!string.IsNullOrEmpty(semVerLevel) && NuGetVersion.TryParse(semVerLevel, out semVerLevelVersion))
if (!string.IsNullOrEmpty(semVerLevel) && NuGetVersion.TryParse(semVerLevel, out _))
{
queryString += $"&semVerLevel={semVerLevel}";
}
Expand Down
3 changes: 1 addition & 2 deletions src/NuGetGallery/Services/JsonStatisticsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,9 @@ public async Task<StatisticsPackagesReport> GetPackageVersionDownloadsByClient(s
private static IList<StatisticsFact> CreateFacts(JObject data)
{
IList<StatisticsFact> facts = new List<StatisticsFact>();
JToken itemsToken;

// Check if the "Items" exist before trying to access them.
if (!data.TryGetValue("Items", out itemsToken))
if (!data.TryGetValue("Items", out _))
{
throw new StatisticsReportNotFoundException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ private static bool IsValidMachineIpValue(string ipAddress)
return true;
}

IPAddress value;

return IPAddress.TryParse(ipAddress, out value);
return IPAddress.TryParse(ipAddress, out _);
}
}
}
6 changes: 2 additions & 4 deletions tests/NuGetGallery.Facts/Controllers/ApiControllerFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2853,11 +2853,9 @@ private async Task<Scope> InvokeAsync(Scope scope)
dynamic json = jsonResult?.Data;
Assert.NotNull(json);

Guid key;
Assert.True(Guid.TryParse(json.Key, out key));
Assert.True(Guid.TryParse(json.Key, out Guid _));

DateTime expires;
Assert.True(DateTime.TryParse(json.Expires, out expires));
Assert.True(DateTime.TryParse(json.Expires, out DateTime _));

// Assert - the invocations
controller.MockAuthenticationService.Verify(s => s.AddCredential(It.IsAny<User>(), It.IsAny<Credential>()), Times.Once);
Expand Down

0 comments on commit 10cd7bd

Please sign in to comment.