Skip to content

Commit 5648cf5

Browse files
PSReservedParams: Make severity Error instead of Warning (#1989)
Co-authored-by: Christoph Bergmeister <[email protected]>
1 parent 0fecc08 commit 5648cf5

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Rules/AvoidReservedParams.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName) {
6060
if (commonParamNames.Contains(paramName, StringComparer.OrdinalIgnoreCase))
6161
{
6262
yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.ReservedParamsError, funcAst.Name, paramName),
63-
paramAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName);
63+
paramAst.Extent, GetName(), GetDiagnosticSeverity(), fileName);
6464
}
6565
}
6666
}
@@ -107,7 +107,16 @@ public SourceType GetSourceType()
107107
/// <returns></returns>
108108
public RuleSeverity GetSeverity()
109109
{
110-
return RuleSeverity.Warning;
110+
return RuleSeverity.Error;
111+
}
112+
113+
/// <summary>
114+
/// Gets the severity of the returned diagnostic record: error, warning, or information.
115+
/// </summary>
116+
/// <returns></returns>
117+
public DiagnosticSeverity GetDiagnosticSeverity()
118+
{
119+
return DiagnosticSeverity.Error;
111120
}
112121

113122
/// <summary>

Tests/Engine/GetScriptAnalyzerRule.tests.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,17 @@ Describe "Test RuleExtension" {
154154
Describe "TestSeverity" {
155155
It "filters rules based on the specified rule severity" {
156156
$rules = Get-ScriptAnalyzerRule -Severity Error
157-
$rules.Count | Should -Be 7
157+
$rules.Count | Should -Be 8
158158
}
159159

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

165165
It "takes lower case inputs" {
166166
$rules = Get-ScriptAnalyzerRule -Severity error
167-
$rules.Count | Should -Be 7
167+
$rules.Count | Should -Be 8
168168
}
169169
}
170170

0 commit comments

Comments
 (0)