Skip to content

Commit 8c15ac9

Browse files
author
Kapil Borle
committed
Add an abstract method to retrieve DiagnosticSeverity in AvoidCmdletGeneric class
1 parent e0a5cb6 commit 8c15ac9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Engine/Generic/AvoidCmdletGeneric.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
4545

4646
if (cmdletNameAndAliases.Contains(cmdAst.GetCommandName(), StringComparer.OrdinalIgnoreCase))
4747
{
48-
yield return new DiagnosticRecord(GetError(fileName), cmdAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName);
48+
yield return new DiagnosticRecord(GetError(fileName), cmdAst.Extent, GetName(), GetDiagnosticSeverity(), fileName);
4949
}
5050
}
5151
}
@@ -97,5 +97,11 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
9797
/// </summary>
9898
/// <returns></returns>
9999
public abstract RuleSeverity GetSeverity();
100+
101+
/// <summary>
102+
/// DiagnosticSeverity: Returns the severity of the rule of type DiagnosticSeverity
103+
/// </summary>
104+
/// <returns></returns>
105+
public abstract DiagnosticSeverity GetDiagnosticSeverity();
100106
}
101107
}

Rules/AvoidUsingInvokeExpression.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ public override RuleSeverity GetSeverity()
8585
return RuleSeverity.Warning;
8686
}
8787

88+
/// <summary>
89+
/// DiagnosticSeverity: Retrieves the severity of the rule of type DiagnosticSeverity: error, warning or information.
90+
/// </summary>
91+
/// <returns></returns>
92+
public override DiagnosticSeverity GetDiagnosticSeverity()
93+
{
94+
return DiagnosticSeverity.Warning;
95+
}
96+
8897
/// <summary>
8998
/// Method: Retrieves the module/assembly name the rule is from.
9099
/// </summary>

0 commit comments

Comments
 (0)