@@ -1444,28 +1444,32 @@ public Dictionary<string, List<string>> CheckRuleExtension(string[] path, PathIn
14441444 return results ;
14451445 }
14461446
1447- #endregion
1447+ #endregion
14481448
14491449
14501450 /// <summary>
14511451 /// Analyzes a script file or a directory containing script files.
14521452 /// </summary>
14531453 /// <param name="path">The path of the file or directory to analyze.</param>
1454+ /// <param name="shouldProcess">Whether the action should be executed.</param>
14541455 /// <param name="searchRecursively">
14551456 /// If true, recursively searches the given file path and analyzes any
14561457 /// script files that are found.
14571458 /// </param>
14581459 /// <returns>An enumeration of DiagnosticRecords that were found by rules.</returns>
1459- public IEnumerable < DiagnosticRecord > AnalyzePath ( string path , bool searchRecursively = false )
1460+ public IEnumerable < DiagnosticRecord > AnalyzePath ( string path , Func < string , string , bool > shouldProcess , bool searchRecursively = false )
14601461 {
14611462 List < string > scriptFilePaths = ScriptPathList ( path , searchRecursively ) ;
14621463
14631464 foreach ( string scriptFilePath in scriptFilePaths )
14641465 {
1465- // Yield each record in the result so that the caller can pull them one at a time
1466- foreach ( var diagnosticRecord in this . AnalyzeFile ( scriptFilePath ) )
1466+ if ( shouldProcess ( scriptFilePath , $ "Analyzing file { scriptFilePath } ") )
14671467 {
1468- yield return diagnosticRecord ;
1468+ // Yield each record in the result so that the caller can pull them one at a time
1469+ foreach ( var diagnosticRecord in this . AnalyzeFile ( scriptFilePath ) )
1470+ {
1471+ yield return diagnosticRecord ;
1472+ }
14691473 }
14701474 }
14711475 }
@@ -1474,25 +1478,29 @@ public IEnumerable<DiagnosticRecord> AnalyzePath(string path, bool searchRecursi
14741478 /// Analyzes a script file or a directory containing script files and fixes warning where possible.
14751479 /// </summary>
14761480 /// <param name="path">The path of the file or directory to analyze.</param>
1481+ /// <param name="shouldProcess">Whether the action should be executed.</param>
14771482 /// <param name="searchRecursively">
14781483 /// If true, recursively searches the given file path and analyzes any
14791484 /// script files that are found.
14801485 /// </param>
14811486 /// <returns>An enumeration of DiagnosticRecords that were found by rules and could not be fixed automatically.</returns>
1482- public IEnumerable < DiagnosticRecord > AnalyzeAndFixPath ( string path , bool searchRecursively = false )
1487+ public IEnumerable < DiagnosticRecord > AnalyzeAndFixPath ( string path , Func < string , string , bool > shouldProcess , bool searchRecursively = false )
14831488 {
14841489 List < string > scriptFilePaths = ScriptPathList ( path , searchRecursively ) ;
14851490
14861491 foreach ( string scriptFilePath in scriptFilePaths )
14871492 {
1488- var fileEncoding = GetFileEncoding ( scriptFilePath ) ;
1489- var scriptFileContentWithFixes = Fix ( File . ReadAllText ( scriptFilePath , fileEncoding ) ) ;
1490- File . WriteAllText ( scriptFilePath , scriptFileContentWithFixes , fileEncoding ) ;
1491-
1492- // Yield each record in the result so that the caller can pull them one at a time
1493- foreach ( var diagnosticRecord in this . AnalyzeFile ( scriptFilePath ) )
1493+ if ( shouldProcess ( scriptFilePath , $ "Analyzing and fixing file { scriptFilePath } ") )
14941494 {
1495- yield return diagnosticRecord ;
1495+ var fileEncoding = GetFileEncoding ( scriptFilePath ) ;
1496+ var scriptFileContentWithFixes = Fix ( File . ReadAllText ( scriptFilePath , fileEncoding ) ) ;
1497+ File . WriteAllText ( scriptFilePath , scriptFileContentWithFixes , fileEncoding ) ;
1498+
1499+ // Yield each record in the result so that the caller can pull them one at a time
1500+ foreach ( var diagnosticRecord in this . AnalyzeFile ( scriptFilePath ) )
1501+ {
1502+ yield return diagnosticRecord ;
1503+ }
14961504 }
14971505 }
14981506 }
0 commit comments