Skip to content

Commit 59d239b

Browse files
committed
C#: Respect order of LGTM_INDEX_FILTERS in buildless extraction
That is, using `exclude:**/*\ninclude:**/*` should include everything.
1 parent 3668ba6 commit 59d239b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FilePathFilter.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,18 @@ public IEnumerable<FileInfo> Filter(IEnumerable<FileInfo> files)
7474
includeByDefault)
7575
});
7676

77-
// Move included pathfilters to the front of the list:
78-
pathFilters.Sort((pf1, pf2) => -1 * pf1.Include.CompareTo(pf2.Include));
7977
return unfilteredResult.Where(f =>
8078
{
8179
var include = f.FileInclusion.Include;
82-
foreach (var pathFilter in pathFilters)
80+
// LGTM_INDEX_FILTERS is a prioritized list, where later filters takes
81+
// priority over earlier ones.
82+
for (int i = pathFilters.Count - 1; i >= 0; i--)
8383
{
84+
var pathFilter = pathFilters[i];
8485
if (pathFilter.Regex.IsMatch(f.FileInclusion.Path))
8586
{
8687
include = pathFilter.Include;
88+
break;
8789
}
8890
}
8991

0 commit comments

Comments
 (0)