fix #610 - False Negative For Missing Template Param In Ddoc

This commit is contained in:
Basile Burg 2018-04-22 20:04:03 +02:00
parent ab0ac1be43
commit b737fc0c0f
1 changed files with 30 additions and 4 deletions

View File

@ -8,6 +8,7 @@ import dparse.lexer;
import dparse.ast;
import dparse.formatter : astFmt = format;
import dscanner.analysis.base : BaseAnalyzer;
import dscanner.utils : safeAccess;
import std.format : format;
import std.range.primitives;
@ -300,11 +301,17 @@ private:
foreach (p; params.parameters)
{
string templateName;
if (const t = p.type)
if (const t2 = t.type2)
if (const tip = t2.typeIdentifierPart)
if (const iot = tip.identifierOrTemplateInstance)
if (auto iot = safeAccess(p).type.type2
.typeIdentifierPart.identifierOrTemplateInstance.unwrap)
{
templateName = iot.identifier.text;
}
else if (auto iot = safeAccess(p).type.type2.type.type2
.typeIdentifierPart.identifierOrTemplateInstance.unwrap)
{
templateName = iot.identifier.text;
}
const idx = tlList.countUntil(templateName);
if (idx >= 0)
@ -910,6 +917,25 @@ unittest
}, sac);
}
unittest
{
StaticAnalysisConfig sac = disabledConfig;
sac.properly_documented_public_functions = Check.enabled;
assertAnalyzerWarnings(q{
/++
An awesome description.
Params:
items = things to put.
Returns: Awesome values.
+/
void put(Range)(const(Range) items) if (canPutConstRange!Range)
{}
}, sac);
}
unittest
{
StaticAnalysisConfig sac = disabledConfig;