MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / oppositeElseIfConditionError

Method oppositeElseIfConditionError

lib/checkcondition.cpp:584–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

582}
583
584void CheckConditionImpl::oppositeElseIfConditionError(const Token *ifCond, const Token *elseIfCond, ErrorPath errorPath)
585{
586 if (diag(ifCond, elseIfCond))
587 return;
588 std::ostringstream errmsg;
589 errmsg << "Expression is always true because 'else if' condition is opposite to previous condition at line "
590 << ifCond->linenr() << ".";
591
592 errorPath.emplace_back(ifCond, "first condition");
593 errorPath.emplace_back(elseIfCond, "else if condition is opposite to first condition");
594
595 reportError(std::move(errorPath), Severity::style, "multiCondition", errmsg.str(), CWE398, Certainty::normal);
596}
597
598//---------------------------------------------------------------------------
599// - Opposite inner conditions => always false

Callers

nothing calls this directly

Calls 3

diagFunction · 0.70
reportErrorFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected