Skip to content

Commit

Permalink
Fix code analysis warnings
Browse files Browse the repository at this point in the history
Fix code analysis warnings from culture-sensitive string comparisons and an undisposed handler.
  • Loading branch information
martincostello committed Mar 14, 2023
1 parent e444046 commit a8f86c6
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal static List<KeyValuePair<string, object>> ExtractMetadataV4ResourceAttr
return new List<KeyValuePair<string, object>>();
}

var httpClientHandler = new HttpClientHandler();
using var httpClientHandler = new HttpClientHandler();
var metadataV4ContainerResponse = ResourceDetectorUtils.SendOutRequest(metadataV4Url, "GET", null, httpClientHandler).Result;
var metadataV4TaskResponse = ResourceDetectorUtils.SendOutRequest($"{metadataV4Url.TrimEnd('/')}/task", "GET", null, httpClientHandler).Result;

Expand All @@ -105,9 +105,9 @@ internal static List<KeyValuePair<string, object>> ExtractMetadataV4ResourceAttr
return new List<KeyValuePair<string, object>>();
}

if (!clusterArn.StartsWith("arn:"))
if (!clusterArn.StartsWith("arn:", StringComparison.Ordinal))
{
var baseArn = containerArn.Substring(containerArn.LastIndexOf(":"));
var baseArn = containerArn.Substring(containerArn.LastIndexOf(":", StringComparison.Ordinal));
clusterArn = $"{baseArn}:cluster/{clusterArn}";
}

Expand All @@ -119,8 +119,8 @@ internal static List<KeyValuePair<string, object>> ExtractMetadataV4ResourceAttr

var launchType = taskResponse.Value<string>("LaunchType") switch
{
string type when "ec2".Equals(type.ToLower()) => AWSSemanticConventions.ValueEcsLaunchTypeEc2,
string type when "fargate".Equals(type.ToLower()) => AWSSemanticConventions.ValueEcsLaunchTypeFargate,
string type when string.Equals("ec2", type, StringComparison.OrdinalIgnoreCase) => AWSSemanticConventions.ValueEcsLaunchTypeEc2,
string type when string.Equals("fargate", type, StringComparison.OrdinalIgnoreCase) => AWSSemanticConventions.ValueEcsLaunchTypeFargate,
_ => null,
};

Expand Down Expand Up @@ -151,7 +151,7 @@ internal static List<KeyValuePair<string, object>> ExtractMetadataV4ResourceAttr
resourceAttributes.Add(new KeyValuePair<string, object>(AWSSemanticConventions.AttributeEcsTaskRevision, revision));
}

if ("awslogs".Equals(containerResponse.Value<string>("LogDriver")))
if (string.Equals("awslogs", containerResponse.Value<string>("LogDriver"), StringComparison.Ordinal))
{
JObject? logOptions = containerResponse.Value<JObject>("LogOptions");
if (logOptions != null)
Expand Down

0 comments on commit a8f86c6

Please sign in to comment.