Merge pull request #646 from BBasile/issue-645
fix #645 - False positive, Else branch identical to Then branch with incomplete IfStatement merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
This commit is contained in:
commit
4b394c2a7d
|
@ -31,7 +31,7 @@ final class IfElseSameCheck : BaseAnalyzer
|
|||
|
||||
override void visit(const IfStatement ifStatement)
|
||||
{
|
||||
if (ifStatement.thenStatement == ifStatement.elseStatement)
|
||||
if (ifStatement.thenStatement && (ifStatement.thenStatement == ifStatement.elseStatement))
|
||||
addErrorMessage(ifStatement.line, ifStatement.column,
|
||||
"dscanner.bugs.if_else_same", "'Else' branch is identical to 'Then' branch.");
|
||||
ifStatement.accept(this);
|
||||
|
@ -95,5 +95,13 @@ unittest
|
|||
person = "bobby"; // not same
|
||||
}
|
||||
}c, sac);
|
||||
|
||||
assertAnalyzerWarnings(q{
|
||||
void foo()
|
||||
{
|
||||
if (auto stuff = call())
|
||||
}
|
||||
}c, sac);
|
||||
|
||||
stderr.writeln("Unittest for IfElseSameCheck passed.");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue