Merge pull request #586 from wilzbach/fix-583
Fix #583 - False negative for missing parameter in Params merged-on-behalf-of: Brian Schott <Hackerpilot@users.noreply.github.com>
This commit is contained in:
commit
68a1fac12b
|
@ -166,8 +166,11 @@ private:
|
||||||
import std.array : array;
|
import std.array : array;
|
||||||
|
|
||||||
const comment = parseComment(commentText, null);
|
const comment = parseComment(commentText, null);
|
||||||
if (!comment.isDitto && !withinTemplate)
|
if (withinTemplate) {
|
||||||
{
|
const paramSection = comment.sections.find!(s => s.name == "Params");
|
||||||
|
if (!paramSection.empty)
|
||||||
|
lastSeenFun.ddocParams ~= paramSection[0].mapping.map!(a => a[0]).array;
|
||||||
|
} else if (!comment.isDitto) {
|
||||||
// check old function for invalid ddoc params
|
// check old function for invalid ddoc params
|
||||||
if (lastSeenFun.active)
|
if (lastSeenFun.active)
|
||||||
postCheckSeenDdocParams();
|
postCheckSeenDdocParams();
|
||||||
|
@ -188,7 +191,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkDdocParams(size_t line, size_t column, const Parameters params,
|
void checkDdocParams(size_t line, size_t column, const Parameters params,
|
||||||
const TemplateParameters templateParameters = null)
|
const TemplateParameters templateParameters = null)
|
||||||
{
|
{
|
||||||
import std.array : array;
|
import std.array : array;
|
||||||
import std.algorithm.searching : canFind, countUntil;
|
import std.algorithm.searching : canFind, countUntil;
|
||||||
|
@ -263,13 +266,13 @@ private:
|
||||||
{
|
{
|
||||||
if (p.templateTypeParameter)
|
if (p.templateTypeParameter)
|
||||||
return p.templateTypeParameter.identifier.text;
|
return p.templateTypeParameter.identifier.text;
|
||||||
if (p.templateValueParameter)
|
if (p.templateValueParameter)
|
||||||
return p.templateValueParameter.identifier.text;
|
return p.templateValueParameter.identifier.text;
|
||||||
if (p.templateAliasParameter)
|
if (p.templateAliasParameter)
|
||||||
return p.templateAliasParameter.identifier.text;
|
return p.templateAliasParameter.identifier.text;
|
||||||
if (p.templateTupleParameter)
|
if (p.templateTupleParameter)
|
||||||
return p.templateTupleParameter.identifier.text;
|
return p.templateTupleParameter.identifier.text;
|
||||||
if (p.templateThisParameter)
|
if (p.templateThisParameter)
|
||||||
return p.templateThisParameter.templateTypeParameter.identifier.text;
|
return p.templateThisParameter.templateTypeParameter.identifier.text;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -280,35 +283,35 @@ private:
|
||||||
import std.meta : AliasSeq;
|
import std.meta : AliasSeq;
|
||||||
alias properties = AliasSeq!(
|
alias properties = AliasSeq!(
|
||||||
"aliasDeclaration",
|
"aliasDeclaration",
|
||||||
"aliasThisDeclaration",
|
"aliasThisDeclaration",
|
||||||
"anonymousEnumDeclaration",
|
"anonymousEnumDeclaration",
|
||||||
"attributeDeclaration",
|
"attributeDeclaration",
|
||||||
"classDeclaration",
|
"classDeclaration",
|
||||||
"conditionalDeclaration",
|
"conditionalDeclaration",
|
||||||
"constructor",
|
"constructor",
|
||||||
"debugSpecification",
|
"debugSpecification",
|
||||||
"destructor",
|
"destructor",
|
||||||
"enumDeclaration",
|
"enumDeclaration",
|
||||||
"eponymousTemplateDeclaration",
|
"eponymousTemplateDeclaration",
|
||||||
"functionDeclaration",
|
"functionDeclaration",
|
||||||
"importDeclaration",
|
"importDeclaration",
|
||||||
"interfaceDeclaration",
|
"interfaceDeclaration",
|
||||||
"invariant_",
|
"invariant_",
|
||||||
"mixinDeclaration",
|
"mixinDeclaration",
|
||||||
"mixinTemplateDeclaration",
|
"mixinTemplateDeclaration",
|
||||||
"postblit",
|
"postblit",
|
||||||
"pragmaDeclaration",
|
"pragmaDeclaration",
|
||||||
"sharedStaticConstructor",
|
"sharedStaticConstructor",
|
||||||
"sharedStaticDestructor",
|
"sharedStaticDestructor",
|
||||||
"staticAssertDeclaration",
|
"staticAssertDeclaration",
|
||||||
"staticConstructor",
|
"staticConstructor",
|
||||||
"staticDestructor",
|
"staticDestructor",
|
||||||
"structDeclaration",
|
"structDeclaration",
|
||||||
"templateDeclaration",
|
"templateDeclaration",
|
||||||
"unionDeclaration",
|
"unionDeclaration",
|
||||||
"unittest_",
|
"unittest_",
|
||||||
"variableDeclaration",
|
"variableDeclaration",
|
||||||
"versionSpecification",
|
"versionSpecification",
|
||||||
);
|
);
|
||||||
if (decl.declarations !is null)
|
if (decl.declarations !is null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -796,6 +799,40 @@ string bar(P, R)(R r){}// [warn]: %s
|
||||||
}c.format(
|
}c.format(
|
||||||
ProperlyDocumentedPublicFunctions.MISSING_TEMPLATE_PARAMS_MESSAGE.format("P")
|
ProperlyDocumentedPublicFunctions.MISSING_TEMPLATE_PARAMS_MESSAGE.format("P")
|
||||||
), sac);
|
), sac);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/dlang-community/D-Scanner/issues/583
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
StaticAnalysisConfig sac = disabledConfig;
|
||||||
|
sac.properly_documented_public_functions = Check.enabled;
|
||||||
|
|
||||||
|
assertAnalyzerWarnings(q{
|
||||||
|
/++
|
||||||
|
Implements the homonym function (also known as `accumulate`)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
the accumulated `result`
|
||||||
|
|
||||||
|
Params:
|
||||||
|
fun = one or more functions
|
||||||
|
+/
|
||||||
|
template reduce(fun...)
|
||||||
|
if (fun.length >= 1)
|
||||||
|
{
|
||||||
|
/++
|
||||||
|
No-seed version. The first element of `r` is used as the seed's value.
|
||||||
|
|
||||||
|
Params:
|
||||||
|
r = an iterable value as defined by `isIterable`
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
the final result of the accumulator applied to the iterable
|
||||||
|
+/
|
||||||
|
auto reduce(R)(R r){}
|
||||||
|
}
|
||||||
|
}c.format(
|
||||||
|
), sac);
|
||||||
|
|
||||||
stderr.writeln("Unittest for ProperlyDocumentedPublicFunctions passed.");
|
stderr.writeln("Unittest for ProperlyDocumentedPublicFunctions passed.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue