File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -74,16 +74,18 @@ public IEnumerable<FileInfo> Filter(IEnumerable<FileInfo> files)
74
74
includeByDefault )
75
75
} ) ;
76
76
77
- // Move included pathfilters to the front of the list:
78
- pathFilters . Sort ( ( pf1 , pf2 ) => - 1 * pf1 . Include . CompareTo ( pf2 . Include ) ) ;
79
77
return unfilteredResult . Where ( f =>
80
78
{
81
79
var include = f . FileInclusion . Include ;
82
- foreach ( var pathFilter in pathFilters )
80
+ // LGTM_INDEX_FILTERS is a prioritized list, where later filters take
81
+ // priority over earlier ones.
82
+ for ( int i = pathFilters . Count - 1 ; i >= 0 ; i -- )
83
83
{
84
+ var pathFilter = pathFilters [ i ] ;
84
85
if ( pathFilter . Regex . IsMatch ( f . FileInclusion . Path ) )
85
86
{
86
87
include = pathFilter . Include ;
88
+ break ;
87
89
}
88
90
}
89
91
Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ public void TestFiltersWithIncludeExcludeExcludeFirst()
165
165
{
166
166
( var testSubject , var progressMonitor , var files ) = TestSetup ( ) ;
167
167
168
+ // NOTE: the ordering DOES matter, later filters takes priority, so the exclude will end up not mattering at all.
168
169
Environment . SetEnvironmentVariable ( "LGTM_INDEX_FILTERS" , """
169
170
exclude:c/x/z
170
171
include:c/x
@@ -174,7 +175,8 @@ public void TestFiltersWithIncludeExcludeExcludeFirst()
174
175
175
176
var expected = GetExpected (
176
177
[
177
- "/a/b/c/x/y/i.cs"
178
+ "/a/b/c/x/y/i.cs" ,
179
+ "/a/b/c/x/z/i.cs"
178
180
] ) ;
179
181
180
182
AssertFileInfoEquivalence ( expected , filtered ) ;
You can’t perform that action at this time.
0 commit comments