fix bug in previous commit: fix #311 (add detection of duplicated if else-cases)
This commit is contained in:
parent
7e403ae210
commit
d22fcb8184
|
@ -3047,9 +3047,6 @@ void CheckOther::checkIncorrectStringCompare()
|
|||
|
||||
static const std::string stringifyTokens(const Token *start, const Token *end)
|
||||
{
|
||||
if (start == end)
|
||||
return "";
|
||||
|
||||
const Token *tok = start;
|
||||
std::string stringified = tok->str();
|
||||
|
||||
|
|
|
@ -2403,6 +2403,12 @@ private:
|
|||
|
||||
void duplicateIf()
|
||||
{
|
||||
check("void f(int a, int &b) {\n"
|
||||
" if (a) { b = 1; }\n"
|
||||
" else if (a) { b = 2; }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:2]: (style) Found duplicate if expressions.\n", errout.str());
|
||||
|
||||
check("void f(int a, int &b) {\n"
|
||||
" if (a == 1) { b = 1; }\n"
|
||||
" else if (a == 2) { b = 2; }\n"
|
||||
|
|
Loading…
Reference in New Issue