Template for a good false-positive report, formatted with Markdown:
- versions used: SonarQube 8.4.1
private async Task<HttpResponseMessage> SendAsync(HttpMethod method, string apiFormat, params object[] formatters)
{
async Task<HttpResponseMessage> sendAsync()
{
var request = new HttpRequestMessage
{
Method = method,
RequestUri = new Uri(string.Format(apiFormat, formatters.Prepend(_sonarQubeConfigAdress).ToArray()))
};
SetRequestHeader(request);
return await _httpClient.SendAsync(request);
}
var response = await Policy
.HandleResult<HttpResponseMessage>(m => m.StatusCode == HttpStatusCode.GatewayTimeout)
.WaitAndRetryAsync(5, retryCount => TimeSpan.FromMilliseconds(5),
onRetry: (httpResponse, timeSpan, retryCount, context) =>
_logger.LogWarning("Gateway timed out {0} times for request {1}", retryCount, httpResponse.Result.RequestMessage.RequestUri))
.ExecuteAsync(sendAsync);
if (!response.IsSuccessStatusCode)
{
_logger.LogError("Got unexpected status {0} for request {1} with message: '{2}'",
response.StatusCode, response.RequestMessage.RequestUri, await response.Content.ReadAsStringAsync());
}
response.EnsureSuccessStatusCode();
return response;
}
See above example. The usage of the parameters method, apiFormat and formatters in the method-local method sendAsync are not detected by sonarqube resulting in ‘csharpsquid:S1172’ remove this parameter whose usage is ignored issues on analysis.