Add check for globals
We don't follow this cpp core guidelines rule well. This is something
that we should aspire to cleaning up in the future, but for the moment,
lets turn the rule on in clang-tidy to stop the bleeding, add ignores
for the things that we know need some better abstractions, and work on
these over time.
Most of this commit is just adding NOLINTNEXTLINE exceptions for all of
our globals. There was one case in the sensor code where clang
correctly noted that those globals weren't actually const, which got
missed because of the use of auto.
Tested: CI should be good enough for this. Passes clang-tidy.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ieda08fee69a3b209d4b3e9771809a6c41524f066
diff --git a/include/nbd_proxy.hpp b/include/nbd_proxy.hpp
index ac3a811..68491cb 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -34,7 +34,7 @@
using boost::asio::local::stream_protocol;
static constexpr auto nbdBufferSize = 131088;
-static const char* requiredPrivilegeString = "ConfigureManager";
+constexpr const char* requiredPrivilegeString = "ConfigureManager";
struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
{
@@ -247,9 +247,10 @@
crow::websocket::Connection& connection;
};
-static boost::container::flat_map<crow::websocket::Connection*,
- std::shared_ptr<NbdProxyServer>>
- sessions;
+using SessionMap = boost::container::flat_map<crow::websocket::Connection*,
+ std::shared_ptr<NbdProxyServer>>;
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
+static SessionMap sessions;
inline void requestRoutes(App& app)
{