Merge pull request #536 from wilzbach/update-phobos
Update phobos branch
This commit is contained in:
commit
eb16fe4e86
|
@ -1 +1 @@
|
|||
Subproject commit 2892cfc1e7a205d4f81af3970cbb53e4f365a765
|
||||
Subproject commit 11289a9ea5f9de34e01cc157c81d0a962b70628f
|
2
dsymbol
2
dsymbol
|
@ -1 +1 @@
|
|||
Subproject commit 199b171fb3dafa6b63a7f897371b02e9a025403a
|
||||
Subproject commit f672685ab7f5408fb5a74a0cd54e5fc750090d9f
|
2
dub.json
2
dub.json
|
@ -12,7 +12,7 @@
|
|||
"StdLoggerDisableWarning"
|
||||
],
|
||||
"dependencies" : {
|
||||
"libdparse" : "~>0.7.2-alpha.1",
|
||||
"libdparse" : "~>0.7.2-alpha.2",
|
||||
"dsymbol" : "~>0.2.9",
|
||||
"inifiled" : ">=1.0.2",
|
||||
"emsi_containers" : "~>0.5.3",
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 222548fe610ee33dc60a87c9c1322aedd487dcdb
|
||||
Subproject commit 7887ba3665a05a54e511850d009f8f999f89d97d
|
|
@ -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.");
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,8 @@ class UnmodifiedFinder : BaseAnalyzer
|
|||
{
|
||||
if (initializedFromCast(d.initializer))
|
||||
continue;
|
||||
if (initializedFromNew(d.initializer))
|
||||
continue;
|
||||
tree[$ - 1].insert(new VariableInfo(d.name.text, d.name.line,
|
||||
d.name.column, isValueTypeSimple(dec.type)));
|
||||
}
|
||||
|
@ -77,6 +79,8 @@ class UnmodifiedFinder : BaseAnalyzer
|
|||
{
|
||||
if (initializedFromCast(part.initializer))
|
||||
continue;
|
||||
if (initializedFromNew(part.initializer))
|
||||
continue;
|
||||
tree[$ - 1].insert(new VariableInfo(part.identifier.text,
|
||||
part.identifier.line, part.identifier.column));
|
||||
}
|
||||
|
@ -211,6 +215,19 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
bool initializedFromNew(const Initializer initializer)
|
||||
{
|
||||
if (initializer && initializer.nonVoidInitializer &&
|
||||
initializer.nonVoidInitializer.assignExpression &&
|
||||
cast(UnaryExpression) initializer.nonVoidInitializer.assignExpression)
|
||||
{
|
||||
const UnaryExpression ue =
|
||||
cast(UnaryExpression) initializer.nonVoidInitializer.assignExpression;
|
||||
return ue.newExpression !is null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool initializedFromCast(const Initializer initializer)
|
||||
{
|
||||
import std.typecons : scoped;
|
||||
|
@ -325,6 +342,12 @@ bool isValueTypeSimple(const Type type) pure nothrow @nogc
|
|||
StaticAnalysisConfig sac = disabledConfig();
|
||||
sac.could_be_immutable_check = Check.enabled;
|
||||
|
||||
// fails
|
||||
|
||||
assertAnalyzerWarnings(q{
|
||||
void foo(){int i = 1;} // [warn]: Variable i is never modified and could have been declared const or immutable.
|
||||
}, sac);
|
||||
|
||||
// pass
|
||||
|
||||
assertAnalyzerWarnings(q{
|
||||
|
@ -339,4 +362,12 @@ bool isValueTypeSimple(const Type type) pure nothrow @nogc
|
|||
void foo(){enum i = 1;}
|
||||
}, sac);
|
||||
|
||||
assertAnalyzerWarnings(q{
|
||||
void foo(){E e = new E;}
|
||||
}, sac);
|
||||
|
||||
assertAnalyzerWarnings(q{
|
||||
void foo(){auto e = new E;}
|
||||
}, sac);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue