Enable readability-avoid-const-params-in-decls

This check involves explicitly declaring variables const when they're
declared auto, which helps in readability, and makes it more clear that
the variables are const.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I71198ea03850384a389a56ad26f2c4a48c75b148
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index ecc2e9c..8770782 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -185,7 +185,7 @@
 
     nlohmann::json& roleMapArray = jsonResponse[ldapType]["RemoteRoleMapping"];
     roleMapArray = nlohmann::json::array();
-    for (auto& obj : confData.groupRoleList)
+    for (const auto& obj : confData.groupRoleList)
     {
         BMCWEB_LOG_DEBUG << "Pushing the data groupName="
                          << obj.second.groupName << "\n";
@@ -1539,7 +1539,7 @@
                             asyncResp->res.jsonValue["Members"];
                         memberArray = nlohmann::json::array();
 
-                        for (auto& userpath : users)
+                        for (const auto& userpath : users)
                         {
                             std::string user = userpath.first.filename();
                             if (user.empty())
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 34f6770..23e3ead 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -952,7 +952,7 @@
             }
             nlohmann::json& links =
                 asyncResp->res.jsonValue["Links"]["Certificates"];
-            for (auto& cert : certs)
+            for (const auto& cert : certs)
             {
                 long id = getIDFromURL(cert.first.str);
                 if (id >= 0)
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index e4e5eb9..f4260a8 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -450,7 +450,7 @@
         // Check if proper pattern for object path appears
         if (boost::starts_with(objpath.first.str, ipv6PathStart))
         {
-            for (auto& interface : objpath.second)
+            for (const auto& interface : objpath.second)
             {
                 if (interface.first == "xyz.openbmc_project.Network.IP")
                 {
@@ -463,7 +463,7 @@
                     IPv6AddressData& ipv6Address = *it.first;
                     ipv6Address.id =
                         objpath.first.str.substr(ipv6PathStart.size());
-                    for (auto& property : interface.second)
+                    for (const auto& property : interface.second)
                     {
                         if (property.first == "Address")
                         {
@@ -528,7 +528,7 @@
         // Check if proper pattern for object path appears
         if (boost::starts_with(objpath.first.str, ipv4PathStart))
         {
-            for (auto& interface : objpath.second)
+            for (const auto& interface : objpath.second)
             {
                 if (interface.first == "xyz.openbmc_project.Network.IP")
                 {
@@ -541,7 +541,7 @@
                     IPv4AddressData& ipv4Address = *it.first;
                     ipv4Address.id =
                         objpath.first.str.substr(ipv4PathStart.size());
-                    for (auto& property : interface.second)
+                    for (const auto& property : interface.second)
                     {
                         if (property.first == "Address")
                         {
@@ -1782,7 +1782,7 @@
     nlohmann::json& ipv4StaticArray = jsonResponse["IPv4StaticAddresses"];
     ipv4Array = nlohmann::json::array();
     ipv4StaticArray = nlohmann::json::array();
-    for (auto& ipv4Config : ipv4Data)
+    for (const auto& ipv4Config : ipv4Data)
     {
 
         std::string gatewayStr = ipv4Config.gateway;
@@ -1819,7 +1819,7 @@
     nlohmann::json& ipv6AddrPolicyTable =
         jsonResponse["IPv6AddressPolicyTable"];
     ipv6AddrPolicyTable = nlohmann::json::array();
-    for (auto& ipv6Config : ipv6Data)
+    for (const auto& ipv6Config : ipv6Data)
     {
         ipv6Array.push_back({{"Address", ipv6Config.address},
                              {"PrefixLength", ipv6Config.prefixLength},
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index 76032b3..588cf13 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -208,7 +208,7 @@
                 IPv4AddressData& ipv4Address = *it.first;
                 if (ifacePair.first == "xyz.openbmc_project.Object.Enable")
                 {
-                    for (auto& property : ifacePair.second)
+                    for (const auto& property : ifacePair.second)
                     {
                         if (property.first == "Enabled")
                         {
@@ -224,7 +224,7 @@
                 }
                 if (ifacePair.first == "xyz.openbmc_project.Network.IP")
                 {
-                    for (auto& property : ifacePair.second)
+                    for (const auto& property : ifacePair.second)
                     {
                         if (property.first == "Address")
                         {
@@ -497,7 +497,7 @@
     nlohmann::json& ipv4StaticArray = jsonResponse["IPv4StaticAddresses"];
     ipv4Array = nlohmann::json::array();
     ipv4StaticArray = nlohmann::json::array();
-    for (auto& ipv4Config : ipv4Data)
+    for (const auto& ipv4Config : ipv4Data)
     {
         if (ipv4Config.isActive)
         {
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 9f40725..aa4d5ec 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -428,7 +428,7 @@
                     if (interfaceMap.first ==
                         "xyz.openbmc_project.Common.Progress")
                     {
-                        for (auto& propertyMap : interfaceMap.second)
+                        for (const auto& propertyMap : interfaceMap.second)
                         {
                             if (propertyMap.first == "Status")
                             {
@@ -467,7 +467,7 @@
                              "xyz.openbmc_project.Time.EpochTime")
                     {
 
-                        for (auto& propertyMap : interfaceMap.second)
+                        for (const auto& propertyMap : interfaceMap.second)
                         {
                             if (propertyMap.first == "Elapsed")
                             {
@@ -564,7 +564,7 @@
                 std::string(boost::algorithm::to_lower_copy(dumpType)) +
                 "/entry/";
 
-            for (auto& objectPath : resp)
+            for (const auto& objectPath : resp)
             {
                 if (objectPath.first.str != dumpEntryPath + entryID)
                 {
@@ -576,17 +576,18 @@
                 uint64_t size = 0;
                 std::string dumpStatus;
 
-                for (auto& interfaceMap : objectPath.second)
+                for (const auto& interfaceMap : objectPath.second)
                 {
                     if (interfaceMap.first ==
                         "xyz.openbmc_project.Common.Progress")
                     {
-                        for (auto& propertyMap : interfaceMap.second)
+                        for (const auto& propertyMap : interfaceMap.second)
                         {
                             if (propertyMap.first == "Status")
                             {
-                                auto status = std::get_if<std::string>(
-                                    &propertyMap.second);
+                                const std::string* status =
+                                    std::get_if<std::string>(
+                                        &propertyMap.second);
                                 if (status == nullptr)
                                 {
                                     messages::internalError(asyncResp->res);
@@ -599,11 +600,11 @@
                     else if (interfaceMap.first ==
                              "xyz.openbmc_project.Dump.Entry")
                     {
-                        for (auto& propertyMap : interfaceMap.second)
+                        for (const auto& propertyMap : interfaceMap.second)
                         {
                             if (propertyMap.first == "Size")
                             {
-                                auto sizePtr =
+                                const uint64_t* sizePtr =
                                     std::get_if<uint64_t>(&propertyMap.second);
                                 if (sizePtr == nullptr)
                                 {
@@ -618,7 +619,7 @@
                     else if (interfaceMap.first ==
                              "xyz.openbmc_project.Time.EpochTime")
                     {
-                        for (auto& propertyMap : interfaceMap.second)
+                        for (const auto& propertyMap : interfaceMap.second)
                         {
                             if (propertyMap.first == "Elapsed")
                             {
@@ -1373,7 +1374,7 @@
                     nlohmann::json& entriesArray =
                         asyncResp->res.jsonValue["Members"];
                     entriesArray = nlohmann::json::array();
-                    for (auto& objectPath : resp)
+                    for (const auto& objectPath : resp)
                     {
                         const uint32_t* id = nullptr;
                         const uint64_t* timestamp = nullptr;
@@ -1382,12 +1383,13 @@
                         const std::string* message = nullptr;
                         const std::string* filePath = nullptr;
                         bool resolved = false;
-                        for (auto& interfaceMap : objectPath.second)
+                        for (const auto& interfaceMap : objectPath.second)
                         {
                             if (interfaceMap.first ==
                                 "xyz.openbmc_project.Logging.Entry")
                             {
-                                for (auto& propertyMap : interfaceMap.second)
+                                for (const auto& propertyMap :
+                                     interfaceMap.second)
                                 {
                                     if (propertyMap.first == "Id")
                                     {
@@ -1439,7 +1441,8 @@
                             else if (interfaceMap.first ==
                                      "xyz.openbmc_project.Common.FilePath")
                             {
-                                for (auto& propertyMap : interfaceMap.second)
+                                for (const auto& propertyMap :
+                                     interfaceMap.second)
                                 {
                                     if (propertyMap.first == "Path")
                                     {
@@ -1536,7 +1539,7 @@
                         const std::string* filePath = nullptr;
                         bool resolved = false;
 
-                        for (auto& propertyMap : resp)
+                        for (const auto& propertyMap : resp)
                         {
                             if (propertyMap.first == "Id")
                             {
@@ -3423,7 +3426,7 @@
                             return;
                         }
 
-                        auto& [tID, c] = postcodes[value];
+                        const auto& [tID, c] = postcodes[value];
                         if (c.empty())
                         {
                             BMCWEB_LOG_INFO << "No found post code data";
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 9a805f0..c69af7e 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -1214,7 +1214,7 @@
                         }
                         const std::string* current = nullptr;
                         const std::vector<std::string>* supported = nullptr;
-                        for (auto& [key, value] : resp)
+                        for (const auto& [key, value] : resp)
                         {
                             if (key == "Current")
                             {
@@ -1439,7 +1439,7 @@
                         }
                         const std::string* current = nullptr;
                         const std::vector<std::string>* supported = nullptr;
-                        for (auto& [key, value] : r)
+                        for (const auto& [key, value] : r)
                         {
                             if (key == "Current")
                             {
diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp
index f933cd4..89bd8db 100644
--- a/redfish-core/lib/metric_report.hpp
+++ b/redfish-core/lib/metric_report.hpp
@@ -22,7 +22,7 @@
 {
     nlohmann::json metricValues = nlohmann::json::array_t();
 
-    for (auto& [id, metadata, sensorValue, timestamp] : readings)
+    for (const auto& [id, metadata, sensorValue, timestamp] : readings)
     {
         metricValues.push_back({
             {"MetricId", id},
diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
index 745fad8..541e631 100644
--- a/redfish-core/lib/metric_report_definition.hpp
+++ b/redfish-core/lib/metric_report_definition.hpp
@@ -86,7 +86,7 @@
     }
 
     nlohmann::json metrics = nlohmann::json::array();
-    for (auto& [sensorPath, operationType, id, metadata] : *readingParams)
+    for (const auto& [sensorPath, operationType, id, metadata] : *readingParams)
     {
         metrics.push_back({
             {"MetricId", id},
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 121223e..f3fa52c 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -761,11 +761,11 @@
 
     // Check if sensor has critical threshold alarm
 
-    for (auto& [interface, values] : interfacesDict)
+    for (const auto& [interface, values] : interfacesDict)
     {
         if (interface == "xyz.openbmc_project.Sensor.Threshold.Critical")
         {
-            for (auto& [valueName, value] : values)
+            for (const auto& [valueName, value] : values)
             {
                 if (valueName == "CriticalAlarmHigh" ||
                     valueName == "CriticalAlarmLow")
@@ -798,11 +798,11 @@
     }
 
     // Check if sensor has warning threshold alarm
-    for (auto& [interface, values] : interfacesDict)
+    for (const auto& [interface, values] : interfacesDict)
     {
         if (interface == "xyz.openbmc_project.Sensor.Threshold.Warning")
         {
-            for (auto& [valueName, value] : values)
+            for (const auto& [valueName, value] : values)
             {
                 if (valueName == "WarningAlarmHigh" ||
                     valueName == "WarningAlarmLow")
@@ -866,11 +866,11 @@
 {
     // Assume values exist as is (10^0 == 1) if no scale exists
     int64_t scaleMultiplier = 0;
-    for (auto& [interface, values] : interfacesDict)
+    for (const auto& [interface, values] : interfacesDict)
     {
         if (interface == "xyz.openbmc_project.Sensor.Value")
         {
-            for (auto& [valueName, value] : values)
+            for (const auto& [valueName, value] : values)
             {
                 if (valueName == "Scale")
                 {
@@ -1194,13 +1194,15 @@
                                     return;
                                 }
 
-                                auto allowedFailures = std::get_if<uint8_t>(
-                                    &(findFailures->second));
-                                auto collection =
+                                const uint8_t* allowedFailures =
+                                    std::get_if<uint8_t>(
+                                        &(findFailures->second));
+                                const std::vector<std::string>* collection =
                                     std::get_if<std::vector<std::string>>(
                                         &(findCollection->second));
-                                auto status = std::get_if<std::string>(
-                                    &(findStatus->second));
+                                const std::string* status =
+                                    std::get_if<std::string>(
+                                        &(findStatus->second));
 
                                 if (allowedFailures == nullptr ||
                                     collection == nullptr || status == nullptr)
@@ -1467,11 +1469,11 @@
 {
     // Get properties from Inventory.Item interface
 
-    for (auto& [interface, values] : interfacesDict)
+    for (const auto& [interface, values] : interfacesDict)
     {
         if (interface == "xyz.openbmc_project.Inventory.Item")
         {
-            for (auto& [name, dbusValue] : values)
+            for (const auto& [name, dbusValue] : values)
             {
                 if (name == "Present")
                 {
@@ -1493,7 +1495,7 @@
         // Get properties from Inventory.Decorator.Asset interface
         if (interface == "xyz.openbmc_project.Inventory.Decorator.Asset")
         {
-            for (auto& [name, dbusValue] : values)
+            for (const auto& [name, dbusValue] : values)
             {
                 if (name == "Manufacturer")
                 {
@@ -1537,7 +1539,7 @@
         if (interface ==
             "xyz.openbmc_project.State.Decorator.OperationalStatus")
         {
-            for (auto& [name, dbusValue] : values)
+            for (const auto& [name, dbusValue] : values)
             {
                 if (name == "Functional")
                 {
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 3137ab3..ba92748 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -723,7 +723,7 @@
                         nlohmann::json::array();
                     asyncResp->res.jsonValue["Members@odata.count"] = 0;
 
-                    for (auto& obj : subtree)
+                    for (const auto& obj : subtree)
                     {
                         sdbusplus::message::object_path path(obj.first);
                         std::string swId = path.filename();