chore: apply light lints (#2570)

This commit is contained in:
iTrooz
2025-12-19 23:49:37 +01:00
committed by GitHub
parent 92cfdf1145
commit 261610dcf1
72 changed files with 477 additions and 447 deletions

View File

@@ -35,7 +35,7 @@
while (true) {
const auto result = splashWindow->loop();
if (result.has_value()) {
if (result.value() == false) {
if (!result.value()) {
ImHexApi::System::impl::addInitArgument("tasks-failed");
}

View File

@@ -40,7 +40,7 @@ namespace hex::init {
WindowSplash::WindowSplash() : m_window(nullptr) {
RequestAddInitTask::subscribe([this](const std::string& name, bool async, const TaskFunction &function){
std::lock_guard guard(m_progressMutex);
std::scoped_lock guard(m_progressMutex);
m_tasks.push_back(Task{ name, function, async, false });
m_totalTaskCount += 1;
@@ -210,14 +210,14 @@ namespace hex::init {
// Save an iterator to the current task name
decltype(m_currTaskNames)::iterator taskNameIter;
{
std::lock_guard guard(m_progressMutex);
std::scoped_lock guard(m_progressMutex);
m_currTaskNames.push_back(task.name + "...");
taskNameIter = std::prev(m_currTaskNames.end());
}
// When the task finished, increment the progress bar
ON_SCOPE_EXIT {
std::lock_guard guard(m_progressMutex);
std::scoped_lock guard(m_progressMutex);
m_completedTaskCount += 1;
m_progress = float(m_completedTaskCount) / float(m_totalTaskCount);
};
@@ -239,7 +239,7 @@ namespace hex::init {
// Erase the task name from the list of running tasks
{
std::lock_guard guard(m_progressMutex);
std::scoped_lock guard(m_progressMutex);
m_currTaskNames.erase(taskNameIter);
}
} catch (const std::exception &e) {
@@ -272,11 +272,11 @@ namespace hex::init {
// Check every 10ms if all tasks have run
while (true) {
// Loop over all registered init tasks
for (auto it = m_tasks.begin(); it != m_tasks.end(); ++it) {
for (auto & m_task : m_tasks) {
// Construct a new task callback
if (!it->running) {
this->createTask(*it);
it->running = true;
if (!m_task.running) {
this->createTask(m_task);
m_task.running = true;
}
}
@@ -396,7 +396,7 @@ namespace hex::init {
// Draw the task progress bar
{
std::lock_guard guard(m_progressMutex);
std::scoped_lock guard(m_progressMutex);
const auto progressBackgroundStart = ImVec2(99, 357);
const auto progressBackgroundSize = ImVec2(442, 30);

View File

@@ -64,7 +64,7 @@ int main(int argc, char **argv) {
#if defined(OS_LINUX)
if (auto distro = ImHexApi::System::getLinuxDistro(); distro.has_value()) {
log::info("Linux distribution: {}. Version: {}", distro->name, distro->version == "" ? "None" : distro->version);
log::info("Linux distribution: {}. Version: {}", distro->name, distro->version.empty() ? "None" : distro->version);
}
#endif

View File

@@ -1,6 +1,5 @@
#if defined(OS_LINUX)
#include <stdexcept>
#include <fcntl.h>
#include <sys/file.h>
#include <unistd.h>
@@ -25,7 +24,7 @@ namespace hex::messaging {
fullEventData.insert(fullEventData.end(), args.begin(), args.end());
u8 *data = &fullEventData[0];
u8 *data = fullEventData.data();
auto dataSize = fullEventData.size();
int fifo = open(CommunicationPipePath, O_WRONLY);

View File

@@ -20,7 +20,6 @@
#include <GLFW/glfw3.h>
#include <imgui_impl_glfw.h>
#include <string.h>
#include <ranges>
#if defined(IMHEX_HAS_FONTCONFIG)

View File

@@ -25,8 +25,6 @@
#include <hex/ui/banner.hpp>
#include <cmath>
#include <chrono>
#include <csignal>
#include <numbers>
#include <romfs/romfs.hpp>
@@ -663,7 +661,7 @@ namespace hex {
const auto windowPos = ImHexApi::System::getMainWindowPosition();
float startY = windowPos.y + ImGui::GetTextLineHeight() + ((ImGui::GetTextLineHeight() + (ImGui::GetStyle().FramePadding.y * 2.0F)) * (onWelcomeScreen ? 1 : 2));
const auto height = ImGui::GetTextLineHeightWithSpacing() * 1.5f;
const auto height = ImGui::GetTextLineHeightWithSpacing() * 1.5F;
// Offset banner based on the size of the title bar. On macOS, it's slightly taller
#if defined(OS_MACOS)
@@ -956,13 +954,13 @@ namespace hex {
GLuint quadVAO, quadVBO;
float quadVertices[] = {
// positions // texCoords
-1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 0.0f,
1.0f, -1.0f, 1.0f, 0.0f,
-1.0F, 1.0F, 0.0F, 1.0F,
-1.0F, -1.0F, 0.0F, 0.0F,
1.0F, -1.0F, 1.0F, 0.0F,
-1.0f, 1.0f, 0.0f, 1.0f,
1.0f, -1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 1.0f, 1.0f
-1.0F, 1.0F, 0.0F, 1.0F,
1.0F, -1.0F, 1.0F, 0.0F,
1.0F, 1.0F, 1.0F, 1.0F
};
glGenVertexArrays(1, &quadVAO);
@@ -971,7 +969,7 @@ namespace hex {
glBindBuffer(GL_ARRAY_BUFFER, quadVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(quadVertices), quadVertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), nullptr);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2 * sizeof(float)));
glBindVertexArray(0);

View File

@@ -158,7 +158,7 @@ bool installUpdate(const std::fs::path &updatePath) {
UpdateHandler { ".deb", "zenity --password | sudo -S apt install -y --fix-broken \"{}\"" },
UpdateHandler { ".rpm", "zenity --password | sudo -S rpm -i \"{}\"" },
UpdateHandler { ".pkg.tar.zst", "zenity --password | sudo -S pacman -Syy && sudo pacman -U --noconfirm \"{}\"" },
UpdateHandler { ".AppImage", fmt::format("zenity --password | sudo -S cp \"{{}}\" \"{}\"", hex::getEnvironmentVariable("APPIMAGE").value_or("")) },
UpdateHandler { ".AppImage", fmt::format(R"(zenity --password | sudo -S cp "{{}}" "{}")", hex::getEnvironmentVariable("APPIMAGE").value_or("")) },
UpdateHandler { ".flatpak", "zenity --password | sudo -S flatpak install -y --reinstall \"{}\"" },
UpdateHandler { ".snap", "zenity --password | sudo -S snap install --dangerous \"{}\"" },
};