diff --git a/test/common/modsecurity_test.cc b/test/common/modsecurity_test.cc index 5b63580f..22757191 100644 --- a/test/common/modsecurity_test.cc +++ b/test/common/modsecurity_test.cc @@ -46,7 +46,7 @@ std::string ModSecurityTest::header() { } template -bool ModSecurityTest::load_test_json(std::string file) { +bool ModSecurityTest::load_test_json(const std::string &file) { char errbuf[1024]; yajl_val node; @@ -76,13 +76,12 @@ bool ModSecurityTest::load_test_json(std::string file) { u->filename = file; if (this->count(u->filename + ":" + u->name) == 0) { - std::vector *vector = new std::vector; - vector->push_back(u); + auto vec = new std::vector; + vec->push_back(u); std::string filename(u->filename + ":" + u->name); - std::pair*> a(filename, vector); - this->insert(a); + this->insert({filename, vec}); } else { - std::vector *vec = this->at(u->filename + ":" + u->name); + auto vec = this->at(u->filename + ":" + u->name); vec->push_back(u); } } @@ -95,7 +94,7 @@ bool ModSecurityTest::load_test_json(std::string file) { template std::pair>* -ModSecurityTest::load_tests(std::string path) { +ModSecurityTest::load_tests(const std::string &path) { DIR *dir; struct dirent *ent; struct stat buffer; diff --git a/test/common/modsecurity_test.h b/test/common/modsecurity_test.h index 83e06ab8..79a168f7 100644 --- a/test/common/modsecurity_test.h +++ b/test/common/modsecurity_test.h @@ -39,8 +39,8 @@ template class ModSecurityTest : std::string header(); void cmd_options(int, char **); std::pair>* load_tests(); - std::pair>* load_tests(std::string path); - bool load_test_json(std::string); + std::pair>* load_tests(const std::string &path); + bool load_test_json(const std::string &file); std::string target; bool verbose = false; diff --git a/test/cppcheck_suppressions.txt b/test/cppcheck_suppressions.txt index 6668c6f2..15234c70 100644 --- a/test/cppcheck_suppressions.txt +++ b/test/cppcheck_suppressions.txt @@ -43,7 +43,6 @@ functionStatic:src/engine/lua.h:70 functionStatic:src/engine/lua.h:71 functionConst:src/utils/geo_lookup.h:49 useInitializationList:src/operators/rbl.h:69 -constStatement:test/common/modsecurity_test.cc:82 functionStatic:src/operators/geo_lookup.h:35 duplicateBreak:src/operators/validate_utf8_encoding.cc syntaxError:src/transaction.cc:62 @@ -55,8 +54,6 @@ rethrowNoCurrentException:src/rule_with_actions.cc:127 ctunullpointer:src/rule_with_actions.cc:244 ctunullpointer:src/rule_with_operator.cc:135 ctunullpointer:src/rule_with_operator.cc:95 -passedByValue:test/common/modsecurity_test.cc:49 -passedByValue:test/common/modsecurity_test.cc:98 unreadVariable:src/rule_with_operator.cc:219 uninitvar:src/operators/verify_cpf.cc:77