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

@@ -16,7 +16,7 @@ EXPORT_MODULE namespace hex {
void stopServices();
}
void registerService(const UnlocalizedString &unlocalizedString, const impl::Callback &callback);
void registerService(const UnlocalizedString &unlocalizedName, const impl::Callback &callback);
}
}

View File

@@ -10,6 +10,7 @@
#include <span>
#include <string>
#include <numbers>
#include <array>
#include <opengl_support.h>
#include "imgui.h"
@@ -935,7 +936,7 @@ namespace hex::gl {
void attachTexture(const Texture &texture) const;
private:
GLuint m_frameBuffer, m_renderBuffer;
GLuint m_frameBuffer = 0, m_renderBuffer = 0;
};
class AxesVectors {

View File

@@ -264,8 +264,7 @@ namespace hex {
}
}
if (json.empty())
return;
if (json.empty()) return;
#if defined(OS_WEB)
auto data = json.dump();

View File

@@ -1,3 +1,4 @@
#include <algorithm>
#include <hex/api/event_manager.hpp>
namespace hex {
@@ -35,7 +36,7 @@ namespace hex {
void EventManager::unsubscribe(void *token, impl::EventId id) {
auto &tokenStore = getTokenStore();
auto iter = std::find_if(tokenStore.begin(), tokenStore.end(), [&](auto &item) {
auto iter = std::ranges::find_if(tokenStore, [&](auto &item) {
return item.first == token && item.second->first == id;
});

View File

@@ -50,7 +50,7 @@ namespace hex {
definition.fallbackLanguageId = item["fallback"].get<std::string>();
}
if (item.contains("hidden") && item["hidden"].get<bool>() == true) {
if (item.contains("hidden") && item["hidden"].get<bool>()) {
definition.hidden = true;
}
@@ -155,7 +155,7 @@ namespace hex {
static AutoReset<std::unordered_map<std::size_t, std::string>> loadedLocalization;
static std::mutex mutex;
std::lock_guard lock(mutex);
std::scoped_lock lock(mutex);
if (*currentLanguageId != languageId) {
currentLanguageId = languageId;
loadedLocalization->clear();

View File

@@ -85,7 +85,7 @@ namespace hex {
}
Plugin::Plugin(const std::string &name, const hex::PluginFunctions &functions) :
m_handle(0), m_path(name), m_addedManually(true), m_functions(functions) { }
m_path(name), m_addedManually(true), m_functions(functions) { }
Plugin::Plugin(Plugin &&other) noexcept {

View File

@@ -7,7 +7,7 @@ namespace hex {
namespace {
void skipWhitespace(std::string_view &string) {
while (string.length() > 0) {
while (!string.empty()) {
if (!std::isspace(string.front()))
break;
string = string.substr(1);
@@ -89,7 +89,7 @@ namespace hex {
return { };
bool inString = false;
while (string.length() > 0) {
while (!string.empty()) {
BinaryPattern::Pattern pattern = { 0, 0 };
if (string.starts_with("\"")) {

View File

@@ -1,3 +1,4 @@
#include <algorithm>
#include <hex/helpers/default_paths.hpp>
#include <hex/api/imhex_api/system.hpp>
@@ -39,7 +40,7 @@ namespace hex::paths {
paths.push_back(xdg::DataHomeDir());
auto dataDirs = xdg::DataDirs();
std::copy(dataDirs.begin(), dataDirs.end(), std::back_inserter(paths));
std::ranges::copy(dataDirs, std::back_inserter(paths));
#endif
@@ -108,7 +109,7 @@ namespace hex::paths {
// Add the system plugin directory to the path if one was provided at compile time
#if defined(OS_LINUX) && defined(SYSTEM_PLUGINS_LOCATION)
paths.push_back(SYSTEM_PLUGINS_LOCATION);
paths.emplace_back(SYSTEM_PLUGINS_LOCATION);
#endif
return paths;

View File

@@ -2,6 +2,7 @@
#include <hex/helpers/utils.hpp>
#include <ranges>
#include <wolv/io/file.hpp>
#include <wolv/utils/string.hpp>
@@ -89,9 +90,7 @@ namespace hex {
std::pair<std::string_view, size_t> EncodingFile::getEncodingFor(std::span<const u8> buffer) const {
for (auto riter = m_mapping->crbegin(); riter != m_mapping->crend(); ++riter) {
const auto &[size, mapping] = *riter;
for (auto [size, mapping] : std::ranges::reverse_view(*m_mapping)) {
if (size > buffer.size()) continue;
std::vector key(buffer.begin(), buffer.begin() + size);
@@ -103,9 +102,7 @@ namespace hex {
}
u64 EncodingFile::getEncodingLengthFor(std::span<u8> buffer) const {
for (auto riter = m_mapping->crbegin(); riter != m_mapping->crend(); ++riter) {
const auto &[size, mapping] = *riter;
for (auto [size, mapping] : std::ranges::reverse_view(*m_mapping)) {
if (size > buffer.size()) continue;
std::vector key(buffer.begin(), buffer.begin() + size);

View File

@@ -13,8 +13,6 @@
#include <xdg.hpp>
# if defined(OS_FREEBSD)
#include <sys/syslimits.h>
# else
#include <limits.h>
# endif
#endif

View File

@@ -1,9 +1,14 @@
#include <cstddef>
#include "wolv/types.hpp"
#include <cmath>
#include <hex/helpers/opengl.hpp>
#include <opengl_support.h>
#include <hex/helpers/utils.hpp>
#include <hex/helpers/logger.hpp>
#include <string_view>
#include <vector>
#include <span>
#include <wolv/utils/guards.hpp>
#include <numbers>

View File

@@ -1,3 +1,4 @@
#include <algorithm>
#include <hex/helpers/patches.hpp>
#include <hex/helpers/utils.hpp>
@@ -5,7 +6,6 @@
#include <hex/providers/provider.hpp>
#include <cstring>
#include <string_view>
namespace hex {
@@ -83,7 +83,7 @@ namespace hex {
[[nodiscard]] UnlocalizedString getTypeName() const override { return ""; }
const std::map<u64, u8>& getPatches() const {
[[nodiscard]] const std::map<u64, u8>& getPatches() const {
return m_patches;
}
private:
@@ -92,7 +92,7 @@ namespace hex {
void pushStringBack(std::vector<u8> &buffer, const std::string &string) {
std::copy(string.begin(), string.end(), std::back_inserter(buffer));
std::ranges::copy(string, std::back_inserter(buffer));
}
template<typename T>

View File

@@ -14,7 +14,7 @@
namespace hex {
UDPServer::UDPServer(u16 port, Callback callback)
: m_port(port), m_callback(std::move(callback)), m_running(false), m_socketFd(-1) {
: m_port(port), m_callback(std::move(callback)), m_running(false) {
}
UDPServer::~UDPServer() {

View File

@@ -1,3 +1,4 @@
#include <algorithm>
#include <cwchar>
#include <hex/helpers/utils.hpp>
@@ -98,7 +99,7 @@ namespace hex {
string = wolv::util::replaceStrings(string, ",", "");
// Check for non-hex characters
bool isValidHexString = std::find_if(string.begin(), string.end(), [](char c) {
bool isValidHexString = std::ranges::find_if(string, [](char c) {
return !std::isxdigit(c) && !std::isspace(c);
}) == string.end();
@@ -824,10 +825,10 @@ namespace hex {
if (lang.has_value() && !lang->empty() && *lang != "C" && *lang != "C.UTF-8") {
auto parts = wolv::util::splitString(*lang, ".");
if (parts.size() > 0)
if (!parts.empty())
return parts[0];
else
return *lang;
return lang;
}
return std::nullopt;

View File

@@ -10,13 +10,14 @@ namespace hex {
void executeCmd(const std::vector<std::string> &argsVector) {
std::vector<char*> cArgsVector;
for (const auto &str : argsVector) {
cArgsVector.reserve(argsVector.size());
for (const auto &str : argsVector) {
cArgsVector.push_back(const_cast<char*>(str.c_str()));
}
cArgsVector.push_back(nullptr);
if (fork() == 0) {
execvp(cArgsVector[0], &cArgsVector[0]);
execvp(cArgsVector[0], cArgsVector.data());
log::error("execvp() failed: {}", strerror(errno));
exit(EXIT_FAILURE);
}

View File

@@ -1516,9 +1516,9 @@ namespace ImGuiExt {
bool IsDarkBackground(const ImColor& bgColor) {
// Extract RGB components in 0255 range
int r = static_cast<int>(bgColor.Value.x * 255.0f);
int g = static_cast<int>(bgColor.Value.y * 255.0f);
int b = static_cast<int>(bgColor.Value.z * 255.0f);
int r = static_cast<int>(bgColor.Value.x * 255.0F);
int g = static_cast<int>(bgColor.Value.y * 255.0F);
int b = static_cast<int>(bgColor.Value.z * 255.0F);
// Compute brightness using perceived luminance
int brightness = (r * 299 + g * 587 + b * 114) / 1000;

View File

@@ -22,6 +22,5 @@ namespace hex::trace {
};
StackTraceResult getStackTrace();
[[nodiscard]] std::string demangle(const std::string &mangledName);
}
[[nodiscard]] std::string demangle(const std::string &symbolName);
}

View File

@@ -218,7 +218,7 @@ static std::mutex s_traceMutex;
}
StackTraceResult getStackTrace() {
std::lock_guard lock(s_traceMutex);
std::scoped_lock lock(s_traceMutex);
static std::vector<StackFrame> result;