Removes WarningIs(Alpha|Digit) checks as this can introduce more problems than fixes.
This commit is contained in:
parent
d74dc759a2
commit
40f3ef61c9
|
@ -69,89 +69,6 @@ void CheckOther::WarningOldStylePointerCast()
|
|||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Use standard function "isdigit" instead
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckOther::WarningIsDigit()
|
||||
{
|
||||
for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
{
|
||||
bool err = false;
|
||||
err |= TOKEN::Match(tok, "%var% >= '0' && %var% <= '9'");
|
||||
err |= TOKEN::Match(tok, "* %var% >= '0' && * %var% <= '9'");
|
||||
err |= TOKEN::Match(tok, "( %var% >= '0' ) && ( %var% <= '9' )");
|
||||
err |= TOKEN::Match(tok, "( * %var% >= '0' ) && ( * %var% <= '9' )");
|
||||
if (err)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << _tokenizer->fileLine(tok) << ": The condition can be simplified; use 'isdigit'";
|
||||
_errorLogger->reportErr(ostr.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Use standard function "isalpha" instead
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckOther::WarningIsAlpha()
|
||||
{
|
||||
for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
{
|
||||
if ( tok->str() != "(" )
|
||||
continue;
|
||||
|
||||
bool err = false;
|
||||
|
||||
err |= TOKEN::Match(tok, "( %var% >= 'A' && %var% <= 'Z' )");
|
||||
err |= TOKEN::Match(tok, "( * %var% >= 'A' && * %var% <= 'Z' )");
|
||||
err |= TOKEN::Match(tok, "( ( %var% >= 'A' ) && ( %var% <= 'Z' ) )");
|
||||
err |= TOKEN::Match(tok, "( ( * %var% >= 'A' ) && ( * %var% <= 'Z' ) )");
|
||||
if (err)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << _tokenizer->fileLine(tok) << ": The condition can be simplified; use 'isupper'";
|
||||
_errorLogger->reportErr(ostr.str());
|
||||
continue;
|
||||
}
|
||||
|
||||
err = false;
|
||||
err |= TOKEN::Match(tok, "( %var% >= 'a' && %var% <= 'z' )");
|
||||
err |= TOKEN::Match(tok, "( * %var% >= 'a' && * %var% <= 'z' )");
|
||||
err |= TOKEN::Match(tok, "( ( %var% >= 'a' ) && ( %var% <= 'z' ) )");
|
||||
err |= TOKEN::Match(tok, "( ( * %var% >= 'a' ) && ( * %var% <= 'z' ) )");
|
||||
if (err)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << _tokenizer->fileLine(tok) << ": The condition can be simplified; use 'islower'";
|
||||
_errorLogger->reportErr(ostr.str());
|
||||
continue;
|
||||
}
|
||||
|
||||
err = false;
|
||||
err |= TOKEN::Match(tok, "( %var% >= 'A' && %var% <= 'Z' ) || ( %var% >= 'a' && %var% <= 'z' )");
|
||||
err |= TOKEN::Match(tok, "( %var% >= 'a' && %var% <= 'z' ) || ( %var% >= 'A' && %var% <= 'Z' )");
|
||||
err |= TOKEN::Match(tok, "( * %var% >= 'A' && * %var% <= 'Z' ) || ( * %var% >= 'a' && * %var% <= 'z' )");
|
||||
err |= TOKEN::Match(tok, "( * %var% >= 'a' && * %var% <= 'z' ) || ( * %var% >= 'A' && * %var% <= 'Z' )");
|
||||
err |= TOKEN::Match(tok, "( ( %var% >= 'A' ) && ( %var% <= 'Z' ) ) || ( ( %var% >= 'a' ) && ( %var% <= 'z' ) )");
|
||||
err |= TOKEN::Match(tok, "( ( %var% >= 'a' ) && ( %var% <= 'z' ) ) || ( ( %var% >= 'A' ) && ( %var% <= 'Z' ) )");
|
||||
err |= TOKEN::Match(tok, "( ( * %var% >= 'A' ) && ( * %var% <= 'Z' ) ) || ( ( * var >= 'a' ) && ( * %var% <= 'z' ) )");
|
||||
err |= TOKEN::Match(tok, "( ( * %var% >= 'a' ) && ( * %var% <= 'z' ) ) || ( ( * var >= 'A' ) && ( * %var% <= 'Z' ) )");
|
||||
if (err)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << _tokenizer->fileLine(tok) << ": The condition can be simplified; use 'isalpha'";
|
||||
_errorLogger->reportErr(ostr.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Redundant code..
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -35,12 +35,6 @@ public:
|
|||
// Casting
|
||||
void WarningOldStylePointerCast();
|
||||
|
||||
// Use standard functions instead
|
||||
void WarningIsDigit();
|
||||
|
||||
// Use standard functions instead
|
||||
void WarningIsAlpha();
|
||||
|
||||
// Redundant code
|
||||
void WarningRedundantCode();
|
||||
|
||||
|
|
|
@ -302,10 +302,6 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
|||
if (ext && strcmp(ext,".cpp")==0)
|
||||
checkOther.WarningOldStylePointerCast();
|
||||
|
||||
// Use standard functions instead
|
||||
checkOther.WarningIsDigit();
|
||||
checkOther.WarningIsAlpha();
|
||||
|
||||
checkClass.CheckOperatorEq1();
|
||||
|
||||
// if (a) delete a;
|
||||
|
|
Loading…
Reference in New Issue