diff --git a/.clang-tidy b/.clang-tidy index f0dfdf1b2..db4990355 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,4 +1,111 @@ -WarningsAsErrors: '*' +WarningsAsErrors: > + -*, + bugprone-*, + -bugprone-multi-level-implicit-pointer-conversion, + -bugprone-empty-catch, + -bugprone-unused-return-value, + -bugprone-reserved-identifier, + -bugprone-switch-missing-default-case, + -bugprone-unused-local-non-trivial-variable, + -bugprone-easily-swappable-parameters, + -bugprone-forward-declararion-namespace, + -bugprone-forward-declararion-namespace, + -bugprone-macro-parentheses, + -bugprone-narrowing-conversions, + -bugprone-branch-clone, + -bugprone-assignment-in-if-condition, + concurrency-*, + -concurrency-mt-unsafe, + cppcoreguidelines-*, + -cppcoreguidelines-pro-type-const-cast, + -cppcoreguidelines-owning-memory, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-pro-bounds-constant-array-index, + -cppcoreguidelines-avoid-const-or-ref-data-members, + -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-avoid-goto, + -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + -cppcoreguidelines-avoid-do-while, + -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-special-member-functions, + -cppcoreguidelines-explicit-virtual-functions, + -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-pro-bounds-pointer-arithmetic, + -cppcoreguidelines-narrowing-conversions, + -cppcoreguidelines-pro-type-union-access, + -cppcoreguidelines-pro-type-member-init, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-macro-to-enum, + -cppcoreguidelines-init-variables, + -cppcoreguidelines-pro-type-cstyle-cast, + -cppcoreguidelines-pro-type-vararg, + -cppcoreguidelines-pro-type-reinterpret-cast, + -google-global-names-in-headers, + -google-readability-casting, + google-runtime-operator, + misc-*, + -misc-use-internal-linkage, + -misc-unused-parameters, + -misc-no-recursion, + -misc-non-private-member-variables-in-classes, + -misc-include-cleaner, + -misc-use-anonymous-namespace, + -misc-const-correctness, + modernize-*, + -modernize-use-emplace, + -modernize-redundant-void-arg, + -modernize-use-starts-ends-with, + -modernize-use-designated-initializers, + -modernize-use-std-numbers, + -modernize-return-braced-init-list, + -modernize-use-trailing-return-type, + -modernize-use-using, + -modernize-use-override, + -modernize-avoid-c-arrays, + -modernize-macro-to-enum, + -modernize-loop-convert, + -modernize-use-nodiscard, + -modernize-pass-by-value, + -modernize-use-auto, + performance-*, + -performance-inefficient-vector-operation, + -performance-inefficient-string-concatenation, + -performance-enum-size, + -performance-move-const-arg, + -performance-avoid-endl, + -performance-unnecessary-value-param, + portability-std-allocator-const, + readability-*, + -readability-identifier-naming, + -readability-use-std-min-max, + -readability-math-missing-parentheses, + -readability-simplify-boolean-expr, + -readability-static-accessed-through-instance, + -readability-use-anyofallof, + -readability-enum-initial-value, + -readability-redundant-inline-specifier, + -readability-function-cognitive-complexity, + -readability-function-size, + -readability-identifier-length, + -readability-magic-numbers, + -readability-uppercase-literal-suffix, + -readability-braces-around-statements, + -readability-redundant-access-specifiers, + -readability-else-after-return, + -readability-container-data-pointer, + -readability-implicit-bool-conversion, + -readability-avoid-nested-conditional-operator, + -readability-redundant-member-init, + -readability-redundant-string-init, + -readability-avoid-const-params-in-decls, + -readability-named-parameter, + -readability-convert-member-functions-to-static, + -readability-qualified-auto, + -readability-make-member-function-const, + -readability-isolate-declaration, + -readability-inconsistent-declaration-parameter-name, + -clang-diagnostic-error, + HeaderFilterRegex: '.*\.hpp' FormatStyle: file Checks: > diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index c238a9ee2..cbf1fcd5c 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -3016,11 +3016,11 @@ std::optional CConfigManager::handleSource(const std::string& comma return "source= path " + rawpath + " bogus!"; } - std::unique_ptr glob_buf{sc(calloc(1, sizeof(glob_t))), // allocate and zero-initialize + std::unique_ptr glob_buf{sc(calloc(1, sizeof(glob_t))), // allocate and zero-initialize NOLINT(cppcoreguidelines-no-malloc) [](glob_t* g) { if (g) { globfree(g); // free internal resources allocated by glob() - free(g); // free the memory for the glob_t structure + free(g); // free the memory for the glob_t structure NOLINT(cppcoreguidelines-no-malloc) } }}; diff --git a/src/devices/IKeyboard.cpp b/src/devices/IKeyboard.cpp index 20292176f..b732ba088 100644 --- a/src/devices/IKeyboard.cpp +++ b/src/devices/IKeyboard.cpp @@ -155,10 +155,10 @@ void IKeyboard::updateKeymapFD() { auto cKeymapStr = xkb_keymap_get_as_string(m_xkbKeymap, XKB_KEYMAP_FORMAT_TEXT_V2); m_xkbKeymapString = cKeymapStr; - free(cKeymapStr); + free(cKeymapStr); // NOLINT(cppcoreguidelines-no-malloc,-warnings-as-errors) auto cKeymapV1Str = xkb_keymap_get_as_string(m_xkbKeymap, XKB_KEYMAP_FORMAT_TEXT_V1); m_xkbKeymapV1String = cKeymapV1Str; - free(cKeymapV1Str); + free(cKeymapV1Str); // NOLINT(cppcoreguidelines-no-malloc,-warnings-as-errors) CFileDescriptor rw, ro, rwV1, roV1; if (!allocateSHMFilePair(m_xkbKeymapString.length() + 1, rw, ro)) diff --git a/src/helpers/Format.cpp b/src/helpers/Format.cpp index e03569a6b..ce64c113f 100644 --- a/src/helpers/Format.cpp +++ b/src/helpers/Format.cpp @@ -264,13 +264,13 @@ uint32_t NFormatUtils::glFormatToType(uint32_t gl) { std::string NFormatUtils::drmFormatName(DRMFormat drm) { auto n = drmGetFormatName(drm); std::string name = n; - free(n); + free(n); // NOLINT(cppcoreguidelines-no-malloc,-warnings-as-errors) return name; } std::string NFormatUtils::drmModifierName(uint64_t mod) { auto n = drmGetFormatModifierName(mod); std::string name = n; - free(n); + free(n); // NOLINT(cppcoreguidelines-no-malloc,-warnings-as-errors) return name; } diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index e91f1a7eb..2b6160c74 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -599,7 +599,7 @@ int64_t getPPIDof(int64_t pid) { fclose(infile); if (line) - free(line); + free(line); // NOLINT(cppcoreguidelines-no-malloc) try { return std::stoll(pidstr); diff --git a/src/helpers/Splashes.hpp b/src/helpers/Splashes.hpp index b94ea863d..4bc2814b9 100644 --- a/src/helpers/Splashes.hpp +++ b/src/helpers/Splashes.hpp @@ -49,7 +49,7 @@ namespace NSplashes { "By dt, do you mean damage tracking or distrotube?", "Made in Poland", "\"I use Arch, btw\" - John Cena", - "\"Hyper\".replace(\"e\", \"\")", + R"("Hyper".replace("e", ""))", "\"my win11 install runs hyprland that is true\" - raf", "\"stop playing league loser\" - hyprBot", "\"If it ain't broke, don't fix it\" - Lucascito_03", diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index 5d6eaf6f7..fa5c77ba2 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -1103,8 +1103,8 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri const bool IGNORE_IF_MASTER = vars.size() >= 2 && std::ranges::any_of(vars, [](const auto& e) { return e == "ignoremaster"; }); if (PMASTER->pWindow.lock() != PWINDOW) { - const auto NEWMASTER = PWINDOW; - const bool newFocusToChild = vars.size() >= 2 && vars[1] == "child"; + const auto& NEWMASTER = PWINDOW; + const bool newFocusToChild = vars.size() >= 2 && vars[1] == "child"; switchWindows(NEWMASTER, NEWCHILD); const auto NEWFOCUS = newFocusToChild ? NEWCHILD : NEWMASTER; switchToWindow(NEWFOCUS); diff --git a/src/protocols/LayerShell.cpp b/src/protocols/LayerShell.cpp index 2ed4bfb1c..15db14458 100644 --- a/src/protocols/LayerShell.cpp +++ b/src/protocols/LayerShell.cpp @@ -159,7 +159,7 @@ CLayerShellResource::CLayerShellResource(SP resource_, SPerror(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_EXCLUSIVE_EDGE, "Exclusive edge doesn't align with anchor"); return; } diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index fd5ce1641..5a2593eca 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -109,7 +109,7 @@ static int openRenderNode(int drmFd) { if (render_version && render_version->name) { Debug::log(LOG, "DRM dev versionName", render_version->name); if (strcmp(render_version->name, "evdi") == 0) { - free(renderName); + free(renderName); // NOLINT(cppcoreguidelines-no-malloc) renderName = strdup("/dev/dri/card0"); } drmFreeVersion(render_version); @@ -122,7 +122,7 @@ static int openRenderNode(int drmFd) { if (renderFD < 0) Debug::log(ERR, "openRenderNode failed to open drm device {}", renderName); - free(renderName); + free(renderName); // NOLINT(cppcoreguidelines-no-malloc) return renderFD; } @@ -505,9 +505,9 @@ void CHyprOpenGLImpl::initDRMFormats() { for (auto const& mod : mods) { auto modName = drmGetFormatModifierName(mod); modifierData.emplace_back(std::make_pair<>(mod, modName ? modName : "?unknown?")); - free(modName); + free(modName); // NOLINT(cppcoreguidelines-no-malloc) } - free(fmtName); + free(fmtName); // NOLINT(cppcoreguidelines-no-malloc) mods.clear(); std::ranges::sort(modifierData, [](const auto& a, const auto& b) { diff --git a/src/xwayland/Dnd.cpp b/src/xwayland/Dnd.cpp index 837f2d338..2967c1895 100644 --- a/src/xwayland/Dnd.cpp +++ b/src/xwayland/Dnd.cpp @@ -64,9 +64,9 @@ xcb_window_t CX11DataDevice::getProxyWindow(xcb_window_t window) { Debug::log(LOG, "Using XdndProxy window {:x} for window {:x}", proxyWindow, window); } } - free(proxyVerifyReply); + free(proxyVerifyReply); // NOLINT(cppcoreguidelines-no-malloc) } - free(proxyReply); + free(proxyReply); // NOLINT(cppcoreguidelines-no-malloc) return targetWindow; } diff --git a/src/xwayland/XDataSource.cpp b/src/xwayland/XDataSource.cpp index c67ca101e..8e7b25054 100644 --- a/src/xwayland/XDataSource.cpp +++ b/src/xwayland/XDataSource.cpp @@ -17,7 +17,7 @@ CXDataSource::CXDataSource(SXSelection& sel_) : m_selection(sel_) { return; if (reply->type != XCB_ATOM_ATOM) { - free(reply); + free(reply); // NOLINT(cppcoreguidelines-no-malloc) return; } @@ -41,7 +41,7 @@ CXDataSource::CXDataSource(SXSelection& sel_) : m_selection(sel_) { m_mimeAtoms.push_back(value[i]); } - free(reply); + free(reply); // NOLINT(cppcoreguidelines-no-malloc) } std::vector CXDataSource::mimes() { diff --git a/src/xwayland/XSurface.cpp b/src/xwayland/XSurface.cpp index fc92e4809..73c512f26 100644 --- a/src/xwayland/XSurface.cpp +++ b/src/xwayland/XSurface.cpp @@ -35,11 +35,11 @@ CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : m_x xcb_res_client_id_value_next(&iter); } if (!ppid) { - free(reply); + free(reply); // NOLINT(cppcoreguidelines-no-malloc) return; } m_pid = *ppid; - free(reply); + free(reply); // NOLINT(cppcoreguidelines-no-malloc) } m_events.resourceChange.listenStatic([this] { ensureListeners(); }); diff --git a/src/xwayland/XWM.cpp b/src/xwayland/XWM.cpp index 5435e2644..c43a20eb4 100644 --- a/src/xwayland/XWM.cpp +++ b/src/xwayland/XWM.cpp @@ -33,7 +33,7 @@ static int onX11Event(int fd, uint32_t mask, void* data) { struct SFreeDeleter { void operator()(void* ptr) const { - std::free(ptr); + std::free(ptr); // NOLINT(cppcoreguidelines-no-malloc) } }; @@ -1292,7 +1292,7 @@ void CXWM::getTransferData(SXSelection& sel) { if (transfer->propertyReply->type == HYPRATOMS["INCR"]) { transfer->incremental = true; transfer->propertyStart = 0; - free(transfer->propertyReply); + free(transfer->propertyReply); // NOLINT(cppcoreguidelines-no-malloc) transfer->propertyReply = nullptr; return; } @@ -1544,7 +1544,7 @@ int SXSelection::onWrite() { if (!transfer->incremental) { transfers.erase(it); } else { - free(transfer->propertyReply); + free(transfer->propertyReply); // NOLINT(cppcoreguidelines-no-malloc) transfer->propertyReply = nullptr; transfer->propertyStart = 0; } @@ -1559,7 +1559,7 @@ SXTransfer::~SXTransfer() { if (incomingWindow) xcb_destroy_window(*g_pXWayland->m_wm->m_connection, incomingWindow); if (propertyReply) - free(propertyReply); + free(propertyReply); // NOLINT(cppcoreguidelines-no-malloc) } bool SXTransfer::getIncomingSelectionProp(bool erase) {