@@ -1437,14 +1437,14 @@ public IEnumerable<DiagnosticRecord> AnalyzeSyntaxTree(
14371437 string fileName = filePathIsNullOrWhiteSpace ? String . Empty : System . IO . Path . GetFileName ( filePath ) ;
14381438 if ( this . ScriptRules != null )
14391439 {
1440- var tasks = this . ScriptRules . Select ( scriptRule => Task . Factory . StartNew ( ( ) =>
1441- {
1442- bool helpRule = String . Equals ( scriptRule . GetName ( ) , "PSUseUTF8EncodingForHelpFile" , StringComparison . OrdinalIgnoreCase ) ;
1440+ var allowedRules = this . ScriptRules . Where ( IsRuleAllowed ) ;
14431441
1444- if ( IsRuleAllowed ( scriptRule ) )
1442+ if ( allowedRules . Any ( ) )
1443+ {
1444+ var tasks = allowedRules . Select ( scriptRule => Task . Factory . StartNew ( ( ) =>
14451445 {
1446+ bool helpRule = String . Equals ( scriptRule . GetName ( ) , "PSUseUTF8EncodingForHelpFile" , StringComparison . OrdinalIgnoreCase ) ;
14461447 List < object > result = new List < object > ( ) ;
1447-
14481448 result . Add ( string . Format ( CultureInfo . CurrentCulture , Strings . VerboseRunningMessage , scriptRule . GetName ( ) ) ) ;
14491449
14501450 // Ensure that any unhandled errors from Rules are converted to non-terminating errors
@@ -1478,26 +1478,26 @@ public IEnumerable<DiagnosticRecord> AnalyzeSyntaxTree(
14781478 }
14791479
14801480 verboseOrErrors . Add ( result ) ;
1481- }
1482- } ) ) ;
1481+ } ) ) ;
14831482
1484- Task . Factory . ContinueWhenAll ( tasks . ToArray ( ) , t => verboseOrErrors . CompleteAdding ( ) ) ;
1483+ Task . Factory . ContinueWhenAll ( tasks . ToArray ( ) , t => verboseOrErrors . CompleteAdding ( ) ) ;
14851484
1486- while ( ! verboseOrErrors . IsCompleted )
1487- {
1488- List < object > data = null ;
1489- try
1485+ while ( ! verboseOrErrors . IsCompleted )
14901486 {
1491- data = verboseOrErrors . Take ( ) ;
1492- }
1493- catch ( InvalidOperationException ) { }
1487+ List < object > data = null ;
1488+ try
1489+ {
1490+ data = verboseOrErrors . Take ( ) ;
1491+ }
1492+ catch ( InvalidOperationException ) { }
14941493
1495- if ( data != null )
1496- {
1497- this . outputWriter . WriteVerbose ( data [ 0 ] as string ) ;
1498- if ( data . Count == 2 )
1494+ if ( data != null )
14991495 {
1500- this . outputWriter . WriteError ( data [ 1 ] as ErrorRecord ) ;
1496+ this . outputWriter . WriteVerbose ( data [ 0 ] as string ) ;
1497+ if ( data . Count == 2 )
1498+ {
1499+ this . outputWriter . WriteError ( data [ 1 ] as ErrorRecord ) ;
1500+ }
15011501 }
15021502 }
15031503 }
0 commit comments