From b737fc0c0f78d93b1b742443f28cf833d6b606b5 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 22 Apr 2018 20:04:03 +0200 Subject: [PATCH] fix #610 - False Negative For Missing Template Param In Ddoc --- .../properly_documented_public_functions.d | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/dscanner/analysis/properly_documented_public_functions.d b/src/dscanner/analysis/properly_documented_public_functions.d index d24909d..abb9d01 100644 --- a/src/dscanner/analysis/properly_documented_public_functions.d +++ b/src/dscanner/analysis/properly_documented_public_functions.d @@ -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;