Fixed #2334 (Internal class index function (no need to 'strchr'))

This commit is contained in:
Daniel Marjamäki 2010-12-20 18:13:26 +01:00
parent c0bedb5036
commit cdc8801be0
2 changed files with 14 additions and 1 deletions

View File

@ -90,7 +90,10 @@ private:
_obsoleteFunctions.push_back(std::make_pair("getwd","Found obsolete function 'getwd'. It is recommended that new applications use the 'getcwd' function")); _obsoleteFunctions.push_back(std::make_pair("getwd","Found obsolete function 'getwd'. It is recommended that new applications use the 'getcwd' function"));
/* Disabled to fix #2334
_obsoleteFunctions.push_back(std::make_pair("index","Found obsolete function 'index'. It is recommended to use the function 'strchr' instead")); _obsoleteFunctions.push_back(std::make_pair("index","Found obsolete function 'index'. It is recommended to use the function 'strchr' instead"));
*/
_obsoleteFunctions.push_back(std::make_pair("rindex","Found obsolete function 'rindex'. It is recommended to use the function 'strrchr' instead")); _obsoleteFunctions.push_back(std::make_pair("rindex","Found obsolete function 'rindex'. It is recommended to use the function 'strrchr' instead"));
_obsoleteFunctions.push_back(std::make_pair("pthread_attr_getstackaddr","Found obsolete function 'pthread_attr_getstackaddr'.It is recommended that new applications use the 'pthread_attr_getstack' function")); _obsoleteFunctions.push_back(std::make_pair("pthread_attr_getstackaddr","Found obsolete function 'pthread_attr_getstackaddr'.It is recommended that new applications use the 'pthread_attr_getstack' function"));

View File

@ -40,6 +40,7 @@ private:
TEST_CASE(testgethostbyaddr); TEST_CASE(testgethostbyaddr);
TEST_CASE(testusleep); TEST_CASE(testusleep);
TEST_CASE(testindex); TEST_CASE(testindex);
TEST_CASE(test_qt_index); // FP when using the Qt function 'index'?
TEST_CASE(testrindex); TEST_CASE(testrindex);
// no false positives for variables // no false positives for variables
@ -165,7 +166,16 @@ 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]: (style) Found obsolete function 'index'. It is recommended to use the function 'strchr' instead\n", errout.str()); ASSERT_EQUALS("", errout.str());
TODO_ASSERT_EQUALS("[test.cpp:4]: (style) Found obsolete function 'index'. It is recommended to use the function 'strchr' instead\n", errout.str());
}
void test_qt_index()
{
check("void TDataModel::forceRowRefresh(int row) {\n"
" emit dataChanged(index(row, 0), index(row, columnCount() - 1));\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }
void testrindex() void testrindex()