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

Method incorrectLogicOperatorError

lib/checkcondition.cpp:1370–1385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1368}
1369
1370void CheckConditionImpl::incorrectLogicOperatorError(const Token *tok, const std::string &condition, bool always, bool inconclusive, ErrorPath errors)
1371{
1372 if (diag(tok))
1373 return;
1374 errors.emplace_back(tok, "");
1375 if (always)
1376 reportError(std::move(errors), Severity::warning, "incorrectLogicOperator",
1377 "Logical disjunction always evaluates to true: " + condition + ".\n"
1378 "Logical disjunction always evaluates to true: " + condition + ". "
1379 "Are these conditions necessary? Did you intend to use && instead? Are the numbers correct? Are you comparing the correct variables?", CWE571, inconclusive ? Certainty::inconclusive : Certainty::normal);
1380 else
1381 reportError(std::move(errors), Severity::warning, "incorrectLogicOperator",
1382 "Logical conjunction always evaluates to false: " + condition + ".\n"
1383 "Logical conjunction always evaluates to false: " + condition + ". "
1384 "Are these conditions necessary? Did you intend to use || instead? Are the numbers correct? Are you comparing the correct variables?", CWE570, inconclusive ? Certainty::inconclusive : Certainty::normal);
1385}
1386
1387void CheckConditionImpl::redundantConditionError(const Token *tok, const std::string &text, bool inconclusive)
1388{

Callers 1

getErrorMessagesMethod · 0.80

Calls 2

diagFunction · 0.70
reportErrorFunction · 0.70

Tested by

no test coverage detected