style(sonar): fix cpp:S6185 (#4133)

This commit is contained in:
ReenigneArcher
2025-08-07 23:17:13 -04:00
committed by GitHub
parent a28c20df18
commit dbe80d0f92
17 changed files with 73 additions and 41 deletions

View File

@ -36,8 +36,6 @@ jobs:
include: 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 # 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 :( # while GitHub has larger macOS runners, they are not available for our repos :(
- os_version: "13"
os_name: "macos"
- os_version: "14" - os_version: "14"
os_name: "macos" os_name: "macos"
- os_version: "15" - os_version: "15"

View File

@ -137,8 +137,6 @@ jobs:
include: include:
- name: Linux-AppImage - name: Linux-AppImage
coverage: true coverage: true
- name: Homebrew-macos-13
coverage: false
- name: Homebrew-macos-14 - name: Homebrew-macos-14
coverage: false coverage: false
- name: Homebrew-macos-15 - name: Homebrew-macos-15

View File

@ -72,13 +72,13 @@ LizardByte has the full documentation hosted on [Read the Docs](https://docs.liz
<td>Windows: 10+ (Windows Server does not support virtual gamepads)</td> <td>Windows: 10+ (Windows Server does not support virtual gamepads)</td>
</tr> </tr>
<tr> <tr>
<td>macOS: 13+</td> <td>macOS: 14+</td>
</tr> </tr>
<tr> <tr>
<td>Linux/Debian: 12+ (bookworm)</td> <td>Linux/Debian: 13+ (trixie)</td>
</tr> </tr>
<tr> <tr>
<td>Linux/Fedora: 40+</td> <td>Linux/Fedora: 41+</td>
</tr> </tr>
<tr> <tr>
<td>Linux/Ubuntu: 22.04+ (jammy)</td> <td>Linux/Ubuntu: 22.04+ (jammy)</td>

View File

@ -37,6 +37,10 @@ class @PROJECT_NAME@ < Formula
depends_on "opus" depends_on "opus"
depends_on "icu4c" => :recommended depends_on "icu4c" => :recommended
on_macos do
depends_on xcode: ["15.3", :build]
end
on_linux do on_linux do
depends_on "avahi" depends_on "avahi"
depends_on "libayatana-appindicator" depends_on "libayatana-appindicator"
@ -59,6 +63,16 @@ class @PROJECT_NAME@ < Formula
depends_on "wayland" depends_on "wayland"
end 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 def install
ENV["BRANCH"] = "@GITHUB_BRANCH@" ENV["BRANCH"] = "@GITHUB_BRANCH@"
ENV["BUILD_VERSION"] = "@BUILD_VERSION@" ENV["BUILD_VERSION"] = "@BUILD_VERSION@"

View File

@ -8,6 +8,7 @@
// standard includes // standard includes
#include <filesystem> #include <filesystem>
#include <format>
#include <fstream> #include <fstream>
#include <set> #include <set>
@ -713,7 +714,7 @@ namespace confighttp {
if (const int max_index = static_cast<int>(apps_node.size()) - 1; max_index < 0) { if (const int max_index = static_cast<int>(apps_node.size()) - 1; max_index < 0) {
error = "No applications to delete"; error = "No applications to delete";
} else { } 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); bad_request(response, request, error);
return; return;
@ -730,7 +731,7 @@ namespace confighttp {
proc::refresh(config::stream.file_apps); proc::refresh(config::stream.file_apps);
output_tree["status"] = true; 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); send_response(response, output_tree);
} catch (std::exception &e) { } catch (std::exception &e) {
BOOST_LOG(warning) << "DeleteApp: "sv << e.what(); BOOST_LOG(warning) << "DeleteApp: "sv << e.what();

View File

@ -4,6 +4,7 @@
*/ */
// standard includes // standard includes
#include <csignal> #include <csignal>
#include <format>
#include <iostream> #include <iostream>
#include <thread> #include <thread>
@ -25,13 +26,11 @@ extern "C" {
using namespace std::literals; using namespace std::literals;
void launch_ui() { void launch_ui(const std::optional<std::string> &path) {
std::string url = "https://localhost:" + std::to_string(net::map_port(confighttp::PORT_HTTPS)); std::string url = std::format("https://localhost:{}", static_cast<int>(net::map_port(confighttp::PORT_HTTPS)));
platf::open_url(url); if (path) {
} url += *path;
}
void launch_ui_with_path(std::string path) {
std::string url = "https://localhost:" + std::to_string(net::map_port(confighttp::PORT_HTTPS)) + path;
platf::open_url(url); platf::open_url(url);
} }

View File

@ -14,19 +14,13 @@
/** /**
* @brief Launch the Web UI. * @brief Launch the Web UI.
* @param path Optional path to append to the base URL.
* @examples * @examples
* launch_ui(); * launch_ui();
* launch_ui("/pin");
* @examples_end * @examples_end
*/ */
void launch_ui(); void launch_ui(const std::optional<std::string> &path = std::nullopt);
/**
* @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);
/** /**
* @brief Functions for handling command line arguments. * @brief Functions for handling command line arguments.

View File

@ -5,6 +5,9 @@
// this include // this include
#include "nvenc_base.h" #include "nvenc_base.h"
// standard includes
#include <format>
// local includes // local includes
#include "src/config.h" #include "src/config.h"
#include "src/logging.h" #include "src/logging.h"
@ -427,7 +430,7 @@ namespace nvenc {
extra += " two-pass"; extra += " two-pass";
} }
if (config.vbv_percentage_increase > 0 && get_encoder_cap(NV_ENC_CAPS_SUPPORT_CUSTOM_VBV_BUF_SIZE)) { 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) { if (encoder_params.rfi) {
extra += " rfi"; extra += " rfi";
@ -439,7 +442,7 @@ namespace nvenc {
extra += " spatial-aq"; extra += " spatial-aq";
} }
if (enc_config.rcParams.enableMinQP) { 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) { if (config.insert_filler_data) {
extra += " filler-data"; extra += " filler-data";

View File

@ -7,6 +7,7 @@
// standard includes // standard includes
#include <filesystem> #include <filesystem>
#include <format>
#include <string> #include <string>
#include <utility> #include <utility>
@ -636,7 +637,7 @@ namespace nvhttp {
tree.put("root.<xmlattr>.status_code", 400); tree.put("root.<xmlattr>.status_code", 400);
tree.put( tree.put(
"root.<xmlattr>.status_message", "root.<xmlattr>.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; return false;
} }
@ -896,7 +897,15 @@ namespace nvhttp {
} }
tree.put("root.<xmlattr>.status_code", 200); tree.put("root.<xmlattr>.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<int>(net::map_port(rtsp_stream::RTSP_SETUP_PORT))
)
);
tree.put("root.gamesession", 1); tree.put("root.gamesession", 1);
rtsp_stream::launch_session_raise(launch_session); rtsp_stream::launch_session_raise(launch_session);
@ -978,7 +987,15 @@ namespace nvhttp {
} }
tree.put("root.<xmlattr>.status_code", 200); tree.put("root.<xmlattr>.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<int>(net::map_port(rtsp_stream::RTSP_SETUP_PORT))
)
);
tree.put("root.resume", 1); tree.put("root.resume", 1);
rtsp_stream::launch_session_raise(launch_session); rtsp_stream::launch_session_raise(launch_session);

View File

@ -4,6 +4,7 @@
*/ */
// standard includes // standard includes
#include <fcntl.h> #include <fcntl.h>
#include <format>
#include <sstream> #include <sstream>
#include <string> #include <string>
@ -574,7 +575,7 @@ namespace va {
if (!display) { if (!display) {
char string[1024]; 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}; std::string_view render_device {string, (std::size_t) bytes};

View File

@ -4,6 +4,9 @@
*/ */
#define INITGUID #define INITGUID
// standard includes
#include <format>
// platform includes // platform includes
#include <Audioclient.h> #include <Audioclient.h>
#include <avrt.h> #include <avrt.h>
@ -168,8 +171,7 @@ namespace {
waveformat.SubFormat == KSDATAFORMAT_SUBTYPE_PCM ? "S" : waveformat.SubFormat == KSDATAFORMAT_SUBTYPE_PCM ? "S" :
"UNKNOWN"; "UNKNOWN";
result += std::to_string(waveformat.Samples.wValidBitsPerSample) + " " + result += std::format("{} {} ", static_cast<int>(waveformat.Samples.wValidBitsPerSample), static_cast<int>(waveformat.Format.nSamplesPerSec));
std::to_string(waveformat.Format.nSamplesPerSec) + " ";
switch (waveformat.dwChannelMask) { switch (waveformat.dwChannelMask) {
case waveformat_mask_stereo: case waveformat_mask_stereo:
@ -189,7 +191,7 @@ namespace {
break; break;
default: default:
result += std::to_string(waveformat.Format.nChannels) + " channels (unrecognized)"; result += std::format("{} channels (unrecognized)", static_cast<int>(waveformat.Format.nChannels));
break; break;
} }

View File

@ -12,6 +12,7 @@ extern "C" {
// standard includes // standard includes
#include <array> #include <array>
#include <cctype> #include <cctype>
#include <format>
#include <set> #include <set>
#include <unordered_map> #include <unordered_map>
#include <utility> #include <utility>
@ -864,7 +865,7 @@ namespace rtsp_stream {
session_option.next = &port_option; session_option.next = &port_option;
// Moonlight merely requires 'server_port=<port>' // Moonlight merely requires 'server_port=<port>'
auto port_value = "server_port=" + std::to_string(port); auto port_value = std::format("server_port={}", static_cast<int>(port));
port_option.option = const_cast<char *>("Transport"); port_option.option = const_cast<char *>("Transport");
port_option.content = port_value.data(); port_option.content = port_value.data();

View File

@ -305,7 +305,7 @@ namespace system_tray {
tray.notification_icon = TRAY_ICON_LOCKED; tray.notification_icon = TRAY_ICON_LOCKED;
tray.tooltip = PROJECT_NAME; tray.tooltip = PROJECT_NAME;
tray.notification_cb = []() { tray.notification_cb = []() {
launch_ui_with_path("/pin"); launch_ui("/pin");
}; };
tray_update(&tray); tray_update(&tray);
} }

View File

@ -4,6 +4,7 @@
*/ */
#include "../tests_common.h" #include "../tests_common.h"
#include <format>
#include <src/config.h> #include <src/config.h>
#include <src/display_device.h> #include <src/display_device.h>
#include <src/rtsp.h> #include <src/rtsp.h>
@ -473,7 +474,7 @@ namespace {
} else { } else {
const auto [manual_res] = std::get<manual_value_t<res_t>>(input_res); const auto [manual_res] = std::get<manual_value_t<res_t>>(input_res);
video_config.dd.resolution_option = manual; 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<int>(manual_res.m_width), static_cast<int>(manual_res.m_height));
} }
} }

View File

@ -4,6 +4,7 @@
*/ */
#include "../tests_common.h" #include "../tests_common.h"
#include <format>
#include <src/file_handler.h> #include <src/file_handler.h>
struct FileHandlerParentDirectoryTest: testing::TestWithParam<std::tuple<std::string, std::string>> {}; struct FileHandlerParentDirectoryTest: testing::TestWithParam<std::tuple<std::string, std::string>> {};
@ -79,13 +80,13 @@ Hey, hey, hey!
TEST_P(FileHandlerTests, WriteFileTest) { TEST_P(FileHandlerTests, WriteFileTest) {
auto [fileNum, content] = GetParam(); 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); EXPECT_EQ(file_handler::write_file(fileName.c_str(), content), 0);
} }
TEST_P(FileHandlerTests, ReadFileTest) { TEST_P(FileHandlerTests, ReadFileTest) {
auto [fileNum, content] = GetParam(); 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); EXPECT_EQ(file_handler::read_file(fileName.c_str()), content);
} }

View File

@ -5,6 +5,7 @@
#include "../tests_common.h" #include "../tests_common.h"
#include "../tests_log_checker.h" #include "../tests_log_checker.h"
#include <format>
#include <random> #include <random>
#include <src/logging.h> #include <src/logging.h>
@ -39,7 +40,7 @@ TEST_P(LogLevelsTest, PutMessage) {
std::random_device rand_dev; std::random_device rand_dev;
std::mt19937_64 rand_gen(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; BOOST_LOG(logger) << test_message;
ASSERT_TRUE(log_checker::line_contains(log_file, test_message)); ASSERT_TRUE(log_checker::line_contains(log_file, test_message));

View File

@ -3,6 +3,7 @@
* @brief Handles launching Sunshine.exe into user sessions as SYSTEM * @brief Handles launching Sunshine.exe into user sessions as SYSTEM
*/ */
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <format>
#include <string> #include <string>
#include <Windows.h> #include <Windows.h>
#include <WtsApi32.h> #include <WtsApi32.h>
@ -137,7 +138,7 @@ bool RunTerminationHelper(HANDLE console_token, DWORD pid) {
command += L'"'; command += L'"';
command += module_path; command += module_path;
command += L'"'; command += L'"';
command += L" --terminate " + std::to_wstring(pid); command += std::format(L" --terminate {}", pid);
STARTUPINFOW startup_info = {}; STARTUPINFOW startup_info = {};
startup_info.cb = sizeof(startup_info); startup_info.cb = sizeof(startup_info);