Require explicit decorator on one arg constructors
We essentially follow this rule already, not relying on implicit
operators, although there are a number of cases where in theory we
could've implicitly constructed an object.
This commit enables the clang-tidy check.
Tested: Code compiles, passes clang-tidy.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ia428463313b075c69614fdb326e8c5c094e7adde
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 3c47698..1785828 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -374,7 +374,8 @@
// Subscription constructor
}
- Subscription(const std::shared_ptr<boost::beast::tcp_stream>& adaptor) :
+ explicit Subscription(
+ const std::shared_ptr<boost::beast::tcp_stream>& adaptor) :
eventSeqNum(1)
{
sseConn = std::make_shared<crow::ServerSentEvents>(adaptor);
diff --git a/redfish-core/include/privileges.hpp b/redfish-core/include/privileges.hpp
index 160816f..f20cede 100644
--- a/redfish-core/include/privileges.hpp
+++ b/redfish-core/include/privileges.hpp
@@ -198,7 +198,8 @@
}
private:
- Privileges(const std::bitset<maxPrivilegeCount>& p) : privilegeBitset{p}
+ explicit Privileges(const std::bitset<maxPrivilegeCount>& p) :
+ privilegeBitset{p}
{}
std::bitset<maxPrivilegeCount> privilegeBitset = 0;
};
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
index c961b2d..8c05dd7 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -62,7 +62,7 @@
*
* @param[in] app Crow app on which Redfish will initialize
*/
- RedfishService(App& app)
+ explicit RedfishService(App& app)
{
requestAccountServiceRoutes(app);
requestRoutesRoles(app);
diff --git a/redfish-core/include/server_sent_events.hpp b/redfish-core/include/server_sent_events.hpp
index 6663f66..16d8e18 100644
--- a/redfish-core/include/server_sent_events.hpp
+++ b/redfish-core/include/server_sent_events.hpp
@@ -256,7 +256,8 @@
ServerSentEvents(ServerSentEvents&&) = delete;
ServerSentEvents& operator=(ServerSentEvents&&) = delete;
- ServerSentEvents(const std::shared_ptr<boost::beast::tcp_stream>& adaptor) :
+ explicit ServerSentEvents(
+ const std::shared_ptr<boost::beast::tcp_stream>& adaptor) :
sseConn(adaptor)
{
startSSE();
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index b931c7d..2fc606d 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -155,7 +155,7 @@
CertificateFile& operator=(const CertificateFile&) = delete;
CertificateFile(CertificateFile&&) = delete;
CertificateFile& operator=(CertificateFile&&) = delete;
- CertificateFile(const std::string& certString)
+ explicit CertificateFile(const std::string& certString)
{
std::array<char, 18> dirTemplate = {'/', 't', 'm', 'p', '/', 'C',
'e', 'r', 't', 's', '.', 'X',
diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp
index 04281bf..cf84c93 100644
--- a/redfish-core/lib/health.hpp
+++ b/redfish-core/lib/health.hpp
@@ -31,8 +31,10 @@
struct HealthPopulate : std::enable_shared_from_this<HealthPopulate>
{
// By default populate status to "/Status" of |asyncResp->res.jsonValue|.
- HealthPopulate(const std::shared_ptr<bmcweb::AsyncResp>& asyncRespIn) :
- asyncResp(asyncRespIn), statusPtr("/Status")
+ explicit HealthPopulate(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncRespIn) :
+ asyncResp(asyncRespIn),
+ statusPtr("/Status")
{}
// Takes a JSON pointer rather than a reference. This is pretty useful when
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index f15fb0b..bda5a1a 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -1168,7 +1168,8 @@
struct GetPIDValues : std::enable_shared_from_this<GetPIDValues>
{
- GetPIDValues(const std::shared_ptr<bmcweb::AsyncResp>& asyncRespIn) :
+ explicit GetPIDValues(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncRespIn) :
asyncResp(asyncRespIn)
{}
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index ca842d9..8b97b7c 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -307,7 +307,7 @@
class InventoryItem
{
public:
- InventoryItem(const std::string& objPath) : objectPath(objPath)
+ explicit InventoryItem(const std::string& objPath) : objectPath(objPath)
{
// Set inventory item name to last node of object path
sdbusplus::message::object_path path(objectPath);
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp
index b1b1d22..dcad059 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -39,7 +39,7 @@
struct Payload
{
- Payload(const crow::Request& req) :
+ explicit Payload(const crow::Request& req) :
targetUri(req.url), httpOperation(req.methodString()),
httpHeaders(nlohmann::json::array())