Reduce noise in undocumented symbol check
This commit is contained in:
parent
8eb19d9235
commit
6258e9886e
|
@ -12,7 +12,8 @@ import analysis.base;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for undocumented public declarations
|
* Checks for undocumented public declarations. Ignores some operator overloads,
|
||||||
|
* main functions, and functions whose name starts with "get" or "set".
|
||||||
*/
|
*/
|
||||||
class UndocumentedDeclarationCheck : BaseAnalyzer
|
class UndocumentedDeclarationCheck : BaseAnalyzer
|
||||||
{
|
{
|
||||||
|
@ -111,9 +112,18 @@ private:
|
||||||
if (declaration.comment is null)
|
if (declaration.comment is null)
|
||||||
{
|
{
|
||||||
static if (hasMember!(T, "name"))
|
static if (hasMember!(T, "name"))
|
||||||
|
{
|
||||||
|
static if (is (T == FunctionDeclaration))
|
||||||
{
|
{
|
||||||
import std.algorithm : canFind;
|
import std.algorithm : canFind;
|
||||||
if (!ignoredNames.canFind(declaration.name.text))
|
if (!(ignoredFunctionNames.canFind(declaration.name.text)
|
||||||
|
|| isGetterOrSetter(declaration.name.text)))
|
||||||
|
{
|
||||||
|
addMessage(declaration.name.line, declaration.name.column,
|
||||||
|
declaration.name.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
addMessage(declaration.name.line, declaration.name.column,
|
addMessage(declaration.name.line, declaration.name.column,
|
||||||
declaration.name.text);
|
declaration.name.text);
|
||||||
|
@ -124,11 +134,20 @@ private:
|
||||||
addMessage(declaration.line, declaration.column, null);
|
addMessage(declaration.line, declaration.column, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static if (!is (T == TemplateDeclaration))
|
static if (!(is (T == TemplateDeclaration)
|
||||||
|
|| is(T == FunctionDeclaration)))
|
||||||
|
{
|
||||||
declaration.accept(this);
|
declaration.accept(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isGetterOrSetter(string name)
|
||||||
|
{
|
||||||
|
import std.algorithm:startsWith;
|
||||||
|
return name.startsWith("get") || name.startsWith("set");
|
||||||
|
}
|
||||||
|
|
||||||
void addMessage(size_t line, size_t column, string name)
|
void addMessage(size_t line, size_t column, string name)
|
||||||
{
|
{
|
||||||
|
@ -182,9 +201,10 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore undocumented symbols with these names
|
// Ignore undocumented symbols with these names
|
||||||
private immutable string[] ignoredNames = [
|
private immutable string[] ignoredFunctionNames = [
|
||||||
"opCmp",
|
"opCmp",
|
||||||
"opEquals",
|
"opEquals",
|
||||||
"toString",
|
"toString",
|
||||||
"toHash"
|
"toHash",
|
||||||
|
"main"
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue