Skip to content

Fix severity inconsistency in AvoidUsingConvertToSecureStringWithPlainText #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
8 changes: 7 additions & 1 deletion Engine/Generic/AvoidCmdletGeneric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)

if (cmdletNameAndAliases.Contains(cmdAst.GetCommandName(), StringComparer.OrdinalIgnoreCase))
{
yield return new DiagnosticRecord(GetError(fileName), cmdAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName);
yield return new DiagnosticRecord(GetError(fileName), cmdAst.Extent, GetName(), GetDiagnosticSeverity(), fileName);
}
}
}
Expand Down Expand Up @@ -97,5 +97,11 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
/// </summary>
/// <returns></returns>
public abstract RuleSeverity GetSeverity();

/// <summary>
/// DiagnosticSeverity: Returns the severity of the rule of type DiagnosticSeverity
/// </summary>
/// <returns></returns>
public abstract DiagnosticSeverity GetDiagnosticSeverity();
}
}
12 changes: 11 additions & 1 deletion Engine/Generic/AvoidParameterGeneric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
{
if (ParameterCondition(cmdAst, ceAst))
{
yield return new DiagnosticRecord(GetError(fileName, cmdAst), cmdAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName, cmdAst.GetCommandName());
yield return new DiagnosticRecord(GetError(fileName, cmdAst), cmdAst.Extent, GetName(), GetDiagnosticSeverity(), fileName, cmdAst.GetCommandName());
}
}
}
Expand Down Expand Up @@ -102,6 +102,16 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
/// <returns>The source type of the rule.</returns>
public abstract SourceType GetSourceType();

/// <summary>
/// RuleSeverity: Returns the severity of the rule.
/// </summary>
/// <returns></returns>
public abstract RuleSeverity GetSeverity();

/// <summary>
/// DiagnosticSeverity: Returns the severity of the rule of type DiagnosticSeverity
/// </summary>
/// <returns></returns>
public abstract DiagnosticSeverity GetDiagnosticSeverity();
}
}
11 changes: 10 additions & 1 deletion Rules/AvoidUsingComputerNameHardcoded.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,23 @@ public override SourceType GetSourceType()
}

/// <summary>
/// GetSeverity: Retrieves the severity of the rule: error, warning of information.
/// GetSeverity: Retrieves the severity of the rule: error, warning or information.
/// </summary>
/// <returns></returns>
public override RuleSeverity GetSeverity()
{
return RuleSeverity.Error;
}

/// <summary>
/// DiagnosticSeverity: Retrieves the severity of the rule of type DiagnosticSeverity: error, warning or information.
/// </summary>
/// <returns></returns>
public override DiagnosticSeverity GetDiagnosticSeverity()
{
return DiagnosticSeverity.Error;
}

/// <summary>
/// GetSourceName: Retrieves the module/assembly name the rule is from.
/// </summary>
Expand Down
11 changes: 10 additions & 1 deletion Rules/AvoidUsingConvertToSecureStringWithPlainText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,23 @@ public override SourceType GetSourceType()
}

/// <summary>
/// GetSeverity: Retrieves the severity of the rule: error, warning of information.
/// GetSeverity: Retrieves the severity of the rule: error, warning or information.
/// </summary>
/// <returns></returns>
public override RuleSeverity GetSeverity()
{
return RuleSeverity.Error;
}

/// <summary>
/// DiagnosticSeverity: Retrieves the severity of the rule of type DiagnosticSeverity: error, warning or information.
/// </summary>
/// <returns></returns>
public override DiagnosticSeverity GetDiagnosticSeverity()
{
return DiagnosticSeverity.Error;
}

/// <summary>
/// GetSourceName: Retrieves the module/assembly name the rule is from.
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions Rules/AvoidUsingInvokeExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ public override RuleSeverity GetSeverity()
return RuleSeverity.Warning;
}

/// <summary>
/// DiagnosticSeverity: Retrieves the severity of the rule of type DiagnosticSeverity: error, warning or information.
/// </summary>
/// <returns></returns>
public override DiagnosticSeverity GetDiagnosticSeverity()
{
return DiagnosticSeverity.Warning;
}

/// <summary>
/// Method: Retrieves the module/assembly name the rule is from.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Rules/UseIdenticalParametersDSC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeDSCResource(Ast ast, string fileName
if (funcParamAsts.Count() != funcParamAsts2.Count())
{
yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseIdenticalParametersDSCError),
firstFunc.Extent, GetName(), DiagnosticSeverity.Information, fileName);
firstFunc.Extent, GetName(), DiagnosticSeverity.Error, fileName);
}

foreach (ParameterAst paramAst in funcParamAsts)
Expand Down