Skip to content

Commit 4c7020f

Browse files
author
Quoc Truong
committed
Add rulesuppression class to store rule suppression info
1 parent 995fb21 commit 4c7020f

File tree

4 files changed

+67
-2
lines changed

4 files changed

+67
-2
lines changed

Engine/Generic/DiagnosticRecord.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class DiagnosticRecord
1818
private string ruleName;
1919
private DiagnosticSeverity severity;
2020
private string scriptName;
21+
private string ruleSuppressionId;
2122

2223
/// <summary>
2324
/// Represents a string from the rule about why this diagnostic was created.
@@ -62,7 +63,16 @@ public string ScriptName
6263
{
6364
get { return scriptName; }
6465
//Trim down to the leaf element of the filePath and pass it to Diagnostic Record
65-
set { scriptName = System.IO.Path.GetFileName(value); ; }
66+
set { scriptName = System.IO.Path.GetFileName(value); }
67+
}
68+
69+
/// <summary>
70+
/// Returns the rule id for this record
71+
/// </summary>
72+
public string RuleSuppressionID
73+
{
74+
get { return ruleSuppressionId; }
75+
set { ruleSuppressionId = value; }
6676
}
6777

6878
/// <summary>
@@ -81,13 +91,14 @@ public DiagnosticRecord()
8191
/// <param name="ruleName">The name of the rule that created this diagnostic</param>
8292
/// <param name="severity">The severity of this diagnostic</param>
8393
/// <param name="scriptName">The name of the script file being analyzed</param>
84-
public DiagnosticRecord(string message, IScriptExtent extent, string ruleName, DiagnosticSeverity severity, string scriptName)
94+
public DiagnosticRecord(string message, IScriptExtent extent, string ruleName, DiagnosticSeverity severity, string scriptName, string ruleId = null)
8595
{
8696
Message = string.IsNullOrEmpty(message) ? string.Empty : message;
8797
RuleName = string.IsNullOrEmpty(ruleName) ? string.Empty : ruleName;
8898
Extent = extent;
8999
Severity = severity;
90100
ScriptName = string.IsNullOrEmpty(scriptName) ? string.Empty : scriptName;
101+
ruleSuppressionId = ruleId;
91102
}
92103
}
93104

Engine/Generic/RuleSuppression.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using System.Management.Automation.Language;
3+
4+
namespace Microsoft.Windows.Powershell.ScriptAnalyzer.Generic
5+
{
6+
/// <summary>
7+
///
8+
/// </summary>
9+
public class RuleSuppression
10+
{
11+
/// <summary>
12+
/// The start offset of the rule suppression
13+
/// </summary>
14+
public int StartOffSet
15+
{
16+
get;
17+
set;
18+
}
19+
20+
/// <summary>
21+
/// The end offset of the rule suppression
22+
/// </summary>
23+
public int EndOffset
24+
{
25+
get;
26+
set;
27+
}
28+
29+
/// <summary>
30+
/// Name of the rule being suppressed
31+
/// </summary>
32+
public string RuleName
33+
{
34+
get;
35+
set;
36+
}
37+
38+
/// <summary>
39+
/// ID of the violation instance
40+
/// </summary>
41+
public string RuleSuppressionID
42+
{
43+
get;
44+
set;
45+
}
46+
}
47+
}

Engine/Helper.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Management.Automation;
66
using System.Management.Automation.Language;
77
using System.Management.Automation.Runspaces;
8+
using Microsoft.Windows.Powershell.ScriptAnalyzer.Generic;
89

910
namespace Microsoft.Windows.Powershell.ScriptAnalyzer
1011
{
@@ -604,6 +605,11 @@ public bool HasSpecialVars(string varName)
604605
return false;
605606
}
606607

608+
public RuleSuppression GetRuleSuppression()
609+
{
610+
return null;
611+
}
612+
607613
#endregion
608614
}
609615

Engine/ScriptAnalyzerEngine.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<Compile Include="Generic\ITokenRule.cs" />
6464
<Compile Include="Generic\LoggerInfo.cs" />
6565
<Compile Include="Generic\RuleInfo.cs" />
66+
<Compile Include="Generic\RuleSuppression.cs" />
6667
<Compile Include="Generic\SkipNamedBlock.cs" />
6768
<Compile Include="Generic\SkipTypeDefinition.cs" />
6869
<Compile Include="Generic\SourceType.cs" />

0 commit comments

Comments
 (0)