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)
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 take
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
Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ public void TestFiltersWithIncludeExcludeExcludeFirst()
165165 {
166166 ( var testSubject , var progressMonitor , var files ) = TestSetup ( ) ;
167167
168+ // NOTE: the ordering DOES matter, later filters takes priority, so the exclude will end up not mattering at all.
168169 Environment . SetEnvironmentVariable ( "LGTM_INDEX_FILTERS" , """
169170 exclude:c/x/z
170171 include:c/x
@@ -174,7 +175,8 @@ public void TestFiltersWithIncludeExcludeExcludeFirst()
174175
175176 var expected = GetExpected (
176177 [
177- "/a/b/c/x/y/i.cs"
178+ "/a/b/c/x/y/i.cs" ,
179+ "/a/b/c/x/z/i.cs"
178180 ] ) ;
179181
180182 AssertFileInfoEquivalence ( expected , filtered ) ;
You can’t perform that action at this time.
0 commit comments