From 90cc58cdb39d18d23cd883906e421b28b1739ca8 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Fri, 3 Nov 2017 15:40:31 +0100 Subject: [PATCH] fix #500 --- src/analysis/has_public_example.d | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/analysis/has_public_example.d b/src/analysis/has_public_example.d index 9a0bba8..fe21b33 100644 --- a/src/analysis/has_public_example.d +++ b/src/analysis/has_public_example.d @@ -42,8 +42,14 @@ class HasPublicExampleCheck : BaseAnalyzer } // check all public top-level declarations - foreach (decl; mod.declarations.filter!(decl => isPublic(decl.attributes))) + foreach (decl; mod.declarations) { + if (!isPublic(decl.attributes)) + { + checkLastDecl(); + continue; + } + const bool hasDdocHeader = hasDdocHeader(decl); // check the documentation of a unittest declaration @@ -281,14 +287,18 @@ unittest unittest {} }, sac); - /// check intermediate private declarations and ditto-ed declarations - assertAnalyzerWarnings(q{ + // check intermediate private declarations + // removed for issue #500 + /*assertAnalyzerWarnings(q{ /// C class C{} private void foo(){} /// unittest {} + }, sac);*/ + // check intermediate ditto-ed declarations + assertAnalyzerWarnings(q{ /// I interface I{} /// ditto @@ -297,6 +307,15 @@ unittest unittest {} }, sac); + // test reset on private symbols (#500) + assertAnalyzerWarnings(q{ + /// + void dirName(C)(C[] path) {} // [warn]: Public declaration 'dirName' has no documented example. + private void _dirName(R)(R path) {} + /// + unittest {} + }, sac); + stderr.writeln("Unittest for HasPublicExampleCheck passed."); }