diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-12-07 18:51:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-07 18:51:18 +0100 |
| commit | 8bbeee11734d3ba8e2cf15d19cb3c302f8bfdbf2 (patch) | |
| tree | 5b6654818049a0743f62defc090e86d4327cccbb /src/config/ConfigManager.cpp | |
| parent | b1e5cc66bdb20b002c93479490c3a317552210b3 (diff) | |
core: Add clang-tidy (#8664)
This adds a .clang-tidy file for us.
It's not a strict requirement to be compliant, but I tuned it to be alright.
Diffstat (limited to 'src/config/ConfigManager.cpp')
| -rw-r--r-- | src/config/ConfigManager.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 50fbe403..ce474f94 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1,5 +1,6 @@ #include "ConfigManager.hpp" #include "../managers/KeybindManager.hpp" +#include "../Compositor.hpp" #include "../render/decorations/CHyprGroupBarDecoration.hpp" #include "config/ConfigDataValues.hpp" @@ -12,7 +13,7 @@ #include <cstddef> #include <cstdint> #include <hyprutils/path/Path.hpp> -#include <string.h> +#include <cstring> #include <string> #include <sys/stat.h> #include <sys/types.h> @@ -30,6 +31,7 @@ #include <filesystem> using namespace Hyprutils::String; +//NOLINTNEXTLINE extern "C" char** environ; #include "ConfigDescriptions.hpp" @@ -70,7 +72,7 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void** const auto COL = configStringToInt(var); if (!COL) throw std::runtime_error(std::format("failed to parse {} as a color", var)); - DATA->m_vColors.push_back(CHyprColor(COL.value())); + DATA->m_vColors.emplace_back(COL.value()); } catch (std::exception& e) { Debug::log(WARN, "Error parsing gradient {}", V); parseError = "Error parsing gradient " + V + ": " + e.what(); @@ -82,7 +84,7 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void** if (parseError.empty()) parseError = "Error parsing gradient " + V + ": No colors?"; - DATA->m_vColors.push_back(0); // transparent + DATA->m_vColors.emplace_back(0); // transparent } DATA->updateColorsOk(); @@ -736,7 +738,7 @@ const std::string CConfigManager::getConfigString() { std::string configString; std::string currFileContent; - for (auto path : configPaths) { + for (const auto& path : configPaths) { std::ifstream configFile(path); configString += ("\n\nConfig File: " + path + ": "); if (!configFile.is_open()) { @@ -1100,7 +1102,7 @@ Vector2D CConfigManager::getDeviceVec(const std::string& dev, const std::string& } std::string CConfigManager::getDeviceString(const std::string& dev, const std::string& v, const std::string& fallback) { - const auto VAL = std::string{std::any_cast<Hyprlang::STRING>(getConfigValueSafeDevice(dev, v, fallback)->getValue())}; + auto VAL = std::string{std::any_cast<Hyprlang::STRING>(getConfigValueSafeDevice(dev, v, fallback)->getValue())}; if (VAL == STRVAL_EMPTY) return ""; @@ -1718,7 +1720,7 @@ void CConfigManager::handlePluginLoads() { std::stringstream error; error << "Failed to load the following plugins:"; - for (auto path : failedPlugins) { + for (const auto& path : failedPlugins) { error << "\n" << path; } @@ -2149,7 +2151,7 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co PANIM->second.internalStyle = ARGS[4]; if (ARGS[4] != "") { - const auto ERR = g_pAnimationManager->styleValidInConfigVar(ANIMNAME, ARGS[4]); + auto ERR = g_pAnimationManager->styleValidInConfigVar(ANIMNAME, ARGS[4]); if (ERR != "") return ERR; @@ -2238,10 +2240,10 @@ std::optional<std::string> CConfigManager::handleBind(const std::string& command std::set<xkb_keysym_t> MODS; if (multiKey) { - for (auto splitKey : CVarList(ARGS[1], 8, '&')) { + for (const auto& splitKey : CVarList(ARGS[1], 8, '&')) { KEYSYMS.insert(xkb_keysym_from_name(splitKey.c_str(), XKB_KEYSYM_CASE_INSENSITIVE)); } - for (auto splitMod : CVarList(ARGS[0], 8, '&')) { + for (const auto& splitMod : CVarList(ARGS[0], 8, '&')) { MODS.insert(xkb_keysym_from_name(splitMod.c_str(), XKB_KEYSYM_CASE_INSENSITIVE)); } } @@ -2687,8 +2689,8 @@ std::optional<std::string> CConfigManager::handleWorkspaceRules(const std::strin return "Invalid workspace rule found: " + rule; } - std::string val = opt.substr(opt.find(":") + 1); - opt = opt.substr(0, opt.find(":")); + std::string val = opt.substr(opt.find(':') + 1); + opt = opt.substr(0, opt.find(':')); wsRule.layoutopts[opt] = val; } |
