summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-01-07 20:32:03 +0300
committerEd Tanous <ed@tanous.net>2022-01-12 22:00:37 +0300
commit600d2394cfd3a3a09b126f0570cc66561fd02d31 (patch)
tree8c41708f83ac2833f07b4f119534629f7a8493e5
parentd3a9e08452986b28c8024de2b0fdb3cadbf4411b (diff)
downloadbmcweb-600d2394cfd3a3a09b126f0570cc66561fd02d31.tar.xz
Enable cpp core guidelines macro checks
We only use a couple macros. Ignore them in the checks. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I38feb10f76f6aaea8899617f081c9be68c88b3eb
-rw-r--r--.clang-tidy1
-rw-r--r--http/app.hpp1
-rw-r--r--http/logging.hpp13
3 files changed, 15 insertions, 0 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 311617baa6..ddf3b641ab 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -203,6 +203,7 @@ clang-analyzer-webkit.NoUncountedMemberChecker,
clang-analyzer-webkit.RefCntblBaseVirtualDtor,
cppcoreguidelines-init-variables,
cppcoreguidelines-interfaces-global-init,
+cppcoreguidelines-macro-usage,
cppcoreguidelines-pro-bounds-pointer-arithmetic,
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-pro-type-reinterpret-cast,
diff --git a/http/app.hpp b/http/app.hpp
index 8dcec48e93..03de3f8952 100644
--- a/http/app.hpp
+++ b/http/app.hpp
@@ -16,6 +16,7 @@
#include <string>
#include <utility>
+// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define BMCWEB_ROUTE(app, url) \
app.template route<crow::black_magic::getParameterTag(url)>(url)
diff --git a/http/logging.hpp b/http/logging.hpp
index e2bfdb1365..ca6bdc6521 100644
--- a/http/logging.hpp
+++ b/http/logging.hpp
@@ -105,18 +105,31 @@ class Logger
};
} // namespace crow
+// The logging functions currently use macros. Now that we have c++20, ideally
+// they'd use source_location with fixed functions, but for the moment, disable
+// the check.
+
+// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define BMCWEB_LOG_CRITICAL \
if (crow::Logger::getCurrentLogLevel() <= crow::LogLevel::Critical) \
crow::Logger("CRITICAL", __FILE__, __LINE__, crow::LogLevel::Critical)
+
+// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define BMCWEB_LOG_ERROR \
if (crow::Logger::getCurrentLogLevel() <= crow::LogLevel::Error) \
crow::Logger("ERROR", __FILE__, __LINE__, crow::LogLevel::Error)
+
+// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define BMCWEB_LOG_WARNING \
if (crow::Logger::getCurrentLogLevel() <= crow::LogLevel::Warning) \
crow::Logger("WARNING", __FILE__, __LINE__, crow::LogLevel::Warning)
+
+// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define BMCWEB_LOG_INFO \
if (crow::Logger::getCurrentLogLevel() <= crow::LogLevel::Info) \
crow::Logger("INFO", __FILE__, __LINE__, crow::LogLevel::Info)
+
+// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define BMCWEB_LOG_DEBUG \
if (crow::Logger::getCurrentLogLevel() <= crow::LogLevel::Debug) \
crow::Logger("DEBUG", __FILE__, __LINE__, crow::LogLevel::Debug)