cppcheck: make static analysis more pedantic

This commit is contained in:
Felipe Zimmerle
2020-01-17 11:41:05 -03:00
parent cd9b8aa93b
commit 4f13fecbaf
23 changed files with 58 additions and 42 deletions

View File

@@ -57,3 +57,14 @@ useStlAlgorithm:test/regression/regression.cc:493
useStlAlgorithm:test/unit/unit.cc:174
useStlAlgorithm:test/unit/unit.cc:209
variableScope:src/operators/verify_cpf.cc:45
unusedFunction
funcArgNamesDifferent
preprocessorErrorDirective
useStlAlgorithm
functionStatic:test/regression/regression_test.h:36
missingInclude
toomanyconfigs
functionStatic:src/unique_id.h:49
functionStatic:src/unique_id.h:50
functionConst:src/utils/geo_lookup.h:49
functionStatic:headers/modsecurity/transaction.h:374

View File

@@ -36,13 +36,13 @@ void CustomDebugLog::write(int level, const std::string &id,
m_log << msgf << std::endl;
}
bool CustomDebugLog::contains(const std::string& pattern) {
bool const CustomDebugLog::contains(const std::string& pattern) const {
modsecurity::Utils::Regex re(pattern);
std::string s = m_log.str();
return modsecurity::Utils::regex_search(s, re);
}
std::string CustomDebugLog::log_messages() {
std::string const CustomDebugLog::log_messages() const {
return m_log.str();
}

View File

@@ -31,8 +31,8 @@ class CustomDebugLog : public modsecurity::debug_log::DebugLog {
void write(int level, const std::string& message) override;
void write(int level, const std::string &id,
const std::string &uri, const std::string &msg) override;
bool contains(const std::string& pattern);
std::string log_messages();
bool const contains(const std::string& pattern) const;
std::string const log_messages() const;
std::string error_log_messages();
int getDebugLogLevel() override;

View File

@@ -23,7 +23,7 @@
namespace modsecurity_test {
std::string RegressionTest::print() {
const std::string RegressionTest::print() {
std::stringstream i;
#if 0

View File

@@ -33,7 +33,7 @@ class RegressionTest {
public:
static RegressionTest *from_yajl_node(const yajl_val &);
std::string print();
const std::string print();
std::string filename;
std::string name;
std::string title;

View File

@@ -119,7 +119,7 @@ std::string UnitTest::print() {
}
UnitTest *UnitTest::from_yajl_node(yajl_val &node) {
UnitTest *UnitTest::from_yajl_node(const yajl_val &node) {
size_t num_tests = node->u.object.len;
UnitTest *u = new UnitTest();

View File

@@ -27,7 +27,7 @@ namespace modsecurity_test {
class UnitTest {
public:
static UnitTest *from_yajl_node(yajl_val &);
static UnitTest *from_yajl_node(const yajl_val &);
std::string print();