Try to fix the lambda formatting issue

clang-tidy has a setting, LambdaBodyIndentation, which it says:
"For callback-heavy code, it may improve readability to have the
signature indented two levels and to use OuterScope."

bmcweb is very callback heavy code.  Try to enable it and see if that
improves things.  There are many cases where the length of a lambda call
will change, and reindent the entire lambda function.  This is really
bad for code reviews, as it's difficult to see the lines changed.  This
commit should resolve it.  This does have the downside of reindenting a
lot of functions, which is unfortunate, but probably worth it in the
long run.

All changes except for the .clang-format file were made by the robot.

Tested: Code compiles, whitespace changes only.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ib4aa2f1391fada981febd25b67dcdb9143827f43
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index d609acb..7b2a47a 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -29,9 +29,9 @@
     const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
     std::vector<nlohmann::json>& powerControlCollections)
 {
-    auto getChassisPath = [sensorsAsyncResp, powerControlCollections](
-                              const std::optional<std::string>&
-                                  chassisPath) mutable {
+    auto getChassisPath =
+        [sensorsAsyncResp, powerControlCollections](
+            const std::optional<std::string>& chassisPath) mutable {
         if (!chassisPath)
         {
             BMCWEB_LOG_ERROR << "Don't find valid chassis path ";
@@ -76,40 +76,38 @@
             "xyz.openbmc_project.Control.Power.Cap", "PowerCapEnable",
             [value, sensorsAsyncResp](const boost::system::error_code ec,
                                       bool powerCapEnable) {
-                if (ec)
-                {
-                    messages::internalError(sensorsAsyncResp->asyncResp->res);
-                    BMCWEB_LOG_ERROR
-                        << "powerCapEnable Get handler: Dbus error " << ec;
-                    return;
-                }
-                if (!powerCapEnable)
-                {
-                    messages::actionNotSupported(
-                        sensorsAsyncResp->asyncResp->res,
-                        "Setting LimitInWatts when PowerLimit feature is disabled");
-                    BMCWEB_LOG_ERROR << "PowerLimit feature is disabled ";
-                    return;
-                }
+            if (ec)
+            {
+                messages::internalError(sensorsAsyncResp->asyncResp->res);
+                BMCWEB_LOG_ERROR << "powerCapEnable Get handler: Dbus error "
+                                 << ec;
+                return;
+            }
+            if (!powerCapEnable)
+            {
+                messages::actionNotSupported(
+                    sensorsAsyncResp->asyncResp->res,
+                    "Setting LimitInWatts when PowerLimit feature is disabled");
+                BMCWEB_LOG_ERROR << "PowerLimit feature is disabled ";
+                return;
+            }
 
-                crow::connections::systemBus->async_method_call(
-                    [sensorsAsyncResp](const boost::system::error_code ec2) {
-                        if (ec2)
-                        {
-                            BMCWEB_LOG_DEBUG << "Power Limit Set: Dbus error: "
-                                             << ec2;
-                            messages::internalError(
-                                sensorsAsyncResp->asyncResp->res);
-                            return;
-                        }
-                        sensorsAsyncResp->asyncResp->res.result(
-                            boost::beast::http::status::no_content);
-                    },
-                    "xyz.openbmc_project.Settings",
-                    "/xyz/openbmc_project/control/host0/power_cap",
-                    "org.freedesktop.DBus.Properties", "Set",
-                    "xyz.openbmc_project.Control.Power.Cap", "PowerCap",
-                    std::variant<uint32_t>(*value));
+            crow::connections::systemBus->async_method_call(
+                [sensorsAsyncResp](const boost::system::error_code ec2) {
+                if (ec2)
+                {
+                    BMCWEB_LOG_DEBUG << "Power Limit Set: Dbus error: " << ec2;
+                    messages::internalError(sensorsAsyncResp->asyncResp->res);
+                    return;
+                }
+                sensorsAsyncResp->asyncResp->res.result(
+                    boost::beast::http::status::no_content);
+                },
+                "xyz.openbmc_project.Settings",
+                "/xyz/openbmc_project/control/host0/power_cap",
+                "org.freedesktop.DBus.Properties", "Set",
+                "xyz.openbmc_project.Control.Power.Cap", "PowerCap",
+                std::variant<uint32_t>(*value));
             });
     };
     getValidChassisPath(sensorsAsyncResp, std::move(getChassisPath));
@@ -119,198 +117,189 @@
 
     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Power/")
         .privileges(redfish::privileges::getPower)
-        .methods(
-            boost::beast::http::verb::
-                get)([&app](const crow::Request& req,
-                            const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
-                            const std::string& chassisName) {
-            if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+        .methods(boost::beast::http::verb::get)(
+            [&app](const crow::Request& req,
+                   const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+                   const std::string& chassisName) {
+        if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+        {
+            return;
+        }
+        asyncResp->res.jsonValue["PowerControl"] = nlohmann::json::array();
+
+        auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
+            asyncResp, chassisName, sensors::dbus::powerPaths,
+            sensors::node::power);
+
+        getChassisData(sensorAsyncResp);
+
+        // This callback verifies that the power limit is only provided
+        // for the chassis that implements the Chassis inventory item.
+        // This prevents things like power supplies providing the
+        // chassis power limit
+
+        using Mapper = dbus::utility::MapperGetSubTreePathsResponse;
+        auto chassisHandler =
+            [sensorAsyncResp](const boost::system::error_code e,
+                              const Mapper& chassisPaths) {
+            if (e)
             {
+                BMCWEB_LOG_ERROR
+                    << "Power Limit GetSubTreePaths handler Dbus error " << e;
                 return;
             }
-            asyncResp->res.jsonValue["PowerControl"] = nlohmann::json::array();
 
-            auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
-                asyncResp, chassisName, sensors::dbus::powerPaths,
-                sensors::node::power);
-
-            getChassisData(sensorAsyncResp);
-
-            // This callback verifies that the power limit is only provided
-            // for the chassis that implements the Chassis inventory item.
-            // This prevents things like power supplies providing the
-            // chassis power limit
-
-            using Mapper = dbus::utility::MapperGetSubTreePathsResponse;
-            auto chassisHandler = [sensorAsyncResp](
-                                      const boost::system::error_code e,
-                                      const Mapper& chassisPaths) {
-                if (e)
+            bool found = false;
+            for (const std::string& chassis : chassisPaths)
+            {
+                size_t len = std::string::npos;
+                size_t lastPos = chassis.rfind('/');
+                if (lastPos == std::string::npos)
                 {
-                    BMCWEB_LOG_ERROR
-                        << "Power Limit GetSubTreePaths handler Dbus error "
-                        << e;
-                    return;
+                    continue;
                 }
 
-                bool found = false;
-                for (const std::string& chassis : chassisPaths)
+                if (lastPos == chassis.size() - 1)
                 {
-                    size_t len = std::string::npos;
-                    size_t lastPos = chassis.rfind('/');
+                    size_t end = lastPos;
+                    lastPos = chassis.rfind('/', lastPos - 1);
                     if (lastPos == std::string::npos)
                     {
                         continue;
                     }
 
-                    if (lastPos == chassis.size() - 1)
-                    {
-                        size_t end = lastPos;
-                        lastPos = chassis.rfind('/', lastPos - 1);
-                        if (lastPos == std::string::npos)
-                        {
-                            continue;
-                        }
-
-                        len = end - (lastPos + 1);
-                    }
-
-                    std::string interfaceChassisName =
-                        chassis.substr(lastPos + 1, len);
-                    if (interfaceChassisName == sensorAsyncResp->chassisId)
-                    {
-                        found = true;
-                        break;
-                    }
+                    len = end - (lastPos + 1);
                 }
 
-                if (!found)
+                std::string interfaceChassisName =
+                    chassis.substr(lastPos + 1, len);
+                if (interfaceChassisName == sensorAsyncResp->chassisId)
                 {
-                    BMCWEB_LOG_DEBUG << "Power Limit not present for "
-                                     << sensorAsyncResp->chassisId;
+                    found = true;
+                    break;
+                }
+            }
+
+            if (!found)
+            {
+                BMCWEB_LOG_DEBUG << "Power Limit not present for "
+                                 << sensorAsyncResp->chassisId;
+                return;
+            }
+
+            auto valueHandler =
+                [sensorAsyncResp](
+                    const boost::system::error_code ec,
+                    const dbus::utility::DBusPropertiesMap& properties) {
+                if (ec)
+                {
+                    messages::internalError(sensorAsyncResp->asyncResp->res);
+                    BMCWEB_LOG_ERROR
+                        << "Power Limit GetAll handler: Dbus error " << ec;
                     return;
                 }
 
-                auto valueHandler =
-                    [sensorAsyncResp](
-                        const boost::system::error_code ec,
-                        const dbus::utility::DBusPropertiesMap& properties) {
-                        if (ec)
+                nlohmann::json& tempArray =
+                    sensorAsyncResp->asyncResp->res.jsonValue["PowerControl"];
+
+                // Put multiple "sensors" into a single PowerControl, 0,
+                // so only create the first one
+                if (tempArray.empty())
+                {
+                    // Mandatory properties odata.id and MemberId
+                    // A warning without a odata.type
+                    nlohmann::json::object_t powerControl;
+                    powerControl["@odata.type"] = "#Power.v1_0_0.PowerControl";
+                    powerControl["@odata.id"] = "/redfish/v1/Chassis/" +
+                                                sensorAsyncResp->chassisId +
+                                                "/Power#/PowerControl/0";
+                    powerControl["Name"] = "Chassis Power Control";
+                    powerControl["MemberId"] = "0";
+                    tempArray.push_back(std::move(powerControl));
+                }
+
+                nlohmann::json& sensorJson = tempArray.back();
+                bool enabled = false;
+                double powerCap = 0.0;
+                int64_t scale = 0;
+
+                for (const std::pair<std::string,
+                                     dbus::utility::DbusVariantType>& property :
+                     properties)
+                {
+                    if (property.first == "Scale")
+                    {
+                        const int64_t* i =
+                            std::get_if<int64_t>(&property.second);
+
+                        if (i != nullptr)
                         {
-                            messages::internalError(
-                                sensorAsyncResp->asyncResp->res);
-                            BMCWEB_LOG_ERROR
-                                << "Power Limit GetAll handler: Dbus error "
-                                << ec;
-                            return;
+                            scale = *i;
                         }
+                    }
+                    else if (property.first == "PowerCap")
+                    {
+                        const double* d = std::get_if<double>(&property.second);
+                        const int64_t* i =
+                            std::get_if<int64_t>(&property.second);
+                        const uint32_t* u =
+                            std::get_if<uint32_t>(&property.second);
 
-                        nlohmann::json& tempArray =
-                            sensorAsyncResp->asyncResp->res
-                                .jsonValue["PowerControl"];
-
-                        // Put multiple "sensors" into a single PowerControl, 0,
-                        // so only create the first one
-                        if (tempArray.empty())
+                        if (d != nullptr)
                         {
-                            // Mandatory properties odata.id and MemberId
-                            // A warning without a odata.type
-                            nlohmann::json::object_t powerControl;
-                            powerControl["@odata.type"] =
-                                "#Power.v1_0_0.PowerControl";
-                            powerControl["@odata.id"] =
-                                "/redfish/v1/Chassis/" +
-                                sensorAsyncResp->chassisId +
-                                "/Power#/PowerControl/0";
-                            powerControl["Name"] = "Chassis Power Control";
-                            powerControl["MemberId"] = "0";
-                            tempArray.push_back(std::move(powerControl));
+                            powerCap = *d;
                         }
-
-                        nlohmann::json& sensorJson = tempArray.back();
-                        bool enabled = false;
-                        double powerCap = 0.0;
-                        int64_t scale = 0;
-
-                        for (const std::pair<std::string,
-                                             dbus::utility::DbusVariantType>&
-                                 property : properties)
+                        else if (i != nullptr)
                         {
-                            if (property.first == "Scale")
-                            {
-                                const int64_t* i =
-                                    std::get_if<int64_t>(&property.second);
-
-                                if (i != nullptr)
-                                {
-                                    scale = *i;
-                                }
-                            }
-                            else if (property.first == "PowerCap")
-                            {
-                                const double* d =
-                                    std::get_if<double>(&property.second);
-                                const int64_t* i =
-                                    std::get_if<int64_t>(&property.second);
-                                const uint32_t* u =
-                                    std::get_if<uint32_t>(&property.second);
-
-                                if (d != nullptr)
-                                {
-                                    powerCap = *d;
-                                }
-                                else if (i != nullptr)
-                                {
-                                    powerCap = static_cast<double>(*i);
-                                }
-                                else if (u != nullptr)
-                                {
-                                    powerCap = *u;
-                                }
-                            }
-                            else if (property.first == "PowerCapEnable")
-                            {
-                                const bool* b =
-                                    std::get_if<bool>(&property.second);
-
-                                if (b != nullptr)
-                                {
-                                    enabled = *b;
-                                }
-                            }
+                            powerCap = static_cast<double>(*i);
                         }
-
-                        nlohmann::json& value =
-                            sensorJson["PowerLimit"]["LimitInWatts"];
-
-                        // LimitException is Mandatory attribute as per OCP
-                        // Baseline Profile – v1.0.0, so currently making it
-                        // "NoAction" as default value to make it OCP Compliant.
-                        sensorJson["PowerLimit"]["LimitException"] = "NoAction";
-
-                        if (enabled)
+                        else if (u != nullptr)
                         {
-                            // Redfish specification indicates PowerLimit should
-                            // be null if the limit is not enabled.
-                            value = powerCap * std::pow(10, scale);
+                            powerCap = *u;
                         }
-                    };
+                    }
+                    else if (property.first == "PowerCapEnable")
+                    {
+                        const bool* b = std::get_if<bool>(&property.second);
 
-                crow::connections::systemBus->async_method_call(
-                    std::move(valueHandler), "xyz.openbmc_project.Settings",
-                    "/xyz/openbmc_project/control/host0/power_cap",
-                    "org.freedesktop.DBus.Properties", "GetAll",
-                    "xyz.openbmc_project.Control.Power.Cap");
+                        if (b != nullptr)
+                        {
+                            enabled = *b;
+                        }
+                    }
+                }
+
+                nlohmann::json& value =
+                    sensorJson["PowerLimit"]["LimitInWatts"];
+
+                // LimitException is Mandatory attribute as per OCP
+                // Baseline Profile – v1.0.0, so currently making it
+                // "NoAction" as default value to make it OCP Compliant.
+                sensorJson["PowerLimit"]["LimitException"] = "NoAction";
+
+                if (enabled)
+                {
+                    // Redfish specification indicates PowerLimit should
+                    // be null if the limit is not enabled.
+                    value = powerCap * std::pow(10, scale);
+                }
             };
 
             crow::connections::systemBus->async_method_call(
-                std::move(chassisHandler), "xyz.openbmc_project.ObjectMapper",
-                "/xyz/openbmc_project/object_mapper",
-                "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
-                "/xyz/openbmc_project/inventory", 0,
-                std::array<const char*, 2>{
-                    "xyz.openbmc_project.Inventory.Item.Board",
-                    "xyz.openbmc_project.Inventory.Item.Chassis"});
+                std::move(valueHandler), "xyz.openbmc_project.Settings",
+                "/xyz/openbmc_project/control/host0/power_cap",
+                "org.freedesktop.DBus.Properties", "GetAll",
+                "xyz.openbmc_project.Control.Power.Cap");
+        };
+
+        crow::connections::systemBus->async_method_call(
+            std::move(chassisHandler), "xyz.openbmc_project.ObjectMapper",
+            "/xyz/openbmc_project/object_mapper",
+            "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
+            "/xyz/openbmc_project/inventory", 0,
+            std::array<const char*, 2>{
+                "xyz.openbmc_project.Inventory.Item.Board",
+                "xyz.openbmc_project.Inventory.Item.Chassis"});
         });
 
     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Power/")
@@ -319,37 +308,36 @@
             [&app](const crow::Request& req,
                    const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
                    const std::string& chassisName) {
-                if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
-                {
-                    return;
-                }
-                auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
-                    asyncResp, chassisName, sensors::dbus::powerPaths,
-                    sensors::node::power);
+        if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+        {
+            return;
+        }
+        auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
+            asyncResp, chassisName, sensors::dbus::powerPaths,
+            sensors::node::power);
 
-                std::optional<std::vector<nlohmann::json>> voltageCollections;
-                std::optional<std::vector<nlohmann::json>> powerCtlCollections;
+        std::optional<std::vector<nlohmann::json>> voltageCollections;
+        std::optional<std::vector<nlohmann::json>> powerCtlCollections;
 
-                if (!json_util::readJsonPatch(
-                        req, sensorAsyncResp->asyncResp->res, "PowerControl",
-                        powerCtlCollections, "Voltages", voltageCollections))
-                {
-                    return;
-                }
+        if (!json_util::readJsonPatch(req, sensorAsyncResp->asyncResp->res,
+                                      "PowerControl", powerCtlCollections,
+                                      "Voltages", voltageCollections))
+        {
+            return;
+        }
 
-                if (powerCtlCollections)
-                {
-                    setPowerCapOverride(sensorAsyncResp, *powerCtlCollections);
-                }
-                if (voltageCollections)
-                {
-                    std::unordered_map<std::string, std::vector<nlohmann::json>>
-                        allCollections;
-                    allCollections.emplace("Voltages",
-                                           *std::move(voltageCollections));
-                    setSensorsOverride(sensorAsyncResp, allCollections);
-                }
-            });
+        if (powerCtlCollections)
+        {
+            setPowerCapOverride(sensorAsyncResp, *powerCtlCollections);
+        }
+        if (voltageCollections)
+        {
+            std::unordered_map<std::string, std::vector<nlohmann::json>>
+                allCollections;
+            allCollections.emplace("Voltages", *std::move(voltageCollections));
+            setSensorsOverride(sensorAsyncResp, allCollections);
+        }
+        });
 }
 
 } // namespace redfish