Removes WarningIs(Alpha|Digit) checks as this can introduce more problems than fixes.

This commit is contained in:
Nicolas Le Cam 2008-12-15 23:03:04 +00:00
parent d74dc759a2
commit 40f3ef61c9
3 changed files with 0 additions and 93 deletions

View File

@ -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.. // Redundant code..
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@ -35,12 +35,6 @@ public:
// Casting // Casting
void WarningOldStylePointerCast(); void WarningOldStylePointerCast();
// Use standard functions instead
void WarningIsDigit();
// Use standard functions instead
void WarningIsAlpha();
// Redundant code // Redundant code
void WarningRedundantCode(); void WarningRedundantCode();

View File

@ -302,10 +302,6 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
if (ext && strcmp(ext,".cpp")==0) if (ext && strcmp(ext,".cpp")==0)
checkOther.WarningOldStylePointerCast(); checkOther.WarningOldStylePointerCast();
// Use standard functions instead
checkOther.WarningIsDigit();
checkOther.WarningIsAlpha();
checkClass.CheckOperatorEq1(); checkClass.CheckOperatorEq1();
// if (a) delete a; // if (a) delete a;