Skip to content

Commit 3e9e5c5

Browse files
author
Kapil Borle
authored
Fix ProvideCommentHelp rule extent (#679)
The violation extent only contains the function name instead of the entire function definition.
1 parent 0d78886 commit 3e9e5c5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Rules/ProvideCommentHelp.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst fun
7070
DiagnosticRecords.Add(
7171
new DiagnosticRecord(
7272
string.Format(CultureInfo.CurrentCulture, Strings.ProvideCommentHelpError, funcAst.Name),
73-
funcAst.Extent, GetName(), DiagnosticSeverity.Information, fileName));
73+
Helper.Instance.GetScriptExtentForFunctionName(funcAst),
74+
GetName(),
75+
DiagnosticSeverity.Information,
76+
fileName));
7477
}
7578
}
7679

Tests/Rules/ProvideCommentHelp.tests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Describe "ProvideCommentHelp" {
2222
$violations[1].Message | Should Match $violationMessage
2323
}
2424

25+
It "has extent that includes only the function name" {
26+
$violations[1].Extent.Text | Should Be "Comment"
27+
}
28+
2529
if ($PSVersionTable.PSVersion -ge [Version]'5.0.0')
2630
{
2731
It "Does not count violation in DSC class" {

0 commit comments

Comments
 (0)