errmsg: Added "found redundant if - 'if (condition);'
This commit is contained in:
parent
153487d504
commit
ae861852e2
|
@ -214,7 +214,7 @@ void CheckOther::WarningIf()
|
|||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << _tokenizer->fileLine(tok) << ": Found \"if (condition);\"";
|
||||
_errorLogger->reportErr(ostr.str());
|
||||
_errorLogger->reportErr(ErrorMessage::ifNoAction(_tokenizer, tok));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -312,11 +312,13 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
|||
if (ErrorMessage::operatorEq(_settings))
|
||||
checkClass.operatorEq();
|
||||
|
||||
if (_settings._checkCodingStyle)
|
||||
{
|
||||
// if (condition);
|
||||
// if (condition);
|
||||
if (ErrorMessage::ifNoAction(_settings))
|
||||
checkOther.WarningIf();
|
||||
|
||||
|
||||
if (_settings._checkCodingStyle)
|
||||
{
|
||||
// Variable scope (check if the scope could be limited)
|
||||
//CheckVariableScope();
|
||||
|
||||
|
|
|
@ -183,5 +183,14 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
static std::string ifNoAction(const Tokenizer *tokenizer, const Token *Location)
|
||||
{
|
||||
return msg1(tokenizer, Location) + "Found redundant if condition - 'if (condition);'";
|
||||
}
|
||||
static bool ifNoAction(const Settings &s)
|
||||
{
|
||||
return s._checkCodingStyle;
|
||||
}
|
||||
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -79,6 +79,7 @@ int main()
|
|||
err.push_back(Message("redundantIfDelete0", Message::STYLE, "Redundant condition. It is safe to deallocate a NULL pointer"));
|
||||
err.push_back(Message("redundantIfRemove", Message::STYLE, "Redundant condition. The remove function in the STL will not do anything if element doesn't exist"));
|
||||
err.push_back(Message("dangerousUsageStrtol", 0, "Invalid radix in call to strtol or strtoul. Must be 0 or 2-36"));
|
||||
err.push_back(Message("ifNoAction", Message::STYLE, "Found redundant if condition - 'if (condition);'"));
|
||||
|
||||
// Generate code..
|
||||
std::cout << "Generate code.." << std::endl;
|
||||
|
|
Loading…
Reference in New Issue