clang-format: re-format for clang-18

clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version.  The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.

See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.

Change-Id: Ib275562735535218d2faf6c724e49f054d0be4a1
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index d43e884..28e3328 100644
--- a/.clang-format
+++ b/.clang-format
@@ -87,7 +87,7 @@
 IndentWrappedFunctionNames: true
 InsertNewlineAtEOF: true
 KeepEmptyLinesAtTheStartOfBlocks: false
-LambdaBodyIndentation: OuterScope
+LambdaBodyIndentation: Signature
 LineEnding: LF
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
@@ -98,13 +98,14 @@
 ObjCSpaceBeforeProtocolList: true
 PackConstructorInitializers: BinPack
 PenaltyBreakAssignment: 25
-PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakBeforeFirstCallParameter: 50
 PenaltyBreakComment: 300
 PenaltyBreakFirstLessLess: 120
 PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
 PenaltyExcessCharacter: 1000000
 PenaltyReturnTypeOnItsOwnLine: 60
-PenaltyIndentedWhitespace: 0
+PenaltyIndentedWhitespace: 1
 PointerAlignment: Left
 QualifierAlignment: Left
 ReferenceAlignment: Left
diff --git a/analyzer.cpp b/analyzer.cpp
index 81988a1..dbb4a42 100644
--- a/analyzer.cpp
+++ b/analyzer.cpp
@@ -116,8 +116,8 @@
     if (t >= next_update)
     {
         float seconds_since_last_sample =
-            std::chrono::duration_cast<std::chrono::microseconds>(t -
-                                                                  g_last_update)
+            std::chrono::duration_cast<std::chrono::microseconds>(
+                t - g_last_update)
                 .count() /
             1000000.0f;
         g_dbus_statistics.seconds_since_last_sample_ =
@@ -234,20 +234,20 @@
     {
         if (i == N - 1 || (i % 100) == 99)
         {
-            g_footer_view->SetStatusString("2. Getting Creds " +
-                                           std::to_string(i + 1) + "/" +
-                                           std::to_string(N));
+            g_footer_view->SetStatusString(
+                "2. Getting Creds " + std::to_string(i + 1) + "/" +
+                std::to_string(N));
             DBusTopUpdateFooterView();
         }
         const std::string& service = services[i];
         sd_bus_creds* creds = nullptr;
-        r = sd_bus_get_name_creds(bus, services[i].c_str(),
-                                  SD_BUS_CREDS_AUGMENT | SD_BUS_CREDS_EUID |
-                                      SD_BUS_CREDS_PID | SD_BUS_CREDS_COMM |
-                                      SD_BUS_CREDS_UNIQUE_NAME |
-                                      SD_BUS_CREDS_UNIT | SD_BUS_CREDS_SESSION |
-                                      SD_BUS_CREDS_DESCRIPTION,
-                                  &creds);
+        r = sd_bus_get_name_creds(
+            bus, services[i].c_str(),
+            SD_BUS_CREDS_AUGMENT | SD_BUS_CREDS_EUID | SD_BUS_CREDS_PID |
+                SD_BUS_CREDS_COMM | SD_BUS_CREDS_UNIQUE_NAME |
+                SD_BUS_CREDS_UNIT | SD_BUS_CREDS_SESSION |
+                SD_BUS_CREDS_DESCRIPTION,
+            &creds);
         // PID
         int pid = INVALID;
         if (r < 0)
@@ -606,16 +606,16 @@
     {
         if (idx % 100 == 99 || idx == N - 1)
         {
-            g_footer_view->SetStatusString("5. Find Association Definitions " +
-                                           std::to_string(idx + 1) + "/" +
-                                           std::to_string(N));
+            g_footer_view->SetStatusString(
+                "5. Find Association Definitions " + std::to_string(idx + 1) +
+                "/" + std::to_string(N));
             DBusTopUpdateFooterView();
         }
         r = sd_bus_message_enter_container(reply, 'e', "sa{sas}");
         if (r <= 0)
         {
             break;
-        }              // e denotes 'dict entry'
+        } // e denotes 'dict entry'
         const char* p; // path
         r = sd_bus_message_read_basic(reply, 's', &p);
         if (r <= 0)
@@ -785,9 +785,9 @@
     {
         if (i % 100 == 99 || i == N - 1)
         {
-            g_footer_view->SetStatusString("7. Check HWMon DBus objects " +
-                                           std::to_string(i + 1) + "/" +
-                                           std::to_string(N));
+            g_footer_view->SetStatusString(
+                "7. Check HWMon DBus objects " + std::to_string(i + 1) + "/" +
+                std::to_string(N));
             DBusTopUpdateFooterView();
         }
         const std::string& comm = comms[i];
@@ -813,11 +813,9 @@
 }
 } // namespace dbus_top_analyzer
 
-void DBusTopStatistics::OnNewDBusMessage(const char* sender,
-                                         const char* destination,
-                                         const char* interface,
-                                         const char* path, const char* member,
-                                         const char type, sd_bus_message* m)
+void DBusTopStatistics::OnNewDBusMessage(
+    const char* sender, const char* destination, const char* interface,
+    const char* path, const char* member, const char type, sd_bus_message* m)
 {
     num_messages_++;
     std::vector<std::string> keys;
diff --git a/histogram.hpp b/histogram.hpp
index 90a9313..b0e69e0 100644
--- a/histogram.hpp
+++ b/histogram.hpp
@@ -116,8 +116,8 @@
             else
             {
                 buckets_[bucket_idx]++;
-                max_bucket_height_ = std::max(max_bucket_height_,
-                                              buckets_[bucket_idx]);
+                max_bucket_height_ =
+                    std::max(max_bucket_height_, buckets_[bucket_idx]);
             }
         }
     }
diff --git a/menu.cpp b/menu.cpp
index a516c5f..dcff459 100644
--- a/menu.cpp
+++ b/menu.cpp
@@ -202,8 +202,8 @@
         }
         return;
     }
-    const int nrows = (order == ColumnMajor) ? DispEntriesPerColumn()
-                                             : DispEntriesPerRow();
+    const int nrows =
+        (order == ColumnMajor) ? DispEntriesPerColumn() : DispEntriesPerRow();
     const int tot_columns = (N - 1) / nrows + 1;
     const int num_rows_last_column = N - nrows * (tot_columns - 1);
     int y = choice_ % nrows, x = choice_ / nrows;
diff --git a/sensorhelper.hpp b/sensorhelper.hpp
index 1228339..08dd22c 100644
--- a/sensorhelper.hpp
+++ b/sensorhelper.hpp
@@ -119,8 +119,8 @@
                        const std::string& _cmd, const std::string& _unit,
                        int _pid)
     {
-        DBusConnection* cxn = new DBusConnection(_s, _connection, _cmd, _unit,
-                                                 _pid);
+        DBusConnection* cxn =
+            new DBusConnection(_s, _connection, _cmd, _unit, _pid);
         connections_.push_back(cxn);
         unique_name_to_cxn[_connection] = cxn;
     }
@@ -372,10 +372,9 @@
         *in_edges = in;
     }
 
-    void AddAssociationDefinition(const std::string& path,
-                                  const std::string& forward,
-                                  const std::string& reverse,
-                                  const std::string& endpoint)
+    void AddAssociationDefinition(
+        const std::string& path, const std::string& forward,
+        const std::string& reverse, const std::string& endpoint)
     {
         std::vector<std::string> d = {path, forward, reverse, endpoint};
         association_definitions_.push_back(d);
diff --git a/views.cpp b/views.cpp
index 1c36fdb..bf87c95 100644
--- a/views.cpp
+++ b/views.cpp
@@ -114,9 +114,9 @@
         snap = 1000;
     }
     const float eps = snap / 100.0f;
-    int label_ymax = (static_cast<int>((ymax - eps) / snap) + 1) *
-                     snap;                                 // round up
-    int label_ymin = static_cast<int>(ymin / snap) * snap; // round down
+    int label_ymax =
+        (static_cast<int>((ymax - eps) / snap) + 1) * snap; // round up
+    int label_ymin = static_cast<int>(ymin / snap) * snap;  // round down
     float y_per_row = (label_ymax - label_ymin) * 1.0f / (h - 1);
     int actual_ymax = label_ymax + static_cast<int>(y_per_row / 2);
     int actual_ymin = label_ymin - static_cast<int>(y_per_row / 2);
@@ -1146,8 +1146,8 @@
                     }
                     else
                     {
-                        float avg_latency_usec = m.total_latency_usec /
-                                                 m.num_method_calls;
+                        float avg_latency_usec =
+                            m.total_latency_usec / m.num_method_calls;
                         row.push_back(FloatToString(avg_latency_usec));
                         sof.f = avg_latency_usec;
                     }
@@ -1170,8 +1170,8 @@
             stats_snapshot_staged.begin(), stats_snapshot_staged.end(),
             [](const std::pair<StringOrFloat, std::vector<std::string>>& a,
                const std::pair<StringOrFloat, std::vector<std::string>>& b) {
-            return a.first.f < b.first.f;
-        });
+                return a.first.f < b.first.f;
+            });
     }
     else
     {
@@ -1179,8 +1179,8 @@
             stats_snapshot_staged.begin(), stats_snapshot_staged.end(),
             [](const std::pair<StringOrFloat, std::vector<std::string>>& a,
                const std::pair<StringOrFloat, std::vector<std::string>>& b) {
-            return a.first.s < b.first.s;
-        });
+                return a.first.s < b.first.s;
+            });
     }
 
     if (sort_order_ == Descending)