Skip to content

[DRAFT FOR TESTS] adding clang tidy comments on modified code#279

Closed
atsju wants to merge 1 commit into
masterfrom
JST/clang-tidy
Closed

[DRAFT FOR TESTS] adding clang tidy comments on modified code#279
atsju wants to merge 1 commit into
masterfrom
JST/clang-tidy

Conversation

@atsju

@atsju atsju commented Nov 19, 2025

Copy link
Copy Markdown
Collaborator

This is a new github action for code quality. It should annotate code based on advanced checks (that we can fine tune) https://clang.llvm.org/extra/clang-tidy/checks/list.html

I made it so that only new code will be annotated and we live with older code as it is.

I'm working on this and not on some other more important features because I want to try it out and eventually reuse it at work.

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit 3628292
Download installer here

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit 73f628f
Download installer here

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit 875ae62
Download installer here

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit 4bbfc49
Download installer here

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit 09d7df3
Download installer here

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit 51792b5
Download installer here

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit ab32b11
Download installer here

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit 070ca27
Download installer here

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit 7f571b5
Download installer here

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit 69a551c
Download installer here

@atsju atsju changed the title adding clang tidy comments on modified code [DRAFT FOR TESTS] adding clang tidy comments on modified code Nov 21, 2025
@atsju atsju marked this pull request as ready for review November 21, 2025 15:05

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-tidy v18.1.3

Only 3 out of 10 clang-tidy concerns fit within this pull request's diff.

Click here for the full clang-tidy patch
diff --git a/main.cpp b/main.cpp
index 6a77a6e..1454845 100644
--- a/main.cpp
+++ b/main.cpp
@@ -114,8 +114,8 @@ static void myQtMessageOutput(QtMsgType type, const QMessageLogContext &/*contex
-static int myCvErrorCallback( int /*status*/, const char* /*func_name*/,
-            const char* err_msg, const char* file_name,
-            int line, void* /*userdata*/ )
-{
-    spdlog::get("logger")->critical("CV error :{} in {} on line {}", err_msg, file_name, line);
-
-    my_terminate_handler();
-    return 0;   //Return value is not used
+static auto myCvErrorCallback(int /*status*/, const char * /*func_name*/,
+                              const char *err_msg, const char *file_name,
+                              int line, void * /*userdata*/) -> int {
+  spdlog::get("logger")->critical("CV error :{} in {} on line {}", err_msg,
+                                  file_name, line);
+
+  my_terminate_handler();
+  return 0; // Return value is not used
@@ -124,12 +124,12 @@ static int myCvErrorCallback( int /*status*/, const char* /*func_name*/,
-int main(int argc, char *argv[])
-{
-// DFTFringe doesn't have a good darkmode palette
-// one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark mode (except for app borders)
-// Following code adds the platform argument programmatically
-
-// Create a new argv array with existing args plus platform args
-int newArgc = argc + 2;
-std::vector<std::string> args;
-args.reserve(newArgc);
-// Copy existing arguments
-for (int i = 0; i < argc; ++i) {
+auto main(int argc, char *argv[]) -> int {
+  // DFTFringe doesn't have a good darkmode palette
+  // one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark
+  // mode (except for app borders) Following code adds the platform argument
+  // programmatically
+
+  // Create a new argv array with existing args plus platform args
+  int newArgc = argc + 2;
+  std::vector<std::string> args;
+  args.reserve(newArgc);
+  // Copy existing arguments
+  for (int i = 0; i < argc; ++i) {
@@ -145 +145 @@ for (auto &arg : args) {
-    newArgv.push_back(&arg[0]); // C++11 guarantees contiguous storage
+  newArgv.push_back(arg.data()); // C++11 guarantees contiguous storage
@@ -155,9 +155,2 @@ MessageReceiver msgReceiver;
-        app.sendMessage( app.arguments().join('\'').toUtf8() );
-        return 0;
-    } else {
-        QObject::connect(
-            &app,
-            &SingleApplication::receivedMessage,
-            &msgReceiver,
-            &MessageReceiver::receivedMessage
-        );
+      app.sendMessage(SingleApplication::arguments().join('\'').toUtf8());
+      return 0;
@@ -164,0 +158,2 @@ MessageReceiver msgReceiver;
+    QObject::connect(&app, &SingleApplication::receivedMessage, &msgReceiver,
+                     &MessageReceiver::receivedMessage);
@@ -166,2 +161,2 @@ MessageReceiver msgReceiver;
-    app.setOrganizationName("DFTFringe");
-    app.setApplicationName("DFTFringe");
+    SingleApplication::setOrganizationName("DFTFringe");
+    SingleApplication::setApplicationName("DFTFringe");
@@ -215 +210 @@ MessageReceiver msgReceiver;
-    MainWindow *w = new MainWindow;
+    auto *w = new MainWindow;
@@ -223 +218 @@ MessageReceiver msgReceiver;
-    return app.exec();
+    return SingleApplication::exec();

Used clang-format v18.1.3

Only 5 out of 30 clang-format concerns fit within this pull request's diff.

Click here for the full clang-format patch
diff --git a/main.cpp b/main.cpp
index 6a77a6e..3016627 100644
--- a/main.cpp
+++ b/main.cpp
@@ -18,3 +17,0 @@
-#include "spdlog/spdlog.h"
-#include "spdlog/sinks/rotating_file_sink.h"
-#include "spdlog/sinks/stdout_color_sinks.h"
@@ -23,2 +19,0 @@
-#include <QApplication>
-#include "singleapplication.h"
@@ -25,0 +21,4 @@
+#include "singleapplication.h"
+#include "spdlog/sinks/rotating_file_sink.h"
+#include "spdlog/sinks/stdout_color_sinks.h"
+#include "spdlog/spdlog.h"
@@ -26,0 +26 @@
+#include <QApplication>
@@ -30,50 +30,36 @@
-    #include <Windows.h>
-    #include <DbgHelp.h>
-    #include <ctime>
-
-    LONG WINAPI MyUnhandledExceptionFilter(EXCEPTION_POINTERS* ExceptionInfo)
-    {
-        // Create a timestamped filename
-        time_t now = time(nullptr);
-        char filename[MAX_PATH];
-        strftime(filename, sizeof(filename), "DFTFringeLogs\\crashdump_%Y%m%d_%H%M%S.dmp", localtime(&now));
-
-        HANDLE hFile = CreateFileA(filename, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
-        if (hFile == INVALID_HANDLE_VALUE) {
-            return EXCEPTION_EXECUTE_HANDLER;
-        }
-
-        if(ExceptionInfo != nullptr)
-        {
-            MINIDUMP_EXCEPTION_INFORMATION dumpInfo;
-            dumpInfo.ThreadId = GetCurrentThreadId();
-            dumpInfo.ExceptionPointers = ExceptionInfo;
-            dumpInfo.ClientPointers = FALSE;
-
-            MiniDumpWriteDump(
-                GetCurrentProcess(),
-                GetCurrentProcessId(),
-                hFile,
-                MiniDumpNormal,
-                &dumpInfo,
-                nullptr,
-                nullptr
-            );
-        }
-        else
-        {
-            MiniDumpWriteDump(
-                GetCurrentProcess(),
-                GetCurrentProcessId(),
-                hFile,
-                MiniDumpNormal,
-                nullptr, // No exception information
-                nullptr,
-                nullptr
-            );
-        }
-
-        CloseHandle(hFile);
-
-        return EXCEPTION_EXECUTE_HANDLER;
-    }
+#include <DbgHelp.h>
+#include <Windows.h>
+#include <ctime>
+
+LONG WINAPI MyUnhandledExceptionFilter(EXCEPTION_POINTERS *ExceptionInfo) {
+  // Create a timestamped filename
+  time_t now = time(nullptr);
+  char filename[MAX_PATH];
+  strftime(filename, sizeof(filename),
+           "DFTFringeLogs\\crashdump_%Y%m%d_%H%M%S.dmp", localtime(&now));
+
+  HANDLE hFile = CreateFileA(filename, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS,
+                             FILE_ATTRIBUTE_NORMAL, nullptr);
+  if (hFile == INVALID_HANDLE_VALUE) {
+    return EXCEPTION_EXECUTE_HANDLER;
+  }
+
+  if (ExceptionInfo != nullptr) {
+    MINIDUMP_EXCEPTION_INFORMATION dumpInfo;
+    dumpInfo.ThreadId = GetCurrentThreadId();
+    dumpInfo.ExceptionPointers = ExceptionInfo;
+    dumpInfo.ClientPointers = FALSE;
+
+    MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile,
+                      MiniDumpNormal, &dumpInfo, nullptr, nullptr);
+  } else {
+    MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile,
+                      MiniDumpNormal,
+                      nullptr, // No exception information
+                      nullptr, nullptr);
+  }
+
+  CloseHandle(hFile);
+
+  return EXCEPTION_EXECUTE_HANDLER;
+}
@@ -83,2 +69,4 @@ static void my_terminate_handler() {
-    try {
-        spdlog::get("logger")->critical("Unexpected issue. Stacktrace:\n" + boost::stacktrace::to_string((boost::stacktrace::stacktrace())));
+  try {
+    spdlog::get("logger")->critical(
+        "Unexpected issue. Stacktrace:\n" +
+        boost::stacktrace::to_string((boost::stacktrace::stacktrace())));
@@ -86 +74,2 @@ static void my_terminate_handler() {
-umpInfo.ClientPointers = FALSE;
+
+    MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile,+    MyUnhandledExceptionFilter(
+        nullptr); // Call the unhandled exception filter to create a crash dump
@@ -88,2 +77,3 @@ static void my_terminate_handler() {
-                 Mini-DumpNormal, &dumpI+  } catch (...) {
+  }
+  std::abort();
@@ -92,20 +82,21 @@ static void my_terminate_handler() {
-, nullptr, nullptr);
+  } else {
+    MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile-,
-+                      MiniDumpNormal,
+            - -         nullptr, //- No exception informa-tion
+                      nullptr, nullptr);
+  }
+
+  CloseHandle(hFile-);
+
+  return -EXCEPTION_EXECUTE_HA-NDLER;
+}
@@ -83,2 +69,4 @@ static void my_terminate_handler() {
-    try- {
-        spd-log::get("logger")->cri-tical("Unexpected issue. Stacktrace:\n" + boost::stacktrace::to_string((b-oost::stacktrac-e::stacktrace())));
+  t-ry {
+    spdlog::get-("logger")->critical(
+        "Unexpected issue. Stacktrace:\n" +
+        b-oost::stacktrace::to_string((boo-st::stacktrace:-:stack+static void myQtMessageOutput(QtMsgType type,
+                              const QMessageLogContext & /*context*/,
+                              const QString &msg) {
+  const std::string localMsg = msg.toStdString();
+
+  switch (type) {
+  case QtDebugMsg:
+    spdlog::get("logger")->debug("QT message handler: {}", localMsg);
+    break;
+  case QtInfoMsg:
+    spdlog::get("logger")->info("QT message handler: {}", localMsg);
+    break;
+  case QtWarningMsg:
+    spdlog::get("logger")->warn("QT message handler: {}", localMsg);
+    break;
+  case QtCriticalMsg:
+  case QtFatalMsg:
+    spdlog::get("logger")->critical("QT message handler: {}", localMsg);
+    my_terminate_handler();
+    break;
+  }
@@ -114,5 +105,5 @@ static void myQtMessageOutput(QtMsgType type, const QMessageLogContext &/*contex
-ce())));
@@ -86 +74,2 @@ static void my_terminate_handler() {
-umpInfo.Cl-ientPointers = FALSE;
+
+    MiniDumpWriteDump(GetCurren-tProcess(), GetCurrentProcessId(), hFile,+ -  - MyUnhandledExceptionFilter(
+        nullptr); // Call the unhandled exception filter to create+static int myCvErrorCallback(int /*status*/, const char * /*func_name*/,
+                             const char *err_msg, const char *file_name,
+                             int line, void * /*userdata*/) {
+  spdlog::get("logger")->critical("CV error :{} in {} on line {}", err_msg,
+                                  file_name, line);
@@ -120,2 +111,2 @@ static int myCvErrorCallback( int /*status*/, const char* /*func_name*/,
-a crash dump
@@ -88,2 +77,3 -@@ static void my_terminate_handler() {
-  +  my_terminate_handler();
+  return 0; // Return value is not used
@@ -124,12 +115,12 @@ static int myCvErrorCallback( int /*status*/, const char* /*func_name*/,
-            Mini-DumpNormal, &dum-pI-+  } catch (...) {
+  }
+  std::abort();
@@ -92,20- +82,21 @@ static void my_terminate_handler() {
-, nullptr, nullptr);
+  } else {
+    MiniDumpWriteDump(GetC-urrentProcess(), GetCurrentProcessId(), hFile-,
-+            - -         MiniDumpNormal,
+            - -         nullptr, //- No- exception informa-tion
-+                      nullptr,- nullptr);
+  }
+
+  Cl-oseHandle(hFile-);
+
+  ret-urn -EXCEPTION_EXECUTE_HA-NDLER;
+int main(int argc, char *argv[]) {
+  // DFTFringe doesn't have a good darkmode palette
+  // one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark
+  // mode (except for app borders) Following code adds the platform argument
+  // programmatically
+
+  // Create a new argv array with existing args plus platform args
+  int newArgc = argc + 2;
+  std::vector<std::string> args;
+  args.reserve(newArgc);
+  // Copy existing arguments
+  for (int i = 0; i < argc; ++i) {
@@ -137,8 +128,8 @@ for (int i = 0; i < argc; ++i) {
- m-y_terminate_handler()- {
-    try- {
-        spd-log:-:get("logger")->cri-tical("Unexpected iss-ue. Stacktrace:\n" + boost::sta-cktrace::to_string((b-oost::-stacktrac-e::stacktrace())-));
+  t-ry {
+    spdlog+  }
+  // Add new arguments
+  args.emplace_back("-platform");
+  args.emplace_back("windows:darkmode=1");
+  // Build non-const char* array
+  std::vector<char *> newArgv;
+  newArgv.reserve(newArgc);
+  for (auto &arg : args) {
@@ -146 +137 @@ for (auto &arg : args) {
-+
+  }
@@ -148,2 +139,2 @@ for (auto &arg : args) {
-        b-oost::stacktrace::t-o_string((boo-st::stacktrace:-:stack+static void myQtMes+  // Allow secondary instances
+  SingleApplication app(newArgc, newArgv.data(), true);
@@ -151 +142 @@ SingleApplication app( newArgc, newArgv.data(), true );
-ageOutput(QtMsgType type,
+  +  MessageReceiver msgReceiver;
@@ -153,12 +144,8 @@ MessageReceiver msgReceiver;
-                           const QMessa-geLogContext & /*context*/,
+ -                             const QString &msg) {
+  const std:-:string localMsg =- msg.toStdStr-ing();
+
+  switch (type) -{
+  case QtDebugM-sg:
+    spdlog::get("logger")->debug("QT message- handler: {}", localMsg);
-+    break;
+  case QtInfoMsg:
+    spdlog::ge-t("logger")-->info+  // If this is a secondary instance
+  if (app.isSecondary()) {
+    app.sendMessage(app.arguments().join('\'').toUtf8());
+    return 0;
+  } else {
+    QObject::connect(&app, &SingleApplication::receivedMessage, &msgReceiver,
+                     &MessageReceiver::receivedMessage);
+  }
@@ -166,2 +153,2 @@ MessageReceiver msgReceiver;
-"QT message handler: {}", localMsg);
+    -break;
+  case QtWarningMsg:
+    spdlog:+  app.setOrganizationName("DFTFringe");
+  app.setApplicationName("DFTFringe");
@@ -169,2 +156,3 @@ MessageReceiver msgReceiver;
-get("logger")->warn("QT message handler: {}", localMsg);
+    break;
+  case QtCr-iticalMsg:
+  case QtFatalMsg:
+    spdlog::get("logger")->critical("QT message handler: {}", localMsg);
+    my_termi+  auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
+  auto file_sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(
+      "DFTFringeLogs/log.txt", 1048576 * 5, 3);
@@ -172 +160,2 @@ MessageReceiver msgReceiver;
-ate_handler();
+    break;
+  }
@@ -114,5 +105,5 @@ static void myQtMessageOutput(QtMsgType type, const QMessageLogContext +  auto combined_logger = std::make_shared<spdlog::logger>(
+      "logger", spdlog::sinks_init_list({console_sink, file_sink}));
@@ -174,2 +163,3 @@ MessageReceiver msgReceiver;
-/*contex
-ce())));
@@ -86 +74,2 @@ static void my_terminate_handler() {
-umpInfo.Cl-i-entPointers = FALSE;
+
+    MiniDumpWriteDump(+  // Combined logger needs to be manually registered or it won't be found by
+  // "get"
+  spdlog::register_logger(combined_logger);
@@ -177,3 +167,3 @@ MessageReceiver msgReceiver;
-etCurren-tProcess(), GetCurrentProcessId(), hFile,+ -  - MyUnhandled-ExceptionFilter(
+        nullptr); // Call the unhandled exception filter to- create+static int myCvErrorCallback(int /*status*+  // periodically flush all *registered* loggers every 3 seconds:
+  // warning: only use if all your loggers are thread-safe ("_mt" loggers)
+  spdlog::flush_every(std::chrono::seconds(3));
@@ -182,2 +172,2 @@ MessageReceiver msgReceiver;
-me*/,
+                       -      const char *err_msg, const char *file_name,
+                           +  // Set the logging format
+  spdlog::get("logger")->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] %v");
@@ -186,15 +176,18 @@ MessageReceiver msgReceiver;
-ne, void * /*userdata*/)- {
+  spdlog::get("logger")->critical("CV error :{} in {} on l-i-ne {}", err_msg,
+        -                          file_name, line);
@@ -120,2 +111,2 @-@ static int myCvErrorCallback( int /*status*/, const char* /*func_name*/,
-a crash dump
@@ -88,2 +77,3 -@@ static void my_termin-ate_handler() {
-  +  my_terminate_handler();
+  r-eturn 0; // Return value is not used
@@ -124,12 +1-15,12 @@ static int myCvErrorCallback( int /*sta-tus*/, const char* /*func_name*/,
-            M-ini-DumpNormal, &dum-pI-+  } catch (...) {
+  }
+ - std::abort();
@@ -92,20- +82,21 @@ static void my_termi-n-ate_handler() {
-, nullptr, nullptr);
+  } else {
+    MiniDumpWriteDump(GetC-urrentProcess(), GetCurrentProcessId(), h-File-,
-+            - -         MiniDumpNormal+  // Set logger level
+  settingsDebug::setLogLevel(settingsDebug::getLogLevel());
+
+  // those are examples
+  spdlog::get("logger")->info("\r\n\r\n\r\n-------------");
+  spdlog::get("logger")->trace("Welcome to spdlog version {}.{}.{}  !",
+                               SPDLOG_VER_MAJOR, SPDLOG_VER_MINOR,
+                               SPDLOG_VER_PATCH);
+  spdlog::get("logger")->trace("spdlog trace");
+  spdlog::get("logger")->debug("spdlog debug");
+  spdlog::get("logger")->info("spdlog info");
+  spdlog::get("logger")->warn("spdlog warn");
+  spdlog::get("logger")->error("spdlog error");
+  spdlog::get("logger")->critical("spdlog critical");
+
+  // from here, any problematic application exit (for example uncatched
+  // exceptions) should call my_terminate_handler
+  std::set_terminate(&my_terminate_handler);
@@ -202,2 +195,3 @@ MessageReceiver msgReceiver;
- - -         nullptr, //- No- exception informa-tion
-+                      nullptr,- nul-lptr);
+  }
+
+  Cl-oseHandle(hFile-);
+
+  ret-urn -EXCEPTIO+  // in case of specific Windows exceptions, we want to catch them and write a
+  // minidump
+  SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
@@ -207,5 +201,10 @@ MessageReceiver msgReceiver;
-t argc, char *argv[]) {
+  // DFTFringe doesn't have a good darkmode palette
+  // one could call "DFTFr-inge.exe -platform windows:darkmode=1" to disable dark
+  // mode (except for app borders) Following code adds the platform ar-gument
+  // programmatically
+
+  // Create a new argv array with existing args p-l-us platform args
+  int newArgc = argc + 2;
+  std::vector<std::string> args;
+  args.reserve(newArgc);
+  // Copy existi+  // override QT message handler because qFatal() and qCritical() would exit
+  // cleanly without crashlog
+  qInstallMessageHandler(
+      myQtMessageOutput); // replace with nullptr if you want to use original
+                          // bahavior for debug purpose
+  // override CV error handler to get crashlog to execute instead of clean exit
+
+  cv::redirectError(
+      myCvErrorCallback); // replace with nullptr if you want to use original
+                          // bahavior for debug purpose
@@ -213 +212,3 @@ MessageReceiver msgReceiver;
-ments
+  for (int i = 0; i < argc; ++i) {
@@ -137,8 +128,8 @@ for (int i = 0; i < argc; ++i) {
- m-y_terminate_handler()- {
-    try- {+  spdlog::get("logger")->critical(
+      "This is a demo stacktrace:\n" +
+      boost::stacktrace::to_string((boost::stacktrace::stacktrace())));
@@ -215,2 +216,2 @@ MessageReceiver msgReceiver;
--        spd-log:-:get("logger")->cr-i-tical("Unexpected iss-ue. Stackt+  MainWindow *w = new MainWindow;
+  msgReceiver.m_mainWindow = w;
@@ -219 +220 @@ MessageReceiver msgReceiver;
--cktrace::to_stri+  // showmem();
@@ -221,3 +222,3 @@ MessageReceiver msgReceiver;
-ost::-stacktrac--e::stacktrace())-));
-+  t-ry {
+    spdlog+ +  w->show();
+  // fclose(logptr);
+  return app.exec();

Have any feedback or feature suggestions? Share it here.

Comment thread main.cpp Outdated
Comment on lines +124 to +135
int main(int argc, char *argv[])
{
// DFTFringe doesn't have a good darkmode palette
// one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark mode (except for app borders)
// Following code adds the platform argument programmatically
char *platformArg = "-platform";
char *platformValue = "windows:darkmode=1";
// Create a new argv array with existing args plus platform args
int newArgc = argc + 2;
char *newArgv[newArgc];
for(size_t i = 0; i < argc; i++) {
newArgv[i] = argv[i];
}
newArgv[argc] = platformArg;
newArgv[argc + 1] = platformValue;
// DFTFringe doesn't have a good darkmode palette
// one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark mode (except for app borders)
// Following code adds the platform argument programmatically

// Create a new argv array with existing args plus platform args
int newArgc = argc + 2;
std::vector<std::string> args;
args.reserve(newArgc);
// Copy existing arguments
for (int i = 0; i < argc; ++i) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format suggestion

Suggested change
int main(int argc, char *argv[])
{
// DFTFringe doesn't have a good darkmode palette
// one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark mode (except for app borders)
// Following code adds the platform argument programmatically
char *platformArg = "-platform";
char *platformValue = "windows:darkmode=1";
// Create a new argv array with existing args plus platform args
int newArgc = argc + 2;
char *newArgv[newArgc];
for(size_t i = 0; i < argc; i++) {
newArgv[i] = argv[i];
}
newArgv[argc] = platformArg;
newArgv[argc + 1] = platformValue;
// DFTFringe doesn't have a good darkmode palette
// one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark mode (except for app borders)
// Following code adds the platform argument programmatically
// Create a new argv array with existing args plus platform args
int newArgc = argc + 2;
std::vector<std::string> args;
args.reserve(newArgc);
// Copy existing arguments
for (int i = 0; i < argc; ++i) {
int main(int argc, char *argv[]) {
// DFTFringe doesn't have a good darkmode palette
// one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark
// mode (except for app borders) Following code adds the platform argument
// programmatically
// Create a new argv array with existing args plus platform args
int newArgc = argc + 2;
std::vector<std::string> args;
args.reserve(newArgc);
// Copy existing arguments
for (int i = 0; i < argc; ++i) {

clang-tidy diagnostics

Suggested change
int main(int argc, char *argv[])
{
// DFTFringe doesn't have a good darkmode palette
// one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark mode (except for app borders)
// Following code adds the platform argument programmatically
char *platformArg = "-platform";
char *platformValue = "windows:darkmode=1";
// Create a new argv array with existing args plus platform args
int newArgc = argc + 2;
char *newArgv[newArgc];
for(size_t i = 0; i < argc; i++) {
newArgv[i] = argv[i];
}
newArgv[argc] = platformArg;
newArgv[argc + 1] = platformValue;
// DFTFringe doesn't have a good darkmode palette
// one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark mode (except for app borders)
// Following code adds the platform argument programmatically
// Create a new argv array with existing args plus platform args
int newArgc = argc + 2;
std::vector<std::string> args;
args.reserve(newArgc);
// Copy existing arguments
for (int i = 0; i < argc; ++i) {
auto main(int argc, char *argv[]) -> int {
// DFTFringe doesn't have a good darkmode palette
// one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark
// mode (except for app borders) Following code adds the platform argument
// programmatically
// Create a new argv array with existing args plus platform args
int newArgc = argc + 2;
std::vector<std::string> args;
args.reserve(newArgc);
// Copy existing arguments
for (int i = 0; i < argc; ++i) {

clang-tidy diagnostic

main.cpp:124:5: warning: [bugprone-exception-escape]

an exception may be thrown in function 'main' which should not throw exceptions

  124 | int main(int argc, char *argv[])
      |     ^

Comment thread main.cpp Outdated
Comment on lines +137 to +144
}
// Add new arguments
args.emplace_back("-platform");
args.emplace_back("windows:darkmode=1");
// Build non-const char* array
std::vector<char*> newArgv;
newArgv.reserve(newArgc);
for (auto &arg : args) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format suggestion

Suggested change
}
// Add new arguments
args.emplace_back("-platform");
args.emplace_back("windows:darkmode=1");
// Build non-const char* array
std::vector<char*> newArgv;
newArgv.reserve(newArgc);
for (auto &arg : args) {
}
// Add new arguments
args.emplace_back("-platform");
args.emplace_back("windows:darkmode=1");
// Build non-const char* array
std::vector<char *> newArgv;
newArgv.reserve(newArgc);
for (auto &arg : args) {

Comment thread main.cpp Outdated
newArgv.reserve(newArgc);
for (auto &arg : args) {
newArgv.push_back(&arg[0]); // C++11 guarantees contiguous storage
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format suggestion

Suggested change
}
}

Comment thread main.cpp Outdated
Comment on lines +148 to +149
// Allow secondary instances
SingleApplication app( newArgc, newArgv.data(), true );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format suggestion

Suggested change
// Allow secondary instances
SingleApplication app( newArgc, newArgv.data(), true );
// Allow secondary instances
SingleApplication app(newArgc, newArgv.data(), true);

Comment thread main.cpp Outdated
SingleApplication app( newArgc, newArgv.data(), true );

MessageReceiver msgReceiver;
MessageReceiver msgReceiver;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format suggestion

Suggested change
MessageReceiver msgReceiver;
MessageReceiver msgReceiver;

Comment thread main.cpp Outdated
std::vector<char*> newArgv;
newArgv.reserve(newArgc);
for (auto &arg : args) {
newArgv.push_back(&arg[0]); // C++11 guarantees contiguous storage

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostics

Suggested change
newArgv.push_back(&arg[0]); // C++11 guarantees contiguous storage
newArgv.push_back(arg.data()); // C++11 guarantees contiguous storage

Comment thread main.cpp Outdated
args.reserve(newArgc);
// Copy existing arguments
for (int i = 0; i < argc; ++i) {
args.emplace_back(argv[i]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

main.cpp:136:23: warning: [cppcoreguidelines-pro-bounds-pointer-arithmetic]

do not use pointer arithmetic

  136 |     args.emplace_back(argv[i]);
      |                       ^

@github-actions

Copy link
Copy Markdown

🚀 New build available for commit e33d287
Download installer here

Comment thread main.cpp
@gr5

gr5 commented Nov 22, 2025

Copy link
Copy Markdown
Collaborator

When you say this only affects "new code" I think you mean it affects any file that was modified. So if I add a single comment, I will see clang notifications throughout the file, correct? Or only on lines of code that were changed?

I have to admit that it's pretty cool that clang sometimes suggests fixes and I can just click "commit suggestion" if I like the suggestion.

@atsju

atsju commented Nov 22, 2025

Copy link
Copy Markdown
Collaborator Author

When you say this only affects "new code" I think you mean it affects any file that was modified. So if I add a single comment, I will see clang notifications throughout the file, correct? Or only on lines of code that were changed?

I have to admit that it's pretty cool that clang sometimes suggests fixes and I can just click "commit suggestion" if I like the suggestion.

It's fully configurable and I can get comments to only show on diff lines
We have currently 9000+ warnings. But this is not a thing to work on, just a metric

@atsju atsju marked this pull request as draft November 23, 2025 18:01
@atsju

atsju commented Nov 23, 2025

Copy link
Copy Markdown
Collaborator Author

that's not ready.

@atsju atsju closed this Dec 6, 2025
@github-actions

github-actions Bot commented Dec 6, 2025

Copy link
Copy Markdown

🚀 New build available for commit aaa92bf
Download installer here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants