From dbe80d0f92367bc5e1d290f11a407f1f04a29b46 Mon Sep 17 00:00:00 2001
From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com>
Date: Thu, 7 Aug 2025 23:17:13 -0400
Subject: [PATCH] style(sonar): fix cpp:S6185 (#4133)
---
.github/workflows/ci-homebrew.yml | 2 --
.github/workflows/ci.yml | 2 --
README.md | 6 +++---
packaging/sunshine.rb | 14 ++++++++++++++
src/confighttp.cpp | 5 +++--
src/entry_handler.cpp | 13 ++++++-------
src/entry_handler.h | 12 +++---------
src/nvenc/nvenc_base.cpp | 7 +++++--
src/nvhttp.cpp | 23 ++++++++++++++++++++---
src/platform/linux/vaapi.cpp | 3 ++-
src/platform/windows/audio.cpp | 8 +++++---
src/rtsp.cpp | 3 ++-
src/system_tray.cpp | 2 +-
tests/unit/test_display_device.cpp | 3 ++-
tests/unit/test_file_handler.cpp | 5 +++--
tests/unit/test_logging.cpp | 3 ++-
tools/sunshinesvc.cpp | 3 ++-
17 files changed, 73 insertions(+), 41 deletions(-)
diff --git a/.github/workflows/ci-homebrew.yml b/.github/workflows/ci-homebrew.yml
index 1b8eb724..dfb232be 100644
--- a/.github/workflows/ci-homebrew.yml
+++ b/.github/workflows/ci-homebrew.yml
@@ -36,8 +36,6 @@ jobs:
include:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
# while GitHub has larger macOS runners, they are not available for our repos :(
- - os_version: "13"
- os_name: "macos"
- os_version: "14"
os_name: "macos"
- os_version: "15"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 02ef92cc..e4266bfe 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -137,8 +137,6 @@ jobs:
include:
- name: Linux-AppImage
coverage: true
- - name: Homebrew-macos-13
- coverage: false
- name: Homebrew-macos-14
coverage: false
- name: Homebrew-macos-15
diff --git a/README.md b/README.md
index 80733b20..63cc9a2d 100644
--- a/README.md
+++ b/README.md
@@ -72,13 +72,13 @@ LizardByte has the full documentation hosted on [Read the Docs](https://docs.liz
Windows: 10+ (Windows Server does not support virtual gamepads) |
- | macOS: 13+ |
+ macOS: 14+ |
- | Linux/Debian: 12+ (bookworm) |
+ Linux/Debian: 13+ (trixie) |
- | Linux/Fedora: 40+ |
+ Linux/Fedora: 41+ |
| Linux/Ubuntu: 22.04+ (jammy) |
diff --git a/packaging/sunshine.rb b/packaging/sunshine.rb
index 97eb9fe5..33eab1e7 100644
--- a/packaging/sunshine.rb
+++ b/packaging/sunshine.rb
@@ -37,6 +37,10 @@ class @PROJECT_NAME@ < Formula
depends_on "opus"
depends_on "icu4c" => :recommended
+ on_macos do
+ depends_on xcode: ["15.3", :build]
+ end
+
on_linux do
depends_on "avahi"
depends_on "libayatana-appindicator"
@@ -59,6 +63,16 @@ class @PROJECT_NAME@ < Formula
depends_on "wayland"
end
+ fails_with :clang do
+ build 1400
+ cause "Requires C++23 support"
+ end
+
+ fails_with :gcc do
+ version "12" # fails with GCC 12.x and earlier
+ cause "Requires C++23 support"
+ end
+
def install
ENV["BRANCH"] = "@GITHUB_BRANCH@"
ENV["BUILD_VERSION"] = "@BUILD_VERSION@"
diff --git a/src/confighttp.cpp b/src/confighttp.cpp
index b50e94d9..5fad47bb 100644
--- a/src/confighttp.cpp
+++ b/src/confighttp.cpp
@@ -8,6 +8,7 @@
// standard includes
#include
+#include
#include
#include
@@ -713,7 +714,7 @@ namespace confighttp {
if (const int max_index = static_cast(apps_node.size()) - 1; max_index < 0) {
error = "No applications to delete";
} else {
- error = "'index' out of range, max index is "s + std::to_string(max_index);
+ error = std::format("'index' {} out of range, max index is {}", index, max_index);
}
bad_request(response, request, error);
return;
@@ -730,7 +731,7 @@ namespace confighttp {
proc::refresh(config::stream.file_apps);
output_tree["status"] = true;
- output_tree["result"] = "application " + std::to_string(index) + " deleted";
+ output_tree["result"] = std::format("application {} deleted", index);
send_response(response, output_tree);
} catch (std::exception &e) {
BOOST_LOG(warning) << "DeleteApp: "sv << e.what();
diff --git a/src/entry_handler.cpp b/src/entry_handler.cpp
index 9ac07649..3986be5c 100644
--- a/src/entry_handler.cpp
+++ b/src/entry_handler.cpp
@@ -4,6 +4,7 @@
*/
// standard includes
#include
+#include
#include
#include
@@ -25,13 +26,11 @@ extern "C" {
using namespace std::literals;
-void launch_ui() {
- std::string url = "https://localhost:" + std::to_string(net::map_port(confighttp::PORT_HTTPS));
- platf::open_url(url);
-}
-
-void launch_ui_with_path(std::string path) {
- std::string url = "https://localhost:" + std::to_string(net::map_port(confighttp::PORT_HTTPS)) + path;
+void launch_ui(const std::optional &path) {
+ std::string url = std::format("https://localhost:{}", static_cast(net::map_port(confighttp::PORT_HTTPS)));
+ if (path) {
+ url += *path;
+ }
platf::open_url(url);
}
diff --git a/src/entry_handler.h b/src/entry_handler.h
index a83fed29..8d5a03e7 100644
--- a/src/entry_handler.h
+++ b/src/entry_handler.h
@@ -14,19 +14,13 @@
/**
* @brief Launch the Web UI.
+ * @param path Optional path to append to the base URL.
* @examples
* launch_ui();
+ * launch_ui("/pin");
* @examples_end
*/
-void launch_ui();
-
-/**
- * @brief Launch the Web UI at a specific endpoint.
- * @examples
- * launch_ui_with_path("/pin");
- * @examples_end
- */
-void launch_ui_with_path(std::string path);
+void launch_ui(const std::optional &path = std::nullopt);
/**
* @brief Functions for handling command line arguments.
diff --git a/src/nvenc/nvenc_base.cpp b/src/nvenc/nvenc_base.cpp
index bcd12ca1..431b7de2 100644
--- a/src/nvenc/nvenc_base.cpp
+++ b/src/nvenc/nvenc_base.cpp
@@ -5,6 +5,9 @@
// this include
#include "nvenc_base.h"
+// standard includes
+#include
+
// local includes
#include "src/config.h"
#include "src/logging.h"
@@ -427,7 +430,7 @@ namespace nvenc {
extra += " two-pass";
}
if (config.vbv_percentage_increase > 0 && get_encoder_cap(NV_ENC_CAPS_SUPPORT_CUSTOM_VBV_BUF_SIZE)) {
- extra += " vbv+" + std::to_string(config.vbv_percentage_increase);
+ extra += std::format(" vbv+{}", config.vbv_percentage_increase);
}
if (encoder_params.rfi) {
extra += " rfi";
@@ -439,7 +442,7 @@ namespace nvenc {
extra += " spatial-aq";
}
if (enc_config.rcParams.enableMinQP) {
- extra += " qpmin=" + std::to_string(enc_config.rcParams.minQP.qpInterP);
+ extra += std::format(" qpmin={}", enc_config.rcParams.minQP.qpInterP);
}
if (config.insert_filler_data) {
extra += " filler-data";
diff --git a/src/nvhttp.cpp b/src/nvhttp.cpp
index 6b518bf9..3511ad32 100644
--- a/src/nvhttp.cpp
+++ b/src/nvhttp.cpp
@@ -7,6 +7,7 @@
// standard includes
#include
+#include
#include
#include
@@ -636,7 +637,7 @@ namespace nvhttp {
tree.put("root..status_code", 400);
tree.put(
"root..status_message",
- "Pin must be 4 digits, " + std::to_string(pin.size()) + " provided"
+ std::format("Pin must be 4 digits, {} provided", pin.size())
);
return false;
}
@@ -896,7 +897,15 @@ namespace nvhttp {
}
tree.put("root..status_code", 200);
- tree.put("root.sessionUrl0", launch_session->rtsp_url_scheme + net::addr_to_url_escaped_string(request->local_endpoint().address()) + ':' + std::to_string(net::map_port(rtsp_stream::RTSP_SETUP_PORT)));
+ tree.put(
+ "root.sessionUrl0",
+ std::format(
+ "{}{}:{}",
+ launch_session->rtsp_url_scheme,
+ net::addr_to_url_escaped_string(request->local_endpoint().address()),
+ static_cast(net::map_port(rtsp_stream::RTSP_SETUP_PORT))
+ )
+ );
tree.put("root.gamesession", 1);
rtsp_stream::launch_session_raise(launch_session);
@@ -978,7 +987,15 @@ namespace nvhttp {
}
tree.put("root..status_code", 200);
- tree.put("root.sessionUrl0", launch_session->rtsp_url_scheme + net::addr_to_url_escaped_string(request->local_endpoint().address()) + ':' + std::to_string(net::map_port(rtsp_stream::RTSP_SETUP_PORT)));
+ tree.put(
+ "root.sessionUrl0",
+ std::format(
+ "{}{}:{}",
+ launch_session->rtsp_url_scheme,
+ net::addr_to_url_escaped_string(request->local_endpoint().address()),
+ static_cast(net::map_port(rtsp_stream::RTSP_SETUP_PORT))
+ )
+ );
tree.put("root.resume", 1);
rtsp_stream::launch_session_raise(launch_session);
diff --git a/src/platform/linux/vaapi.cpp b/src/platform/linux/vaapi.cpp
index 88444d10..1a38c4ec 100644
--- a/src/platform/linux/vaapi.cpp
+++ b/src/platform/linux/vaapi.cpp
@@ -4,6 +4,7 @@
*/
// standard includes
#include
+#include
#include
#include
@@ -574,7 +575,7 @@ namespace va {
if (!display) {
char string[1024];
- auto bytes = readlink(("/proc/self/fd/" + std::to_string(fd)).c_str(), string, sizeof(string));
+ auto bytes = readlink(std::format("/proc/self/fd/{}", fd).c_str(), string, sizeof(string));
std::string_view render_device {string, (std::size_t) bytes};
diff --git a/src/platform/windows/audio.cpp b/src/platform/windows/audio.cpp
index 94863409..48738cb3 100644
--- a/src/platform/windows/audio.cpp
+++ b/src/platform/windows/audio.cpp
@@ -4,6 +4,9 @@
*/
#define INITGUID
+// standard includes
+#include
+
// platform includes
#include
#include
@@ -168,8 +171,7 @@ namespace {
waveformat.SubFormat == KSDATAFORMAT_SUBTYPE_PCM ? "S" :
"UNKNOWN";
- result += std::to_string(waveformat.Samples.wValidBitsPerSample) + " " +
- std::to_string(waveformat.Format.nSamplesPerSec) + " ";
+ result += std::format("{} {} ", static_cast(waveformat.Samples.wValidBitsPerSample), static_cast(waveformat.Format.nSamplesPerSec));
switch (waveformat.dwChannelMask) {
case waveformat_mask_stereo:
@@ -189,7 +191,7 @@ namespace {
break;
default:
- result += std::to_string(waveformat.Format.nChannels) + " channels (unrecognized)";
+ result += std::format("{} channels (unrecognized)", static_cast(waveformat.Format.nChannels));
break;
}
diff --git a/src/rtsp.cpp b/src/rtsp.cpp
index cd43dd0c..25647e2e 100644
--- a/src/rtsp.cpp
+++ b/src/rtsp.cpp
@@ -12,6 +12,7 @@ extern "C" {
// standard includes
#include
#include
+#include
#include
#include
#include
@@ -864,7 +865,7 @@ namespace rtsp_stream {
session_option.next = &port_option;
// Moonlight merely requires 'server_port='
- auto port_value = "server_port=" + std::to_string(port);
+ auto port_value = std::format("server_port={}", static_cast(port));
port_option.option = const_cast("Transport");
port_option.content = port_value.data();
diff --git a/src/system_tray.cpp b/src/system_tray.cpp
index f792c741..255904b0 100644
--- a/src/system_tray.cpp
+++ b/src/system_tray.cpp
@@ -305,7 +305,7 @@ namespace system_tray {
tray.notification_icon = TRAY_ICON_LOCKED;
tray.tooltip = PROJECT_NAME;
tray.notification_cb = []() {
- launch_ui_with_path("/pin");
+ launch_ui("/pin");
};
tray_update(&tray);
}
diff --git a/tests/unit/test_display_device.cpp b/tests/unit/test_display_device.cpp
index 92133c3c..cf7992fa 100644
--- a/tests/unit/test_display_device.cpp
+++ b/tests/unit/test_display_device.cpp
@@ -4,6 +4,7 @@
*/
#include "../tests_common.h"
+#include
#include
#include
#include
@@ -473,7 +474,7 @@ namespace {
} else {
const auto [manual_res] = std::get>(input_res);
video_config.dd.resolution_option = manual;
- video_config.dd.manual_resolution = std::to_string(manual_res.m_width) + "x"s + std::to_string(manual_res.m_height);
+ video_config.dd.manual_resolution = std::format("{}x{}", static_cast(manual_res.m_width), static_cast(manual_res.m_height));
}
}
diff --git a/tests/unit/test_file_handler.cpp b/tests/unit/test_file_handler.cpp
index 99872cc6..cf5b8a1f 100644
--- a/tests/unit/test_file_handler.cpp
+++ b/tests/unit/test_file_handler.cpp
@@ -4,6 +4,7 @@
*/
#include "../tests_common.h"
+#include
#include
struct FileHandlerParentDirectoryTest: testing::TestWithParam> {};
@@ -79,13 +80,13 @@ Hey, hey, hey!
TEST_P(FileHandlerTests, WriteFileTest) {
auto [fileNum, content] = GetParam();
- std::string fileName = "write_file_test_" + std::to_string(fileNum) + ".txt";
+ const std::string fileName = std::format("write_file_test_{}.txt", fileNum);
EXPECT_EQ(file_handler::write_file(fileName.c_str(), content), 0);
}
TEST_P(FileHandlerTests, ReadFileTest) {
auto [fileNum, content] = GetParam();
- std::string fileName = "write_file_test_" + std::to_string(fileNum) + ".txt";
+ const std::string fileName = std::format("write_file_test_{}.txt", fileNum);
EXPECT_EQ(file_handler::read_file(fileName.c_str()), content);
}
diff --git a/tests/unit/test_logging.cpp b/tests/unit/test_logging.cpp
index 0b4c2273..cc638859 100644
--- a/tests/unit/test_logging.cpp
+++ b/tests/unit/test_logging.cpp
@@ -5,6 +5,7 @@
#include "../tests_common.h"
#include "../tests_log_checker.h"
+#include
#include
#include
@@ -39,7 +40,7 @@ TEST_P(LogLevelsTest, PutMessage) {
std::random_device rand_dev;
std::mt19937_64 rand_gen(rand_dev());
- auto test_message = std::to_string(rand_gen()) + std::to_string(rand_gen());
+ auto test_message = std::format("{}{}", rand_gen(), rand_gen());
BOOST_LOG(logger) << test_message;
ASSERT_TRUE(log_checker::line_contains(log_file, test_message));
diff --git a/tools/sunshinesvc.cpp b/tools/sunshinesvc.cpp
index 9ff124ed..bd9522b9 100644
--- a/tools/sunshinesvc.cpp
+++ b/tools/sunshinesvc.cpp
@@ -3,6 +3,7 @@
* @brief Handles launching Sunshine.exe into user sessions as SYSTEM
*/
#define WIN32_LEAN_AND_MEAN
+#include
#include
#include
#include
@@ -137,7 +138,7 @@ bool RunTerminationHelper(HANDLE console_token, DWORD pid) {
command += L'"';
command += module_path;
command += L'"';
- command += L" --terminate " + std::to_wstring(pid);
+ command += std::format(L" --terminate {}", pid);
STARTUPINFOW startup_info = {};
startup_info.cb = sizeof(startup_info);