From c5319e353bfa7d03a96a010c93053baa7ac9a49a Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 24 Nov 2024 02:27:49 -0800 Subject: [PATCH] all: fix clang 18 lints --- .clang-tidy | 2 ++ .github/workflows/lint.yml | 2 +- Justfile | 2 +- src/core/clock.hpp | 3 ++- src/core/logging_qtprivate.hpp | 3 ++- src/core/paths.hpp | 3 ++- src/core/popupanchor.hpp | 3 ++- src/core/qsmenu.hpp | 2 +- src/core/region.hpp | 4 ++-- src/core/types.hpp | 3 ++- src/services/greetd/connection.hpp | 3 ++- src/services/mpris/player.hpp | 4 ++-- src/services/notifications/notification.hpp | 5 +++-- src/services/notifications/server.cpp | 2 +- src/services/notifications/server.hpp | 2 +- src/services/pam/conversation.hpp | 7 +++---- src/services/pam/subprocess.hpp | 2 +- src/services/pipewire/link.hpp | 2 +- src/services/pipewire/node.hpp | 2 +- src/services/status_notifier/dbus_item_types.cpp | 1 + src/services/status_notifier/item.hpp | 4 ++-- src/services/upower/device.hpp | 4 ++-- src/wayland/hyprland/global_shortcuts/qml.cpp | 1 - src/wayland/wlr_layershell/window.hpp | 4 ++-- src/window/panelinterface.hpp | 3 ++- 25 files changed, 41 insertions(+), 32 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 5741bf6..f8d764c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -6,6 +6,7 @@ Checks: > bugprone-*, -bugprone-easily-swappable-parameters, -bugprone-forward-declararion-namespace, + -bugprone-forward-declararion-namespace, concurrency-*, cppcoreguidelines-*, -cppcoreguidelines-owning-memory, @@ -42,6 +43,7 @@ Checks: > -readability-else-after-return, -readability-container-data-pointer, -readability-implicit-bool-conversion, + -readability-avoid-nested-conditional-operator, tidyfox-*, CheckOptions: performance-for-range-copy.WarnOnAllAutoCopies: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index aac7a33..d9c3aa9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,4 +22,4 @@ jobs: just build - name: Run lints - run: just lint 2>&1 + run: just lint diff --git a/Justfile b/Justfile index a017ba3..e5d8bd9 100644 --- a/Justfile +++ b/Justfile @@ -4,7 +4,7 @@ fmt: find src -type f \( -name "*.cpp" -o -name "*.hpp" \) -print0 | xargs -0 clang-format -i lint: - find src -type f -name "*.cpp" -print0 | parallel -q0 --bar clang-tidy --use-color --load={{ env_var("TIDYFOX") }} + find src -type f -name "*.cpp" -print0 | parallel -q0 --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }} configure target='debug' *FLAGS='': cmake -GNinja -B {{builddir}} \ diff --git a/src/core/clock.hpp b/src/core/clock.hpp index 575f031..3e66958 100644 --- a/src/core/clock.hpp +++ b/src/core/clock.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "util.hpp" @@ -27,7 +28,7 @@ class SystemClock: public QObject { public: // must be named enum until docgen is ready to handle member enums better - enum Enum { + enum Enum : quint8 { Hours = 1, Minutes = 2, Seconds = 3, diff --git a/src/core/logging_qtprivate.hpp b/src/core/logging_qtprivate.hpp index 1756340..83c8258 100644 --- a/src/core/logging_qtprivate.hpp +++ b/src/core/logging_qtprivate.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace qs::log { Q_DECLARE_LOGGING_CATEGORY(logLogging); @@ -22,7 +23,7 @@ class QLoggingRule { QLoggingRule(QStringView pattern, bool enabled); [[nodiscard]] int pass(QLatin1StringView categoryName, QtMsgType type) const; - enum PatternFlag { + enum PatternFlag : quint8 { FullText = 0x1, LeftFilter = 0x2, RightFilter = 0x4, diff --git a/src/core/paths.hpp b/src/core/paths.hpp index b3042ba..b20d408 100644 --- a/src/core/paths.hpp +++ b/src/core/paths.hpp @@ -1,6 +1,7 @@ #pragma once #include #include +#include #include "instanceinfo.hpp" @@ -31,7 +32,7 @@ class QsPaths { void createLock(); private: - enum class DirState { + enum class DirState : quint8 { Unknown = 0, Ready = 1, Failed = 2, diff --git a/src/core/popupanchor.hpp b/src/core/popupanchor.hpp index f9a4b99..90ba697 100644 --- a/src/core/popupanchor.hpp +++ b/src/core/popupanchor.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "../window/proxywindow.hpp" @@ -26,7 +27,7 @@ namespace PopupAdjustment { // NOLINT Q_NAMESPACE; QML_ELEMENT; -enum Enum { +enum Enum : quint8 { None = 0, /// If the X axis is constrained, the popup will slide along the X axis until it fits onscreen. SlideX = 1, diff --git a/src/core/qsmenu.hpp b/src/core/qsmenu.hpp index a088eac..932bdb2 100644 --- a/src/core/qsmenu.hpp +++ b/src/core/qsmenu.hpp @@ -20,7 +20,7 @@ class QsMenuButtonType: public QObject { QML_SINGLETON; public: - enum Enum { + enum Enum : quint8 { /// This menu item does not have a checkbox or a radiobutton associated with it. None = 0, /// This menu item should draw a checkbox. diff --git a/src/core/region.hpp b/src/core/region.hpp index a512085..02d7a26 100644 --- a/src/core/region.hpp +++ b/src/core/region.hpp @@ -15,7 +15,7 @@ namespace RegionShape { // NOLINT Q_NAMESPACE; QML_ELEMENT; -enum Enum { +enum Enum : quint8 { Rect = 0, Ellipse = 1, }; @@ -29,7 +29,7 @@ namespace Intersection { // NOLINT Q_NAMESPACE; QML_ELEMENT; -enum Enum { +enum Enum : quint8 { /// Combine this region, leaving a union of this and the other region. (opposite of `Subtract`) Combine = 0, /// Subtract this region, cutting this region out of the other. (opposite of `Combine`) diff --git a/src/core/types.hpp b/src/core/types.hpp index cacd7b3..0adc85c 100644 --- a/src/core/types.hpp +++ b/src/core/types.hpp @@ -6,6 +6,7 @@ #include #include #include +#include class Box { Q_GADGET; @@ -53,7 +54,7 @@ namespace Edges { // NOLINT Q_NAMESPACE; QML_NAMED_ELEMENT(Edges); -enum Enum { +enum Enum : quint8 { None = 0, Top = Qt::TopEdge, Left = Qt::LeftEdge, diff --git a/src/services/greetd/connection.hpp b/src/services/greetd/connection.hpp index fd619a1..0c1d1eb 100644 --- a/src/services/greetd/connection.hpp +++ b/src/services/greetd/connection.hpp @@ -6,6 +6,7 @@ #include #include #include +#include ///! State of the Greetd connection. /// See @@Greetd.state. @@ -15,7 +16,7 @@ class GreetdState: public QObject { QML_SINGLETON; public: - enum Enum { + enum Enum : quint8 { Inactive = 0, Authenticating = 1, ReadyToLaunch = 2, diff --git a/src/services/mpris/player.hpp b/src/services/mpris/player.hpp index c618b7a..bf329a8 100644 --- a/src/services/mpris/player.hpp +++ b/src/services/mpris/player.hpp @@ -23,7 +23,7 @@ class MprisPlaybackState: public QObject { QML_SINGLETON; public: - enum Enum { + enum Enum : quint8 { Stopped = 0, Playing = 1, Paused = 2, @@ -41,7 +41,7 @@ class MprisLoopState: public QObject { QML_SINGLETON; public: - enum Enum { + enum Enum : quint8 { None = 0, Track = 1, Playlist = 2, diff --git a/src/services/notifications/notification.hpp b/src/services/notifications/notification.hpp index 5a7110c..25b9e33 100644 --- a/src/services/notifications/notification.hpp +++ b/src/services/notifications/notification.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "../../core/retainable.hpp" #include "../../core/util.hpp" @@ -24,7 +25,7 @@ class NotificationUrgency: public QObject { QML_SINGLETON; public: - enum Enum { + enum Enum : quint8 { Low = 0, Normal = 1, Critical = 2, @@ -42,7 +43,7 @@ class NotificationCloseReason: public QObject { QML_SINGLETON; public: - enum Enum { + enum Enum : quint8 { /// The notification expired due to a timeout. Expired = 1, /// The notification was explicitly dismissed by the user. diff --git a/src/services/notifications/server.cpp b/src/services/notifications/server.cpp index 3e035e0..9a866f7 100644 --- a/src/services/notifications/server.cpp +++ b/src/services/notifications/server.cpp @@ -124,7 +124,7 @@ void NotificationServer::tryRegister() { } void NotificationServer::onServiceUnregistered(const QString& /*unused*/) { qCDebug(logNotifications) << "Active notification server unregistered, attempting registration"; - this->tryRegister(); + NotificationServer::tryRegister(); } void NotificationServer::CloseNotification(uint id) { diff --git a/src/services/notifications/server.hpp b/src/services/notifications/server.hpp index de140f8..8c20943 100644 --- a/src/services/notifications/server.hpp +++ b/src/services/notifications/server.hpp @@ -63,7 +63,7 @@ class NotificationServer: public QObject { // NOLINTEND private slots: - void onServiceUnregistered(const QString& service); + static void onServiceUnregistered(const QString& service); private: explicit NotificationServer(); diff --git a/src/services/pam/conversation.hpp b/src/services/pam/conversation.hpp index 2ba4e8e..d0f2d97 100644 --- a/src/services/pam/conversation.hpp +++ b/src/services/pam/conversation.hpp @@ -1,13 +1,12 @@ #pragma once -#include - #include #include #include #include #include #include +#include #include "ipc.hpp" @@ -21,7 +20,7 @@ class PamResult: public QObject { QML_SINGLETON; public: - enum Enum { + enum Enum : quint8 { /// Authentication was successful. Success = 0, /// Authentication failed. @@ -44,7 +43,7 @@ class PamError: public QObject { QML_SINGLETON; public: - enum Enum { + enum Enum : quint8 { /// Failed to start the pam session. StartFailed = 1, /// Failed to try to authenticate the user. diff --git a/src/services/pam/subprocess.hpp b/src/services/pam/subprocess.hpp index 11f738f..2d289c9 100644 --- a/src/services/pam/subprocess.hpp +++ b/src/services/pam/subprocess.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include // NOLINT std::cout #include diff --git a/src/services/pipewire/link.hpp b/src/services/pipewire/link.hpp index 55bbcf0..d87c7c5 100644 --- a/src/services/pipewire/link.hpp +++ b/src/services/pipewire/link.hpp @@ -21,7 +21,7 @@ class PwLinkState: public QObject { QML_SINGLETON; public: - enum Enum { + enum Enum : qint8 { Error = PW_LINK_STATE_ERROR, Unlinked = PW_LINK_STATE_UNLINKED, Init = PW_LINK_STATE_INIT, diff --git a/src/services/pipewire/node.hpp b/src/services/pipewire/node.hpp index 5a67db7..697a54e 100644 --- a/src/services/pipewire/node.hpp +++ b/src/services/pipewire/node.hpp @@ -87,7 +87,7 @@ class PwAudioChannel: public QObject { Q_INVOKABLE static QString toString(qs::service::pipewire::PwAudioChannel::Enum value); }; -enum class PwNodeType { +enum class PwNodeType : quint8 { Untracked, Audio, }; diff --git a/src/services/status_notifier/dbus_item_types.cpp b/src/services/status_notifier/dbus_item_types.cpp index 4a41d6a..52f7fea 100644 --- a/src/services/status_notifier/dbus_item_types.cpp +++ b/src/services/status_notifier/dbus_item_types.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include bool DBusSniIconPixmap::operator==(const DBusSniIconPixmap& other) const { diff --git a/src/services/status_notifier/item.hpp b/src/services/status_notifier/item.hpp index b82171b..bc50672 100644 --- a/src/services/status_notifier/item.hpp +++ b/src/services/status_notifier/item.hpp @@ -26,7 +26,7 @@ namespace Status { // NOLINT Q_NAMESPACE; QML_ELEMENT; -enum Enum { +enum Enum : quint8 { /// A passive item does not convey important information and can be considered idle. You may want to hide these. Passive = 0, /// An active item may have information more important than a passive one and you probably do not want to hide it. @@ -43,7 +43,7 @@ namespace Category { // NOLINT Q_NAMESPACE; QML_ELEMENT; -enum Enum { +enum Enum : quint8 { /// The fallback category for general applications or anything that does /// not fit into a different category. ApplicationStatus = 0, diff --git a/src/services/upower/device.hpp b/src/services/upower/device.hpp index 2f37ea0..17ce4b4 100644 --- a/src/services/upower/device.hpp +++ b/src/services/upower/device.hpp @@ -20,7 +20,7 @@ class UPowerDeviceState: public QObject { QML_SINGLETON; public: - enum Enum { + enum Enum : quint8 { Unknown = 0, Charging = 1, Discharging = 2, @@ -44,7 +44,7 @@ class UPowerDeviceType: public QObject { QML_SINGLETON; public: - enum Enum { + enum Enum : quint8 { Unknown = 0, LinePower = 1, Battery = 2, diff --git a/src/wayland/hyprland/global_shortcuts/qml.cpp b/src/wayland/hyprland/global_shortcuts/qml.cpp index 9442337..1faa724 100644 --- a/src/wayland/hyprland/global_shortcuts/qml.cpp +++ b/src/wayland/hyprland/global_shortcuts/qml.cpp @@ -6,7 +6,6 @@ #include #include "manager.hpp" -#include "shortcut.hpp" namespace qs::hyprland::global_shortcuts { using impl::GlobalShortcutManager; diff --git a/src/wayland/wlr_layershell/window.hpp b/src/wayland/wlr_layershell/window.hpp index 59711b5..050caf6 100644 --- a/src/wayland/wlr_layershell/window.hpp +++ b/src/wayland/wlr_layershell/window.hpp @@ -15,7 +15,7 @@ namespace WlrLayer { // NOLINT Q_NAMESPACE; QML_ELEMENT; -enum Enum { +enum Enum : quint8 { /// Below bottom Background = 0, /// Above background, usually below windows @@ -36,7 +36,7 @@ namespace WlrKeyboardFocus { // NOLINT Q_NAMESPACE; QML_ELEMENT; -enum Enum { +enum Enum : quint8 { /// No keyboard input will be accepted. None = 0, /// Exclusive access to the keyboard, locking out all other windows. diff --git a/src/window/panelinterface.hpp b/src/window/panelinterface.hpp index ada01a7..6f8d1ec 100644 --- a/src/window/panelinterface.hpp +++ b/src/window/panelinterface.hpp @@ -2,6 +2,7 @@ #include #include +#include #include "../core/doc.hpp" #include "windowinterface.hpp" @@ -63,7 +64,7 @@ namespace ExclusionMode { // NOLINT Q_NAMESPACE; QML_ELEMENT; -enum Enum { +enum Enum : quint8 { /// Respect the exclusion zone of other shell layers and optionally set one Normal = 0, /// Ignore exclusion zones of other shell layers. You cannot set an exclusion zone in this mode.