Skip to content

Commit 381d1b1

Browse files
fix: use LINQ Select instead of foreach loop in EfIncludePathHelper (#115)
- Replace foreach + manual Add with .Select().ToList() to resolve CodeQL cs/linq/missed-select alert
1 parent 2b0169e commit 381d1b1

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

JsonApiToolkit/Helpers/EfIncludePathHelper.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,16 @@ public static List<string> MapIncludePathsToClrProperties<T>(List<string>? inclu
2121
return [];
2222

2323
var type = typeof(T);
24-
var mapped = new List<string>(includePaths.Count);
2524

26-
foreach (var path in includePaths.Where(p => !string.IsNullOrWhiteSpace(p)))
27-
{
28-
var mappedPath = s_includePathCache.GetOrAdd(
29-
(type, path),
30-
key => MapSinglePath(key.Item1, key.Item2)
31-
);
32-
33-
mapped.Add(mappedPath);
34-
}
35-
36-
return mapped;
25+
return includePaths
26+
.Where(p => !string.IsNullOrWhiteSpace(p))
27+
.Select(path =>
28+
s_includePathCache.GetOrAdd(
29+
(type, path),
30+
key => MapSinglePath(key.Item1, key.Item2)
31+
)
32+
)
33+
.ToList();
3734
}
3835

3936
private static string MapSinglePath(Type startType, string path)

0 commit comments

Comments
 (0)