fixed clang-tidy errors

fixed clang compilation error and few clang-tidy issues

Tested:
- Code compiles, all unit tests are passing
- Number of reported clang-tidy issues decreased

Change-Id: Ie3f88db6e2dffb26ec6c56dbdc1ce5bad288dccd
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/src/discrete_threshold.cpp b/src/discrete_threshold.cpp
index 25cc46f..3c98c93 100644
--- a/src/discrete_threshold.cpp
+++ b/src/discrete_threshold.cpp
@@ -6,7 +6,8 @@
     boost::asio::io_context& ioc, Sensors sensorsIn,
     std::vector<std::string> sensorNames,
     std::vector<std::unique_ptr<interfaces::TriggerAction>> actionsIn,
-    Milliseconds dwellTimeIn, double thresholdValueIn, std::string name) :
+    Milliseconds dwellTimeIn, double thresholdValueIn,
+    const std::string& name) :
     ioc(ioc),
     sensors(std::move(sensorsIn)), actions(std::move(actionsIn)),
     dwellTime(dwellTimeIn), thresholdValue(thresholdValueIn), name(name)
diff --git a/src/discrete_threshold.hpp b/src/discrete_threshold.hpp
index 636a4f5..c9bca4d 100644
--- a/src/discrete_threshold.hpp
+++ b/src/discrete_threshold.hpp
@@ -23,11 +23,9 @@
         boost::asio::io_context& ioc, Sensors sensors,
         std::vector<std::string> sensorNames,
         std::vector<std::unique_ptr<interfaces::TriggerAction>> actions,
-        Milliseconds dwellTime, double thresholdValue, std::string name);
+        Milliseconds dwellTime, double thresholdValue, const std::string& name);
     DiscreteThreshold(const DiscreteThreshold&) = delete;
     DiscreteThreshold(DiscreteThreshold&&) = delete;
-    ~DiscreteThreshold()
-    {}
 
     void initialize() override;
     void sensorUpdated(interfaces::Sensor&, Milliseconds) override;
diff --git a/src/metric.cpp b/src/metric.cpp
index d8241b9..582e506 100644
--- a/src/metric.cpp
+++ b/src/metric.cpp
@@ -107,7 +107,8 @@
 class Metric::DataStartup : public Metric::CollectionData
 {
   public:
-    DataStartup(std::shared_ptr<details::CollectionFunction> function) :
+    explicit DataStartup(
+        std::shared_ptr<details::CollectionFunction> function) :
         function(std::move(function))
     {}
 
diff --git a/src/report.cpp b/src/report.cpp
index 170f50d..ed869b9 100644
--- a/src/report.cpp
+++ b/src/report.cpp
@@ -307,9 +307,9 @@
                 readingsBuffer.isFull())
             {
                 enabled = false;
-                for (auto& metric : metrics)
+                for (auto& m : metrics)
                 {
-                    metric->deinitialize();
+                    m->deinitialize();
                 }
                 break;
             }
diff --git a/src/report.hpp b/src/report.hpp
index e2f422d..880ede7 100644
--- a/src/report.hpp
+++ b/src/report.hpp
@@ -31,7 +31,6 @@
            interfaces::JsonStorage& reportStorage,
            std::vector<std::shared_ptr<interfaces::Metric>> metrics,
            const bool enabled, std::unique_ptr<interfaces::Clock> clock);
-    ~Report() = default;
 
     Report(const Report&) = delete;
     Report(Report&&) = delete;
diff --git a/src/report_factory.cpp b/src/report_factory.cpp
index 278b9f1..952b4f2 100644
--- a/src/report_factory.cpp
+++ b/src/report_factory.cpp
@@ -77,7 +77,7 @@
         {
             auto it = std::find_if(
                 tree.begin(), tree.end(),
-                [&sensorPath](const auto& v) { return v.first == sensorPath; });
+                [path = sensorPath](const auto& v) { return v.first == path; });
 
             if (it != tree.end() && it->second.size() == 1)
             {
diff --git a/src/telemetry.hpp b/src/telemetry.hpp
index be2d81c..633c4b0 100644
--- a/src/telemetry.hpp
+++ b/src/telemetry.hpp
@@ -15,7 +15,7 @@
 class Telemetry
 {
   public:
-    Telemetry(std::shared_ptr<sdbusplus::asio::connection> bus) :
+    explicit Telemetry(std::shared_ptr<sdbusplus::asio::connection> bus) :
         objServer(std::make_shared<sdbusplus::asio::object_server>(bus)),
         reportManager(
             std::make_unique<ReportFactory>(bus, objServer, sensorCache),
diff --git a/src/trigger_actions.hpp b/src/trigger_actions.hpp
index 2871256..6a5f7c2 100644
--- a/src/trigger_actions.hpp
+++ b/src/trigger_actions.hpp
@@ -53,7 +53,7 @@
 class LogToJournal : public interfaces::TriggerAction
 {
   public:
-    LogToJournal(::discrete::Severity severity) : severity(severity)
+    explicit LogToJournal(::discrete::Severity severity) : severity(severity)
     {}
 
     void commit(const std::string& id, Milliseconds timestamp,
@@ -68,7 +68,7 @@
 class LogToRedfish : public interfaces::TriggerAction
 {
   public:
-    LogToRedfish(::discrete::Severity severity) : severity(severity)
+    explicit LogToRedfish(::discrete::Severity severity) : severity(severity)
     {}
 
     void commit(const std::string& id, Milliseconds timestamp,
diff --git a/src/trigger_factory.cpp b/src/trigger_factory.cpp
index 0003360..493fe32 100644
--- a/src/trigger_factory.cpp
+++ b/src/trigger_factory.cpp
@@ -33,7 +33,7 @@
     std::vector<TriggerAction> triggerActions;
     std::transform(triggerActionsIn.begin(), triggerActionsIn.end(),
                    std::back_inserter(triggerActions),
-                   [](auto& triggerActionStr) {
+                   [](const auto& triggerActionStr) {
                        return toTriggerAction(triggerActionStr);
                    });
     std::vector<std::shared_ptr<interfaces::Threshold>> thresholds;
@@ -144,7 +144,7 @@
         const auto& [sensorPath, metadata] = item;
         auto found = std::find_if(
             tree.begin(), tree.end(),
-            [&sensorPath](const auto& x) { return x.first == sensorPath; });
+            [path = sensorPath](const auto& x) { return x.first == path; });
 
         if (tree.end() != found)
         {
diff --git a/src/trigger_factory.hpp b/src/trigger_factory.hpp
index 9ae2197..494f5ab 100644
--- a/src/trigger_factory.hpp
+++ b/src/trigger_factory.hpp
@@ -27,7 +27,7 @@
 
     std::vector<LabeledSensorInfo>
         getLabeledSensorsInfo(boost::asio::yield_context& yield,
-                              const SensorsInfo& sensorsInfo) const;
+                              const SensorsInfo& sensorsInfo) const override;
 
   private:
     std::shared_ptr<sdbusplus::asio::connection> bus;
diff --git a/src/utils/circular_vector.hpp b/src/utils/circular_vector.hpp
index 55d3f29..ba185ec 100644
--- a/src/utils/circular_vector.hpp
+++ b/src/utils/circular_vector.hpp
@@ -4,7 +4,7 @@
 class CircularVector
 {
   public:
-    CircularVector(size_t maxSizeIn) : maxSize(maxSizeIn)
+    explicit CircularVector(size_t maxSizeIn) : maxSize(maxSizeIn)
     {}
 
     template <class... Args>
diff --git a/src/utils/labeled_tuple.hpp b/src/utils/labeled_tuple.hpp
index 55789e9..71bf4b0 100644
--- a/src/utils/labeled_tuple.hpp
+++ b/src/utils/labeled_tuple.hpp
@@ -61,7 +61,7 @@
     LabeledTuple(const LabeledTuple&) = default;
     LabeledTuple(LabeledTuple&&) = default;
 
-    LabeledTuple(tuple_type v) : value(std::move(v))
+    explicit LabeledTuple(tuple_type v) : value(std::move(v))
     {}
     LabeledTuple(Args... args) : value(std::move(args)...)
     {}
diff --git a/tests/src/dbus_environment.hpp b/tests/src/dbus_environment.hpp
index 86d7007..eabb53a 100644
--- a/tests/src/dbus_environment.hpp
+++ b/tests/src/dbus_environment.hpp
@@ -119,14 +119,14 @@
         setProperty(const std::string& path, const std::string& interfaceName,
                     const std::string& property, const T& newValue)
     {
-        auto setPromise = std::promise<boost::system::error_code>();
-        auto future = setPromise.get_future();
+        auto promise = std::promise<boost::system::error_code>();
+        auto future = promise.get_future();
         sdbusplus::asio::setProperty(
             *DbusEnvironment::getBus(), DbusEnvironment::serviceName(), path,
             interfaceName, property, std::move(newValue),
-            [setPromise =
-                 std::move(setPromise)](boost::system::error_code ec) mutable {
-                setPromise.set_value(ec);
+            [promise =
+                 std::move(promise)](boost::system::error_code ec) mutable {
+                promise.set_value(ec);
             });
         return DbusEnvironment::waitForFuture(std::move(future));
     }
diff --git a/tests/src/mocks/report_mock.hpp b/tests/src/mocks/report_mock.hpp
index 6a6e259..758290c 100644
--- a/tests/src/mocks/report_mock.hpp
+++ b/tests/src/mocks/report_mock.hpp
@@ -7,7 +7,7 @@
 class ReportMock : public interfaces::Report
 {
   public:
-    ReportMock(const std::string& id)
+    explicit ReportMock(const std::string& id)
     {
         using namespace testing;
 
diff --git a/tests/src/mocks/trigger_mock.hpp b/tests/src/mocks/trigger_mock.hpp
index be40a65..cd0e5f4 100644
--- a/tests/src/mocks/trigger_mock.hpp
+++ b/tests/src/mocks/trigger_mock.hpp
@@ -7,7 +7,7 @@
 class TriggerMock : public interfaces::Trigger
 {
   public:
-    TriggerMock(std::string id)
+    explicit TriggerMock(std::string id)
     {
         using namespace testing;
 
diff --git a/tests/src/test_sensor.cpp b/tests/src/test_sensor.cpp
index 0eae668..c0a9dc3 100644
--- a/tests/src/test_sensor.cpp
+++ b/tests/src/test_sensor.cpp
@@ -110,9 +110,6 @@
 
         ASSERT_TRUE(DbusEnvironment::waitForFuture("async_read"));
     }
-
-    std::shared_ptr<SensorListenerMock> listenerMock2 =
-        std::make_shared<StrictMock<SensorListenerMock>>();
 };
 
 TEST_F(TestSensorNotification, notifiesListenerWithValueWhenChangeOccurs)