From 58db814d7208b709a9b81a8918725c12d95fc73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 8 Sep 2017 12:41:33 +0200 Subject: [PATCH] Rephraze /Same/Identical/ --- lib/checkcondition.cpp | 6 +++--- lib/checkcondition.h | 6 +++--- test/testcondition.cpp | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index c2b9f0e12..92c5ee8db 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -580,7 +580,7 @@ void CheckCondition::multiCondition2() tokens2.push(secondCondition->astOperand2()); } else if (isSameExpression(_tokenizer->isCPP(), true, cond1, secondCondition, _settings->library, true)) { if (!isAliased(vars)) - sameConditionAfterEarlyExitError(cond1, secondCondition); + identicalConditionAfterEarlyExitError(cond1, secondCondition); } } } @@ -663,13 +663,13 @@ void CheckCondition::oppositeInnerConditionError(const Token *tok1, const Token* reportError(errorPath, Severity::warning, "oppositeInnerCondition", msg, CWE398, false); } -void CheckCondition::sameConditionAfterEarlyExitError(const Token *cond1, const Token* cond2) +void CheckCondition::identicalConditionAfterEarlyExitError(const Token *cond1, const Token* cond2) { const std::string cond(cond1 ? cond1->expressionString() : "x"); ErrorPath errorPath; errorPath.push_back(ErrorPathItem(cond1, "first condition")); errorPath.push_back(ErrorPathItem(cond2, "second condition")); - reportError(errorPath, Severity::warning, "sameConditionAfterEarlyExit", "Same condition '" + cond + "', second condition is always false", CWE398, false); + reportError(errorPath, Severity::warning, "identicalConditionAfterEarlyExit", "Identical condition '" + cond + "', second condition is always false", CWE398, false); } //--------------------------------------------------------------------------- diff --git a/lib/checkcondition.h b/lib/checkcondition.h index 9e17ca37c..238f84cde 100644 --- a/lib/checkcondition.h +++ b/lib/checkcondition.h @@ -129,7 +129,7 @@ private: void oppositeInnerConditionError(const Token *tok1, const Token* tok2); - void sameConditionAfterEarlyExitError(const Token *cond1, const Token *cond2); + void identicalConditionAfterEarlyExitError(const Token *cond1, const Token *cond2); void incorrectLogicOperatorError(const Token *tok, const std::string &condition, bool always, bool inconclusive); void redundantConditionError(const Token *tok, const std::string &text, bool inconclusive); @@ -151,7 +151,7 @@ private: c.multiConditionError(nullptr,1); c.mismatchingBitAndError(nullptr, 0xf0, nullptr, 1); c.oppositeInnerConditionError(nullptr, nullptr); - c.sameConditionAfterEarlyExitError(nullptr, nullptr); + c.identicalConditionAfterEarlyExitError(nullptr, nullptr); c.incorrectLogicOperatorError(nullptr, "foo > 3 && foo < 4", true, false); c.redundantConditionError(nullptr, "If x > 11 the condition x > 10 is always true.", false); c.moduloAlwaysTrueFalseError(nullptr, "1"); @@ -172,7 +172,7 @@ private: "- Detect matching 'if' and 'else if' conditions\n" "- Mismatching bitand (a &= 0xf0; a &= 1; => a = 0)\n" "- Opposite inner condition is always false\n" - "- Same condition after early exit is always false\n" + "- Identical condition after early exit is always false\n" "- Condition that is always true/false\n" "- Mutual exclusion over || always evaluating to true\n" "- Comparisons of modulo results that are always true/false.\n" diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 6d26c8e09..7625ac3a3 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -1770,40 +1770,40 @@ private: " if (x > 100) { return; }\n" " if (x > 100) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Same condition 'x>100', second condition is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Identical condition 'x>100', second condition is always false\n", errout.str()); check("void f(int x) {\n" " if (x > 100) { return; }\n" " if (x > 100 || y > 100) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Same condition 'x>100', second condition is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Identical condition 'x>100', second condition is always false\n", errout.str()); check("void f(int x) {\n" " if (x > 100) { return; }\n" " if (x > 100 && y > 100) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Same condition 'x>100', second condition is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Identical condition 'x>100', second condition is always false\n", errout.str()); check("void f(int x) {\n" " if (x > 100) { return; }\n" " if (abc) {}\n" " if (x > 100) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Same condition 'x>100', second condition is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Identical condition 'x>100', second condition is always false\n", errout.str()); check("void f(int x) {\n" " if (x > 100) { return; }\n" " while (abc) { y = x; }\n" " if (x > 100) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Same condition 'x>100', second condition is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Identical condition 'x>100', second condition is always false\n", errout.str()); check("void f(const int *i) {\n" " if (!i) return;\n" " if (!num1tok) { *num1 = *num2; }\n" " if (!i) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Same condition '!i', second condition is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (warning) Identical condition '!i', second condition is always false\n", errout.str()); check("void C::f(Tree &coreTree) {\n" // daca " if(!coreTree.build())\n" @@ -1820,7 +1820,7 @@ private: " coreTree.dostuff();\n" " if(!coreTree.build()) {}\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:6]: (warning) Same condition '!coreTree.build()', second condition is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:6]: (warning) Identical condition '!coreTree.build()', second condition is always false\n", errout.str()); check("void f(int x) {\n" // daca: labplot " switch(type) {\n"