Skip to content

Commit 5eac4fa

Browse files
committed
Fix some SonarCloud remarks
1 parent e58781e commit 5eac4fa

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

Skyline.DataMiner.CICD.Tools.GitHubToCatalogYaml/CatalogManager.cs

+6-11
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ private async Task CheckShortDescription(CatalogYaml catalogYaml)
123123
private async Task CheckTags(CatalogYaml catalogYaml)
124124
{
125125
logger.LogDebug("Checking if Tags exist, extending with retrieved GitHub repository topics...");
126-
if (catalogYaml.Tags == null || !catalogYaml.Tags.Any())
126+
if (catalogYaml.Tags == null || catalogYaml.Tags.Count == 0)
127127
{
128128
catalogYaml.Tags = new List<string>();
129129
}
130130

131131
var topics = await service.GetRepositoryTopicsAsync();
132-
if (topics != null && topics.Any())
132+
if (topics is { Count: > 0 })
133133
{
134134
catalogYaml.Tags.AddRange(topics);
135135
catalogYaml.Tags = catalogYaml.Tags.Distinct().ToList();
@@ -250,18 +250,13 @@ private CatalogYaml CreateCatalogYaml(IDeserializer deserializer, out string fou
250250
private static string InferArtifactContentType(string keyword)
251251
{
252252
// Check if the keyword exists in the dictionary
253-
if (!Constants.ArtifactTypeMap.TryGetValue(keyword.ToUpper(), out var contentType))
253+
if (Constants.ArtifactTypeMap.TryGetValue(keyword.ToUpper(), out var contentType))
254254
{
255-
foreach (var typeName in Constants.ArtifactTypeMap.Values)
256-
{
257-
if (typeName.Equals(keyword, StringComparison.OrdinalIgnoreCase))
258-
{
259-
contentType = typeName;
260-
}
261-
}
255+
return contentType;
262256
}
263257

264-
return contentType ?? String.Empty;
258+
return Constants.ArtifactTypeMap.FirstOrDefault(pair => pair.Value.Equals(keyword, StringComparison.OrdinalIgnoreCase)).Key ??
259+
String.Empty;
265260
}
266261

267262
/// <summary>

0 commit comments

Comments
 (0)