Skip to content

Commit 47c2c60

Browse files
committed
Clean up final analyzer findings
Root cause: the latest push triggered one more static-analysis pass that flagged a disposable test-helper pattern, two Yahoo immutability nits, one unreachable Yahoo throw, and avoidable empty-array allocations in MapQuest.
1 parent 65e8e1e commit 47c2c60

4 files changed

Lines changed: 8 additions & 14 deletions

File tree

src/Geocoding.MapQuest/MapQuestGeocoder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ private IEnumerable<Address> HandleSingleResponse(MapQuestResponse res)
5656
select l);
5757
}
5858
else
59-
return new Address[0];
59+
return Array.Empty<Address>();
6060
}
6161

6262
private IEnumerable<Address> HandleSingleResponse(IEnumerable<MapQuestLocation> locs)
6363
{
6464
if (locs is null)
65-
return new Address[0];
65+
return Array.Empty<Address>();
6666
else
6767
{
6868
return from l in locs.OfType<MapQuestLocation>()

src/Geocoding.Yahoo/OAuthBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public enum SignatureTypes
3030
/// </summary>
3131
protected class QueryParameter
3232
{
33-
private string _name = null!;
34-
private string _value = null!;
33+
private readonly string _name = null!;
34+
private readonly string _value = null!;
3535

3636
/// <summary>
3737
/// Initializes a new instance of the <see cref="QueryParameter"/> class.

src/Geocoding.Yahoo/YahooGeocoder.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ private async Task<IEnumerable<YahooAddress>> ProcessRequest(HttpRequestMessage
128128
{
129129
throw new YahooGeocodingException(message, ex);
130130
}
131-
132-
throw new YahooGeocodingException(message, new HttpRequestException(message));
133131
}
134132

135133
using (var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))

test/Geocoding.Tests/TestHttpMessageHandler.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
2020

2121
public static Task<HttpResponseMessage> CreateResponseAsync(HttpStatusCode statusCode, string? reasonPhrase = null, string? body = null)
2222
{
23-
var response = new HttpResponseMessage(statusCode)
23+
return Task.FromResult(new HttpResponseMessage(statusCode)
2424
{
25-
ReasonPhrase = reasonPhrase
26-
};
27-
28-
if (!String.IsNullOrWhiteSpace(body))
29-
response.Content = new StringContent(body, Encoding.UTF8, "text/plain");
30-
31-
return Task.FromResult(response);
25+
ReasonPhrase = reasonPhrase,
26+
Content = String.IsNullOrWhiteSpace(body) ? null : new StringContent(body, Encoding.UTF8, "text/plain")
27+
});
3228
}
3329
}

0 commit comments

Comments
 (0)