Skip to content

Commit 72a6e78

Browse files
author
Kapil Borle
committed
Add class to find functions without comment help
1 parent 3eb753a commit 72a6e78

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Rules/ProvideCommentHelp.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,46 @@ private IEnumerable<CorrectionExtent> GetCorrection(FunctionDefinitionAst funcDe
161161
funcDefnAst.Extent.File);
162162
}
163163

164+
private class ViolationFinder : AstVisitor
165+
{
166+
private HashSet<string> exportedFunctions;
167+
private List<FunctionDefinitionAst> functionDefinitionAsts;
168+
169+
public ViolationFinder()
170+
{
171+
exportedFunctions = new HashSet<string>();
172+
functionDefinitionAsts = new List<FunctionDefinitionAst>();
173+
}
174+
175+
public ViolationFinder(HashSet<string> exportedFunctions) : this()
176+
{
177+
if (exportedFunctions == null)
178+
{
179+
throw new ArgumentNullException(nameof(exportedFunctions));
180+
}
181+
182+
this.exportedFunctions = exportedFunctions;
183+
}
184+
185+
public IEnumerable<FunctionDefinitionAst> FunctionDefinitionAsts { get { return functionDefinitionAsts; } }
186+
187+
/// <summary>
188+
/// Visit function and checks that it has comment help
189+
/// </summary>
190+
/// <param name="funcAst"></param>
191+
/// <returns></returns>
192+
public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst funcAst)
193+
{
194+
if (exportedFunctions.Contains(funcAst.Name)
195+
&& funcAst.GetHelpContent() == null)
196+
{
197+
functionDefinitionAsts.Add(funcAst);
198+
}
199+
200+
return AstVisitAction.Continue;
201+
}
202+
}
203+
164204
private class CommentHelpBuilder
165205
{
166206
private CommentHelpNode synopsis;

0 commit comments

Comments
 (0)