add clang-tidy

This commit implements a clang-tidy file, and makes some changes to get
it to pass.  Most changes are naming or mechanical in nature.

Tested:
Clang-tidy now passes.

Signed-off-by: Ed Tanous <ed@tanous.net>
Change-Id: Ia441e4801b6c8725421d160c531c5df141f255d4
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index b8966a6..3397ea8 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -14,10 +14,9 @@
 // limitations under the License.
 */
 
-#include "PSUEvent.hpp"
-#include "PSUSensor.hpp"
-#include "Utils.hpp"
-
+#include <PSUEvent.hpp>
+#include <PSUSensor.hpp>
+#include <Utils.hpp>
 #include <boost/algorithm/string/predicate.hpp>
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/container/flat_map.hpp>
@@ -38,7 +37,7 @@
 #include <variant>
 #include <vector>
 
-static constexpr bool DEBUG = false;
+static constexpr bool debug = false;
 
 static constexpr std::array<const char*, 17> sensorTypes = {
     "xyz.openbmc_project.Configuration.ADM1272",
@@ -102,7 +101,9 @@
         const std::string& eventName = match.first;
         for (const auto& eventAttr : eventAttrs)
         {
-            auto eventPath = directory + "/" + eventAttr;
+            std::string eventPath = directory;
+            eventPath += "/";
+            eventPath += eventAttr;
 
             std::ifstream eventFile(eventPath);
             if (!eventFile.good())
@@ -141,7 +142,9 @@
             const std::vector<std::string>& eventAttrs = match.second;
             for (const auto& eventAttr : eventAttrs)
             {
-                auto eventPath = directory + "/" + eventAttr;
+                std::string eventPath = directory;
+                eventPath += "/";
+                eventPath += eventAttr;
                 std::ifstream eventFile(eventPath);
                 if (!eventFile.good())
                 {
@@ -279,7 +282,7 @@
 
         fs::path device = directory / "device";
         std::string deviceName = fs::canonical(device).stem();
-        auto findHyphen = deviceName.find("-");
+        auto findHyphen = deviceName.find('-');
         if (findHyphen == std::string::npos)
         {
             std::cerr << "found bad device" << deviceName << "\n";
@@ -294,7 +297,7 @@
         try
         {
             bus = std::stoi(busStr);
-            addr = std::stoi(addrStr, 0, 16);
+            addr = std::stoi(addrStr, nullptr, 16);
         }
         catch (std::invalid_argument&)
         {
@@ -432,7 +435,7 @@
         /* read max value in sysfs for in, curr, power, temp, ... */
         if (!findFiles(directory, R"(\w\d+_max$)", sensorPaths, 0))
         {
-            if constexpr (DEBUG)
+            if constexpr (debug)
             {
                 std::cerr << "No max name in PSU \n";
             }
@@ -473,7 +476,7 @@
             std::string labelPath;
 
             /* find and differentiate _max and _input to replace "label" */
-            size_t pos = sensorPathStr.find("_");
+            size_t pos = sensorPathStr.find('_');
             if (pos != std::string::npos)
             {
 
@@ -499,14 +502,14 @@
             std::ifstream labelFile(labelPath);
             if (!labelFile.good())
             {
-                if constexpr (DEBUG)
+                if constexpr (debug)
                 {
                     std::cerr << "Input file " << sensorPath
                               << " has no corresponding label file\n";
                 }
                 // hwmon *_input filename with number:
                 // temp1, temp2, temp3, ...
-                labelHead = sensorNameStr.substr(0, sensorNameStr.find("_"));
+                labelHead = sensorNameStr.substr(0, sensorNameStr.find('_'));
             }
             else
             {
@@ -521,16 +524,16 @@
 
                 // hwmon corresponding *_label file contents:
                 // vin1, vout1, ...
-                labelHead = label.substr(0, label.find(" "));
+                labelHead = label.substr(0, label.find(' '));
             }
 
             /* append "max" for labelMatch */
             if (maxLabel)
             {
-                labelHead = "max" + labelHead;
+                labelHead.insert(0, "max");
             }
 
-            if constexpr (DEBUG)
+            if constexpr (debug)
             {
                 std::cerr << "Sensor type=\"" << sensorNameSubStr
                           << "\" label=\"" << labelHead << "\"\n";
@@ -545,7 +548,7 @@
                 if (std::find(findLabels.begin(), findLabels.end(),
                               labelHead) == findLabels.end())
                 {
-                    if constexpr (DEBUG)
+                    if constexpr (debug)
                     {
                         std::cerr << "could not find " << labelHead
                                   << " in the Labels list\n";
@@ -557,7 +560,7 @@
             auto findProperty = labelMatch.find(labelHead);
             if (findProperty == labelMatch.end())
             {
-                if constexpr (DEBUG)
+                if constexpr (debug)
                 {
                     std::cerr << "Could not find matching default property for "
                               << labelHead << "\n";
@@ -697,7 +700,7 @@
 
                 psuNameFromIndex = psuNames[nameIndex];
 
-                if constexpr (DEBUG)
+                if constexpr (debug)
                 {
                     std::cerr << "Sensor label head " << labelHead
                               << " paired with " << psuNameFromIndex
@@ -717,7 +720,8 @@
                 factor = std::pow(10.0, factor);
 
                 /* Change first char of substring to uppercase */
-                char firstChar = sensorNameSubStr[0] - 0x20;
+                char firstChar =
+                    static_cast<char>(std::toupper(sensorNameSubStr[0]));
                 std::string strScaleFactor =
                     firstChar + sensorNameSubStr.substr(1) + "ScaleFactor";
 
@@ -730,7 +734,7 @@
                                         findScaleFactor->second);
                 }
 
-                if constexpr (DEBUG)
+                if constexpr (debug)
                 {
                     std::cerr << "Sensor scaling factor " << factor
                               << " string " << strScaleFactor << "\n";
@@ -753,7 +757,7 @@
                 continue;
             }
 
-            if constexpr (DEBUG)
+            if constexpr (debug)
             {
                 std::cerr << "Sensor properties: Name \""
                           << psuProperty->labelTypeName << "\" Scale "
@@ -781,7 +785,7 @@
                     psuNameFromIndex + " " + psuProperty->labelTypeName;
             }
 
-            if constexpr (DEBUG)
+            if constexpr (debug)
             {
                 std::cerr << "Sensor name \"" << sensorName << "\" path \""
                           << sensorPathStr << "\" type \"" << sensorType
@@ -796,7 +800,7 @@
                 psuProperty->minReading, labelHead, thresholdConfSize);
             sensors[sensorName]->setupRead();
             ++numCreated;
-            if constexpr (DEBUG)
+            if constexpr (debug)
             {
                 std::cerr << "Created " << numCreated << " sensors so far\n";
             }
@@ -810,7 +814,7 @@
                 groupEventPathList, "OperationalStatus");
     }
 
-    if constexpr (DEBUG)
+    if constexpr (debug)
     {
         std::cerr << "Created total of " << numCreated << " sensors\n";
     }
@@ -953,7 +957,7 @@
                 {
                     return;
                 }
-                else if (ec)
+                if (ec)
                 {
                     std::cerr << "timer error\n";
                 }