Skip to content
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

PSReservedParams: Make severity Error instead of Warning #1989

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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