mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Minor codebase improvements suggested by Sonarcloud
- src/modsecurity.cc - Replace the redundant type with "auto". - src/transaction.cc - Avoid this unnecessary copy by using a "const" reference. - test/common/custom_debug_log.cc - Use "=default" instead of the default implementation of this special member functions. - Removed the unnecessary destructor override instead. - Annotate this function with "override" or "final". - Removed the unnecessary destructor override instead. - Remove this "const" qualifier from the return type in all declarations. - test/common/modsecurity_test_context.h - Replace the redundant type with "auto". - test/regression/regression.cc - Use the "nullptr" literal. - Replace this declaration by a structured binding declaration. - Replace "reinterpret_cast" with a safer operation.
This commit is contained in:
@@ -23,8 +23,6 @@
|
||||
|
||||
namespace modsecurity_test {
|
||||
|
||||
CustomDebugLog::~CustomDebugLog() {}
|
||||
|
||||
void CustomDebugLog::write(int level, const std::string &message) {
|
||||
m_log << "[" << level << "] " << message << std::endl;
|
||||
}
|
||||
@@ -36,13 +34,13 @@ namespace modsecurity_test {
|
||||
m_log << msgf << std::endl;
|
||||
}
|
||||
|
||||
bool const CustomDebugLog::contains(const std::string &pattern) const {
|
||||
bool 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 const CustomDebugLog::log_messages() const {
|
||||
std::string CustomDebugLog::log_messages() const {
|
||||
return m_log.str();
|
||||
}
|
||||
|
||||
|
@@ -26,13 +26,12 @@ namespace modsecurity_test {
|
||||
class CustomDebugLog : public modsecurity::debug_log::DebugLog {
|
||||
public:
|
||||
CustomDebugLog *new_instance();
|
||||
~CustomDebugLog();
|
||||
|
||||
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 const contains(const std::string& pattern) const;
|
||||
std::string const log_messages() const;
|
||||
bool contains(const std::string& pattern) const;
|
||||
std::string log_messages() const;
|
||||
std::string error_log_messages();
|
||||
int getDebugLogLevel() override;
|
||||
|
||||
|
@@ -31,8 +31,8 @@ namespace modsecurity_test {
|
||||
|
||||
private:
|
||||
static void logCb(void *data, const void *msgv) {
|
||||
const char *msg = reinterpret_cast<const char *>(msgv);
|
||||
std::stringstream *ss = (std::stringstream *)data;
|
||||
auto msg = reinterpret_cast<const char *>(msgv);
|
||||
auto ss = reinterpret_cast<std::stringstream *>(data);
|
||||
*ss << msg << std::endl;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user