Move "information" errors to "style" errors.
"information" severity is documented in lib/errorlogger.h as: Checking information. Information message about the checking (process) itself. These messages inform about header files not found etc issues that are not errors in the code but something user needs to know. It IS NOT for errors in the code. All the current "information"- severity errors fit nicely into description of the "style"- severity. We definitely need to separate processing information and actual errors in the code. It is highly confusing for users to mix these two different things. Hence all current "information" code error messages are moved to "style" category. Ticket: #3165 (Stop misusing the 'information' error severity!)
This commit is contained in:
parent
09df5de964
commit
3cfe7ca1a7
|
@ -191,5 +191,5 @@ void CheckAssignIf::multiConditionError(const Token *tok, unsigned int line1)
|
||||||
errmsg << "'else if' condition matches previous condition at line "
|
errmsg << "'else if' condition matches previous condition at line "
|
||||||
<< line1;
|
<< line1;
|
||||||
|
|
||||||
reportError(tok, Severity::information, "multiCondition", errmsg.str());
|
reportError(tok, Severity::style, "multiCondition", errmsg.str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1762,7 +1762,7 @@ bool CheckClass::isVirtualFunc(const Scope *scope, const Token *functionToken) c
|
||||||
|
|
||||||
void CheckClass::checkConstError(const Token *tok, const std::string &classname, const std::string &funcname)
|
void CheckClass::checkConstError(const Token *tok, const std::string &classname, const std::string &funcname)
|
||||||
{
|
{
|
||||||
reportError(tok, Severity::information, "functionConst",
|
reportError(tok, Severity::style, "functionConst",
|
||||||
"Technically the member function '" + classname + "::" + funcname + "' can be const.\n"
|
"Technically the member function '" + classname + "::" + funcname + "' can be const.\n"
|
||||||
"The member function '" + classname + "::" + funcname + "' can be made a const "
|
"The member function '" + classname + "::" + funcname + "' can be made a const "
|
||||||
"function. Making this function const function should not cause compiler errors. "
|
"function. Making this function const function should not cause compiler errors. "
|
||||||
|
@ -1776,7 +1776,7 @@ void CheckClass::checkConstError2(const Token *tok1, const Token *tok2, const st
|
||||||
std::list<const Token *> toks;
|
std::list<const Token *> toks;
|
||||||
toks.push_back(tok1);
|
toks.push_back(tok1);
|
||||||
toks.push_back(tok2);
|
toks.push_back(tok2);
|
||||||
reportError(toks, Severity::information, "functionConst",
|
reportError(toks, Severity::style, "functionConst",
|
||||||
"Technically the member function '" + classname + "::" + funcname + "' can be const.\n"
|
"Technically the member function '" + classname + "::" + funcname + "' can be const.\n"
|
||||||
"The member function '" + classname + "::" + funcname + "' can be made a const "
|
"The member function '" + classname + "::" + funcname + "' can be made a const "
|
||||||
"function. Making this function const function should not cause compiler errors. "
|
"function. Making this function const function should not cause compiler errors. "
|
||||||
|
|
|
@ -60,7 +60,7 @@ void CheckObsoleteFunctions::obsoleteFunctions()
|
||||||
{
|
{
|
||||||
// If checking an old code base it might be uninteresting to update obsolete functions.
|
// If checking an old code base it might be uninteresting to update obsolete functions.
|
||||||
// Therefore this is "information"
|
// Therefore this is "information"
|
||||||
reportError(tok->tokAt(1), Severity::information, "obsoleteFunctions"+it->first, it->second);
|
reportError(tok->tokAt(1), Severity::style, "obsoleteFunctions"+it->first, it->second);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (_settings->posix)
|
else if (_settings->posix)
|
||||||
|
@ -70,7 +70,7 @@ void CheckObsoleteFunctions::obsoleteFunctions()
|
||||||
{
|
{
|
||||||
// If checking an old code base it might be uninteresting to update obsolete functions.
|
// If checking an old code base it might be uninteresting to update obsolete functions.
|
||||||
// Therefore this is "information"
|
// Therefore this is "information"
|
||||||
reportError(tok->tokAt(1), Severity::information, "obsoleteFunctions"+it->first, it->second);
|
reportError(tok->tokAt(1), Severity::style, "obsoleteFunctions"+it->first, it->second);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1558,7 +1558,7 @@ void CheckOther::lookupVar(const Token *tok1, const std::string &varname)
|
||||||
void CheckOther::variableScopeError(const Token *tok, const std::string &varname)
|
void CheckOther::variableScopeError(const Token *tok, const std::string &varname)
|
||||||
{
|
{
|
||||||
reportError(tok,
|
reportError(tok,
|
||||||
Severity::information,
|
Severity::style,
|
||||||
"variableScope",
|
"variableScope",
|
||||||
"The scope of the variable '" + varname + "' can be reduced\n"
|
"The scope of the variable '" + varname + "' can be reduced\n"
|
||||||
"The scope of the variable '" + varname + "' can be reduced. Warning: It can be unsafe "
|
"The scope of the variable '" + varname + "' can be reduced. Warning: It can be unsafe "
|
||||||
|
|
|
@ -121,14 +121,14 @@ private:
|
||||||
" if (x & 7);\n"
|
" if (x & 7);\n"
|
||||||
" else if (x == 1);\n"
|
" else if (x == 1);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (information) 'else if' condition matches previous condition at line 3\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (style) 'else if' condition matches previous condition at line 3\n", errout.str());
|
||||||
|
|
||||||
check("void foo(int x)\n"
|
check("void foo(int x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if (x & 7);\n"
|
" if (x & 7);\n"
|
||||||
" else if (x & 1);\n"
|
" else if (x & 1);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (information) 'else if' condition matches previous condition at line 3\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (style) 'else if' condition matches previous condition at line 3\n", errout.str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -85,7 +85,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" bsd_signal(SIGABRT, SIG_IGN);\n"
|
" bsd_signal(SIGABRT, SIG_IGN);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (information) Found obsolete function 'bsd_signal'. It is recommended that new applications use the 'sigaction' function\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Found obsolete function 'bsd_signal'. It is recommended that new applications use the 'sigaction' function\n", errout.str());
|
||||||
|
|
||||||
check("int f()\n"
|
check("int f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -105,7 +105,7 @@ private:
|
||||||
" exit(1);\n"
|
" exit(1);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (information) Found obsolete function 'gethostbyname'. It is recommended that new applications use the 'getaddrinfo' function\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (style) Found obsolete function 'gethostbyname'. It is recommended that new applications use the 'getaddrinfo' function\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testgethostbyaddr()
|
void testgethostbyaddr()
|
||||||
|
@ -118,7 +118,7 @@ private:
|
||||||
" exit(1);\n"
|
" exit(1);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (information) Found obsolete function 'gethostbyaddr'. It is recommended that new applications use the 'getnameinfo' function\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:5]: (style) Found obsolete function 'gethostbyaddr'. It is recommended that new applications use the 'getnameinfo' function\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testusleep()
|
void testusleep()
|
||||||
|
@ -127,7 +127,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" usleep( 1000 );\n"
|
" usleep( 1000 );\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (information) Found obsolete function 'usleep'. It is recommended that new applications use the 'nanosleep' or 'setitimer' function\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Found obsolete function 'usleep'. It is recommended that new applications use the 'nanosleep' or 'setitimer' function\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testindex()
|
void testindex()
|
||||||
|
@ -168,7 +168,7 @@ private:
|
||||||
" const char i = index(var, 0);\n"
|
" const char i = index(var, 0);\n"
|
||||||
" return i;\n"
|
" return i;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (information) Found obsolete function 'index'. It is recommended to use the function 'strchr' instead\n",
|
ASSERT_EQUALS("[test.cpp:4]: (style) Found obsolete function 'index'. It is recommended to use the function 'strchr' instead\n",
|
||||||
errout.str());
|
errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ private:
|
||||||
check("void TDataModel::forceRowRefresh(int row) {\n"
|
check("void TDataModel::forceRowRefresh(int row) {\n"
|
||||||
" emit dataChanged(index(row, 0), index(row, columnCount() - 1));\n"
|
" emit dataChanged(index(row, 0), index(row, columnCount() - 1));\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (information) Found obsolete function 'index'. It is recommended to use the function 'strchr' instead\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (style) Found obsolete function 'index'. It is recommended to use the function 'strchr' instead\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testrindex()
|
void testrindex()
|
||||||
|
@ -193,7 +193,7 @@ private:
|
||||||
" const char var[7] = 'rindex';\n"
|
" const char var[7] = 'rindex';\n"
|
||||||
" print(rindex(var, 0));\n"
|
" print(rindex(var, 0));\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (information) Found obsolete function 'rindex'. It is recommended to use the function 'strrchr' instead\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (style) Found obsolete function 'rindex'. It is recommended to use the function 'strrchr' instead\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" char *x = gets();\n"
|
" char *x = gets();\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (information) Found obsolete function 'gets'. It is recommended to use the function 'fgets' instead\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Found obsolete function 'gets'. It is recommended to use the function 'fgets' instead\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ticket #3121
|
// ticket #3121
|
||||||
|
|
|
@ -604,7 +604,7 @@ private:
|
||||||
" for ( ; i < 10; ++i) ;\n"
|
" for ( ; i < 10; ++i) ;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable 'i' can be reduced\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) The scope of the variable 'i' can be reduced\n", errout.str());
|
||||||
|
|
||||||
varScope("void f(int x)\n"
|
varScope("void f(int x)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -614,7 +614,7 @@ private:
|
||||||
" for ( ; i < 10; ++i) ;\n"
|
" for ( ; i < 10; ++i) ;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable 'i' can be reduced\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) The scope of the variable 'i' can be reduced\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void varScope6()
|
void varScope6()
|
||||||
|
@ -680,7 +680,7 @@ private:
|
||||||
" edgeResistance = (edge+1) / 2.0;\n"
|
" edgeResistance = (edge+1) / 2.0;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (information) The scope of the variable 'edgeResistance' can be reduced\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (style) The scope of the variable 'edgeResistance' can be reduced\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void varScope9()
|
void varScope9()
|
||||||
|
|
Loading…
Reference in New Issue