Skip to content

Commit 6b51b94

Browse files
author
Kapil Borle
committed
Merge pull request #470 from PowerShell/FixSeverityInconsistency
Fix severity inconsistency in AvoidUsingConvertToSecureStringWithPlainText and UseIdenticalParametersDSC
2 parents d43a478 + 8334c5e commit 6b51b94

8 files changed

+48
-5
lines changed
File renamed without changes.

Engine/Generic/AvoidCmdletGeneric.cs

+7-1
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
}

Engine/Generic/AvoidParameterGeneric.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
4444
{
4545
if (ParameterCondition(cmdAst, ceAst))
4646
{
47-
yield return new DiagnosticRecord(GetError(fileName, cmdAst), cmdAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName, cmdAst.GetCommandName());
47+
yield return new DiagnosticRecord(GetError(fileName, cmdAst), cmdAst.Extent, GetName(), GetDiagnosticSeverity(), fileName, cmdAst.GetCommandName());
4848
}
4949
}
5050
}
@@ -102,6 +102,16 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
102102
/// <returns>The source type of the rule.</returns>
103103
public abstract SourceType GetSourceType();
104104

105+
/// <summary>
106+
/// RuleSeverity: Returns the severity of the rule.
107+
/// </summary>
108+
/// <returns></returns>
105109
public abstract RuleSeverity GetSeverity();
110+
111+
/// <summary>
112+
/// DiagnosticSeverity: Returns the severity of the rule of type DiagnosticSeverity
113+
/// </summary>
114+
/// <returns></returns>
115+
public abstract DiagnosticSeverity GetDiagnosticSeverity();
106116
}
107117
}

Rules/AvoidUsingComputerNameHardcoded.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,23 @@ public override SourceType GetSourceType()
141141
}
142142

143143
/// <summary>
144-
/// GetSeverity: Retrieves the severity of the rule: error, warning of information.
144+
/// GetSeverity: Retrieves the severity of the rule: error, warning or information.
145145
/// </summary>
146146
/// <returns></returns>
147147
public override RuleSeverity GetSeverity()
148148
{
149149
return RuleSeverity.Error;
150150
}
151151

152+
/// <summary>
153+
/// DiagnosticSeverity: Retrieves the severity of the rule of type DiagnosticSeverity: error, warning or information.
154+
/// </summary>
155+
/// <returns></returns>
156+
public override DiagnosticSeverity GetDiagnosticSeverity()
157+
{
158+
return DiagnosticSeverity.Error;
159+
}
160+
152161
/// <summary>
153162
/// GetSourceName: Retrieves the module/assembly name the rule is from.
154163
/// </summary>

Rules/AvoidUsingConvertToSecureStringWithPlainText.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,23 @@ public override SourceType GetSourceType()
108108
}
109109

110110
/// <summary>
111-
/// GetSeverity: Retrieves the severity of the rule: error, warning of information.
111+
/// GetSeverity: Retrieves the severity of the rule: error, warning or information.
112112
/// </summary>
113113
/// <returns></returns>
114114
public override RuleSeverity GetSeverity()
115115
{
116116
return RuleSeverity.Error;
117117
}
118118

119+
/// <summary>
120+
/// DiagnosticSeverity: Retrieves the severity of the rule of type DiagnosticSeverity: error, warning or information.
121+
/// </summary>
122+
/// <returns></returns>
123+
public override DiagnosticSeverity GetDiagnosticSeverity()
124+
{
125+
return DiagnosticSeverity.Error;
126+
}
127+
119128
/// <summary>
120129
/// GetSourceName: Retrieves the module/assembly name the rule is from.
121130
/// </summary>

Rules/AvoidUsingInvokeExpression.cs

+9
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>

Rules/UseIdenticalParametersDSC.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeDSCResource(Ast ast, string fileName
5353
if (funcParamAsts.Count() != funcParamAsts2.Count())
5454
{
5555
yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseIdenticalParametersDSCError),
56-
firstFunc.Extent, GetName(), DiagnosticSeverity.Information, fileName);
56+
firstFunc.Extent, GetName(), DiagnosticSeverity.Error, fileName);
5757
}
5858

5959
foreach (ParameterAst paramAst in funcParamAsts)

0 commit comments

Comments
 (0)