clang-tidy: Enable cppcoreguidelines-special-member-functions
The check finds classes where some but not all of the special member
functions are defined.
By default the compiler defines a copy constructor, copy assignment
operator, move constructor, move assignment operator and destructor.
The default can be suppressed by explicit user-definitions. The
relationship between which functions will be suppressed by
definitions of other functions is complicated and it is advised that
all five are defaulted or explicitly defined.
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: Icbfd448b2bf78ebf99ec07b55220871e093cb899
diff --git a/.clang-tidy b/.clang-tidy
index 07ab870..1f35090 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -202,7 +202,8 @@
cppcoreguidelines-pro-type-cstyle-cast,
cppcoreguidelines-pro-type-static-cast-downcast,
cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-slicing'
+cppcoreguidelines-slicing,
+cppcoreguidelines-special-member-functions'
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
diff --git a/src/activation.hpp b/src/activation.hpp
index b7f9cbc..dc708e9 100644
--- a/src/activation.hpp
+++ b/src/activation.hpp
@@ -40,6 +40,14 @@
class ActivationBlocksTransition : public ActivationBlocksTransitionInherit
{
public:
+ ActivationBlocksTransition() = delete;
+ ActivationBlocksTransition(const ActivationBlocksTransition&) = delete;
+ ActivationBlocksTransition&
+ operator=(const ActivationBlocksTransition&) = delete;
+ ActivationBlocksTransition(ActivationBlocksTransition&&) = delete;
+ ActivationBlocksTransition&
+ operator=(ActivationBlocksTransition&&) = delete;
+
/** @brief Constructs ActivationBlocksTransition.
*
* @param[in] bus - The Dbus bus object
diff --git a/src/activation_listener.hpp b/src/activation_listener.hpp
index 5437232..e5de981 100644
--- a/src/activation_listener.hpp
+++ b/src/activation_listener.hpp
@@ -5,6 +5,12 @@
class ActivationListener
{
public:
+ ActivationListener() = default;
+ ActivationListener(const ActivationListener&) = delete;
+ ActivationListener& operator=(const ActivationListener&) = delete;
+ ActivationListener(ActivationListener&&) = delete;
+ ActivationListener& operator=(ActivationListener&&) = delete;
+
virtual ~ActivationListener() = default;
/** @brief Notify a PSU is updated
diff --git a/src/association_interface.hpp b/src/association_interface.hpp
index 2969719..9d25b9b 100644
--- a/src/association_interface.hpp
+++ b/src/association_interface.hpp
@@ -5,6 +5,12 @@
class AssociationInterface
{
public:
+ AssociationInterface() = default;
+ AssociationInterface(const AssociationInterface&) = delete;
+ AssociationInterface& operator=(const AssociationInterface&) = delete;
+ AssociationInterface(AssociationInterface&&) = delete;
+ AssociationInterface& operator=(AssociationInterface&&) = delete;
+
virtual ~AssociationInterface() = default;
/** @brief Create an active association to the
diff --git a/src/utils.hpp b/src/utils.hpp
index 2e73d87..be85494 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -108,6 +108,12 @@
class UtilsInterface
{
public:
+ UtilsInterface() = default;
+ UtilsInterface(const UtilsInterface&) = delete;
+ UtilsInterface& operator=(const UtilsInterface&) = delete;
+ UtilsInterface(UtilsInterface&&) = delete;
+ UtilsInterface& operator=(UtilsInterface&&) = delete;
+
// For now the code needs to get property for Present and Version
using PropertyType = std::variant<std::string, bool>;
diff --git a/test/mocked_activation_listener.hpp b/test/mocked_activation_listener.hpp
index cb8c939..092ab86 100644
--- a/test/mocked_activation_listener.hpp
+++ b/test/mocked_activation_listener.hpp
@@ -7,6 +7,13 @@
class MockedActivationListener : public ActivationListener
{
public:
+ MockedActivationListener() = default;
+ MockedActivationListener(const MockedActivationListener&) = delete;
+ MockedActivationListener&
+ operator=(const MockedActivationListener&) = delete;
+ MockedActivationListener(MockedActivationListener&&) = delete;
+ MockedActivationListener& operator=(MockedActivationListener&&) = delete;
+
~MockedActivationListener() override = default;
MOCK_METHOD2(onUpdateDone, void(const std::string& versionId,
diff --git a/test/mocked_association_interface.hpp b/test/mocked_association_interface.hpp
index ff25861..70e6d01 100644
--- a/test/mocked_association_interface.hpp
+++ b/test/mocked_association_interface.hpp
@@ -7,6 +7,14 @@
class MockedAssociationInterface : public AssociationInterface
{
public:
+ MockedAssociationInterface() = default;
+ MockedAssociationInterface(const MockedAssociationInterface&) = delete;
+ MockedAssociationInterface&
+ operator=(const MockedAssociationInterface&) = delete;
+ MockedAssociationInterface(MockedAssociationInterface&&) = delete;
+ MockedAssociationInterface&
+ operator=(MockedAssociationInterface&&) = delete;
+
~MockedAssociationInterface() override = default;
MOCK_METHOD1(createActiveAssociation, void(const std::string& path));
diff --git a/test/mocked_utils.hpp b/test/mocked_utils.hpp
index 219e25f..ef4baa5 100644
--- a/test/mocked_utils.hpp
+++ b/test/mocked_utils.hpp
@@ -8,6 +8,12 @@
class MockedUtils : public UtilsInterface
{
public:
+ MockedUtils() = default;
+ MockedUtils(const MockedUtils&) = delete;
+ MockedUtils& operator=(const MockedUtils&) = delete;
+ MockedUtils(MockedUtils&&) = delete;
+ MockedUtils& operator=(MockedUtils&&) = delete;
+
~MockedUtils() override = default;
MOCK_CONST_METHOD1(getPSUInventoryPath,
diff --git a/test/test_activation.cpp b/test/test_activation.cpp
index 97b8ff3..f63ee11 100644
--- a/test/test_activation.cpp
+++ b/test/test_activation.cpp
@@ -22,6 +22,12 @@
using PropertyType = utils::UtilsInterface::PropertyType;
using Status = Activation::Status;
using RequestedStatus = Activation::RequestedActivations;
+
+ TestActivation(const TestActivation&) = delete;
+ TestActivation& operator=(const TestActivation&) = delete;
+ TestActivation(TestActivation&&) = delete;
+ TestActivation& operator=(TestActivation&&) = delete;
+
TestActivation() :
mockedUtils(
reinterpret_cast<const utils::MockedUtils&>(utils::getUtils()))
diff --git a/test/test_item_updater.cpp b/test/test_item_updater.cpp
index db1db8e..c231654 100644
--- a/test/test_item_updater.cpp
+++ b/test/test_item_updater.cpp
@@ -22,6 +22,11 @@
using Properties = ItemUpdater::Properties;
using PropertyType = utils::UtilsInterface::PropertyType;
+ TestItemUpdater(const TestItemUpdater&) = delete;
+ TestItemUpdater& operator=(const TestItemUpdater&) = delete;
+ TestItemUpdater(TestItemUpdater&&) = delete;
+ TestItemUpdater& operator=(TestItemUpdater&&) = delete;
+
TestItemUpdater() :
mockedUtils(
reinterpret_cast<const utils::MockedUtils&>(utils::getUtils()))
diff --git a/test/test_version.cpp b/test/test_version.cpp
index ad3a88f..7da0352 100644
--- a/test/test_version.cpp
+++ b/test/test_version.cpp
@@ -26,6 +26,11 @@
class TestVersion : public ::testing::Test
{
public:
+ TestVersion(const TestVersion&) = delete;
+ TestVersion& operator=(const TestVersion&) = delete;
+ TestVersion(TestVersion&&) = delete;
+ TestVersion& operator=(TestVersion&&) = delete;
+
TestVersion()
{
auto tmpPath = fs::temp_directory_path();