Skip to content

Commit d3dd449

Browse files
Copilotbaywet
andauthored
fix(library): replace foreach with LINQ Any to address CodeQL missed-where finding
Agent-Logs-Url: https://github.com/microsoft/OpenAPI.NET/sessions/4f39d2a9-62e7-497f-be81-7f0efcb876c9 Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
1 parent 7a6be84 commit d3dd449

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/Microsoft.OpenApi/Services/OpenApiPathHelper.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Diagnostics.CodeAnalysis;
8+
using System.Linq;
89

910
namespace Microsoft.OpenApi;
1011

@@ -59,12 +60,10 @@ public static class OpenApiPathHelper
5960
return path;
6061
}
6162

62-
foreach (var policy in matchingPolicies)
63+
string? versionedPath = null;
64+
if (matchingPolicies.Any(policy => policy.TryGetVersionedPath(segments, out versionedPath)))
6365
{
64-
if (policy.TryGetVersionedPath(segments, out var result))
65-
{
66-
return result;
67-
}
66+
return versionedPath;
6867
}
6968

7069
return path;

0 commit comments

Comments
 (0)