@@ -1444,28 +1444,32 @@ public Dictionary<string, List<string>> CheckRuleExtension(string[] path, PathIn
1444
1444
return results ;
1445
1445
}
1446
1446
1447
- #endregion
1447
+ #endregion
1448
1448
1449
1449
1450
1450
/// <summary>
1451
1451
/// Analyzes a script file or a directory containing script files.
1452
1452
/// </summary>
1453
1453
/// <param name="path">The path of the file or directory to analyze.</param>
1454
+ /// <param name="shouldProcess">Whether the action should be executed.</param>
1454
1455
/// <param name="searchRecursively">
1455
1456
/// If true, recursively searches the given file path and analyzes any
1456
1457
/// script files that are found.
1457
1458
/// </param>
1458
1459
/// <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 )
1460
1461
{
1461
1462
List < string > scriptFilePaths = ScriptPathList ( path , searchRecursively ) ;
1462
1463
1463
1464
foreach ( string scriptFilePath in scriptFilePaths )
1464
1465
{
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 } ") )
1467
1467
{
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
+ }
1469
1473
}
1470
1474
}
1471
1475
}
@@ -1474,25 +1478,29 @@ public IEnumerable<DiagnosticRecord> AnalyzePath(string path, bool searchRecursi
1474
1478
/// Analyzes a script file or a directory containing script files and fixes warning where possible.
1475
1479
/// </summary>
1476
1480
/// <param name="path">The path of the file or directory to analyze.</param>
1481
+ /// <param name="shouldProcess">Whether the action should be executed.</param>
1477
1482
/// <param name="searchRecursively">
1478
1483
/// If true, recursively searches the given file path and analyzes any
1479
1484
/// script files that are found.
1480
1485
/// </param>
1481
1486
/// <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 )
1483
1488
{
1484
1489
List < string > scriptFilePaths = ScriptPathList ( path , searchRecursively ) ;
1485
1490
1486
1491
foreach ( string scriptFilePath in scriptFilePaths )
1487
1492
{
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 } ") )
1494
1494
{
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
+ }
1496
1504
}
1497
1505
}
1498
1506
}
0 commit comments