@@ -81,6 +81,38 @@ public static void DeleteHitsFile(string path)
8181 RetryHelper . Retry ( ( ) => File . Delete ( path ) , retryStrategy , 10 ) ;
8282 }
8383
84+ public static bool IsValidFilterExpression ( string filter )
85+ {
86+ if ( filter == null )
87+ return false ;
88+
89+ if ( ! filter . StartsWith ( "[" ) )
90+ return false ;
91+
92+ if ( ! filter . Contains ( "]" ) )
93+ return false ;
94+
95+ if ( filter . Count ( f => f == '[' ) > 1 )
96+ return false ;
97+
98+ if ( filter . Count ( f => f == ']' ) > 1 )
99+ return false ;
100+
101+ if ( filter . IndexOf ( ']' ) < filter . IndexOf ( '[' ) )
102+ return false ;
103+
104+ if ( filter . IndexOf ( ']' ) - filter . IndexOf ( '[' ) == 1 )
105+ return false ;
106+
107+ if ( filter . EndsWith ( "]" ) )
108+ return false ;
109+
110+ if ( new Regex ( @"[^\w*]" ) . IsMatch ( filter . Replace ( "." , "" ) . Replace ( "[" , "" ) . Replace ( "]" , "" ) ) )
111+ return false ;
112+
113+ return true ;
114+ }
115+
84116 public static bool IsModuleExcluded ( string module , string [ ] filters )
85117 {
86118 if ( filters == null )
@@ -91,9 +123,6 @@ public static bool IsModuleExcluded(string module, string[] filters)
91123
92124 foreach ( var filter in filters )
93125 {
94- if ( ! IsValidFilterExpression ( filter ) )
95- continue ;
96-
97126 string modulePattern = filter . Substring ( 1 , filter . IndexOf ( ']' ) - 1 ) ;
98127 string typePattern = filter . Substring ( filter . IndexOf ( ']' ) + 1 ) ;
99128
@@ -116,9 +145,6 @@ public static bool IsTypeExcluded(string module, string type, string[] filters)
116145
117146 foreach ( var filter in filters )
118147 {
119- if ( ! IsValidFilterExpression ( filter ) )
120- continue ;
121-
122148 string typePattern = filter . Substring ( filter . IndexOf ( ']' ) + 1 ) ;
123149 string modulePattern = filter . Substring ( 1 , filter . IndexOf ( ']' ) - 1 ) ;
124150
@@ -191,35 +217,6 @@ TimeSpan retryStrategy()
191217 return retryStrategy ;
192218 }
193219
194- private static bool IsValidFilterExpression ( string filter )
195- {
196- if ( ! filter . StartsWith ( "[" ) )
197- return false ;
198-
199- if ( ! filter . Contains ( "]" ) )
200- return false ;
201-
202- if ( filter . Count ( f => f == '[' ) > 1 )
203- return false ;
204-
205- if ( filter . Count ( f => f == ']' ) > 1 )
206- return false ;
207-
208- if ( filter . IndexOf ( ']' ) < filter . IndexOf ( '[' ) )
209- return false ;
210-
211- if ( filter . IndexOf ( ']' ) - filter . IndexOf ( '[' ) == 1 )
212- return false ;
213-
214- if ( filter . EndsWith ( "]" ) )
215- return false ;
216-
217- if ( new Regex ( @"[^\w*]" ) . IsMatch ( filter . Replace ( "." , "" ) . Replace ( "[" , "" ) . Replace ( "]" , "" ) ) )
218- return false ;
219-
220- return true ;
221- }
222-
223220 private static string WildcardToRegex ( string pattern )
224221 {
225222 return "^" + Regex . Escape ( pattern ) .
0 commit comments