@@ -1454,22 +1454,27 @@ private Tuple<List<SuppressedRecord>, List<DiagnosticRecord>> SuppressRule(
1454
1454
}
1455
1455
return records ;
1456
1456
}
1457
+
1458
+ /// <summary>
1459
+ /// Wrapper around SuppressRule method.
1460
+ ///
1461
+ /// This enables suppressing external rules (written in PowerShell).
1462
+ /// Since there can be an inconsistency between the rule name in
1463
+ /// diagnostic record and the actual rule (function) name, we use
1464
+ /// the diagnostic record rule name for suppression
1465
+ /// </summary>
1466
+ /// <param name="ruleSuppressions"></param>
1467
+ /// <param name="ruleDiagnosticRecord"></param>
1468
+ /// <returns>Returns a tuple of suppressed and diagnostic records</returns>
1457
1469
private Tuple < List < SuppressedRecord > , List < DiagnosticRecord > > SuppressRule (
1458
- DiagnosticRecord ruleDiagnosticRecord ,
1459
- Dictionary < string , List < RuleSuppression > > ruleSuppressions
1470
+ Dictionary < string , List < RuleSuppression > > ruleSuppressions ,
1471
+ DiagnosticRecord ruleDiagnosticRecord
1460
1472
)
1461
1473
{
1462
- List < ErrorRecord > suppressRuleErrors ;
1463
- var records = Helper . Instance . SuppressRule (
1474
+ return SuppressRule (
1464
1475
ruleDiagnosticRecord . RuleName ,
1465
1476
ruleSuppressions ,
1466
- new List < DiagnosticRecord > { ruleDiagnosticRecord } ,
1467
- out suppressRuleErrors ) ;
1468
- foreach ( var error in suppressRuleErrors )
1469
- {
1470
- this . outputWriter . WriteError ( error ) ;
1471
- }
1472
- return records ;
1477
+ new List < DiagnosticRecord > { ruleDiagnosticRecord } ) ;
1473
1478
}
1474
1479
1475
1480
/// <summary>
@@ -1771,7 +1776,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeSyntaxTree(
1771
1776
1772
1777
foreach ( var ruleRecord in this . GetExternalRecord ( scriptAst , scriptTokens , exRules . ToArray ( ) , fileName ) )
1773
1778
{
1774
- var records = SuppressRule ( ruleRecord , ruleSuppressions ) ;
1779
+ var records = SuppressRule ( ruleSuppressions , ruleRecord ) ;
1775
1780
foreach ( var record in records . Item2 )
1776
1781
{
1777
1782
diagnostics . Add ( record ) ;
0 commit comments