Skip to content

Commit

Permalink
PSReservedParams: Make severity Error instead of Warning (#1989)
Browse files Browse the repository at this point in the history
Co-authored-by: Christoph Bergmeister <[email protected]>
  • Loading branch information
liamjpeters and bergmeister authored Feb 20, 2025
1 parent 0fecc08 commit 5648cf5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 11 additions & 2 deletions Rules/AvoidReservedParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName) {
if (commonParamNames.Contains(paramName, StringComparer.OrdinalIgnoreCase))
{
yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.ReservedParamsError, funcAst.Name, paramName),
paramAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName);
paramAst.Extent, GetName(), GetDiagnosticSeverity(), fileName);
}
}
}
Expand Down Expand Up @@ -107,7 +107,16 @@ public SourceType GetSourceType()
/// <returns></returns>
public RuleSeverity GetSeverity()
{
return RuleSeverity.Warning;
return RuleSeverity.Error;
}

/// <summary>
/// Gets the severity of the returned diagnostic record: error, warning, or information.
/// </summary>
/// <returns></returns>
public DiagnosticSeverity GetDiagnosticSeverity()
{
return DiagnosticSeverity.Error;
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Tests/Engine/GetScriptAnalyzerRule.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ Describe "Test RuleExtension" {
Describe "TestSeverity" {
It "filters rules based on the specified rule severity" {
$rules = Get-ScriptAnalyzerRule -Severity Error
$rules.Count | Should -Be 7
$rules.Count | Should -Be 8
}

It "filters rules based on multiple severity inputs"{
$rules = Get-ScriptAnalyzerRule -Severity Error,Information
$rules.Count | Should -Be 18
$rules.Count | Should -Be 19
}

It "takes lower case inputs" {
$rules = Get-ScriptAnalyzerRule -Severity error
$rules.Count | Should -Be 7
$rules.Count | Should -Be 8
}
}

Expand Down

0 comments on commit 5648cf5

Please sign in to comment.