Skip to content

Commit 2c411fc

Browse files
committed
all: fix new lints
1 parent 26d443a commit 2c411fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+352
-317
lines changed

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Checks: >
77
-bugprone-easily-swappable-parameters,
88
-bugprone-forward-declararion-namespace,
99
-bugprone-forward-declararion-namespace,
10+
-bugprone-return-const-ref-from-parameter,
1011
concurrency-*,
1112
cppcoreguidelines-*,
1213
-cppcoreguidelines-owning-memory,
@@ -44,6 +45,7 @@ Checks: >
4445
-readability-container-data-pointer,
4546
-readability-implicit-bool-conversion,
4647
-readability-avoid-nested-conditional-operator,
48+
-readability-math-missing-parentheses,
4749
tidyfox-*,
4850
CheckOptions:
4951
performance-for-range-copy.WarnOnAllAutoCopies: true

Justfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ fmt:
44
find src -type f \( -name "*.cpp" -o -name "*.hpp" \) -print0 | xargs -0 clang-format -i
55

66
lint:
7-
find src -type f -name "*.cpp" -print0 | parallel -q0 --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}
7+
find src -type f -name "*.cpp" -print0 | parallel -j$(nproc) -q0 --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}
88

99
lint-ci:
10-
find src -type f -name "*.cpp" -print0 | parallel -q0 --no-notice --will-cite --tty clang-tidy --load={{ env_var("TIDYFOX") }}
10+
find src -type f -name "*.cpp" -print0 | parallel -j$(nproc) -q0 --no-notice --will-cite --tty clang-tidy --load={{ env_var("TIDYFOX") }}
1111

1212
lint-changed:
13-
git diff --name-only HEAD | grep "^.*\.cpp\$" | parallel --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}
13+
git diff --name-only HEAD | grep "^.*\.cpp\$" | parallel -j$(nproc) --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}
1414

1515
configure target='debug' *FLAGS='':
1616
cmake -GNinja -B {{builddir}} \

src/core/desktopentry.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
#include "model.hpp"
2020

21+
namespace {
2122
Q_LOGGING_CATEGORY(logDesktopEntry, "quickshell.desktopentry", QtWarningMsg);
23+
}
2224

2325
struct Locale {
2426
explicit Locale() = default;
@@ -78,6 +80,7 @@ struct Locale {
7880
QString modifier;
7981
};
8082

83+
// NOLINTNEXTLINE(misc-use-internal-linkage)
8184
QDebug operator<<(QDebug debug, const Locale& locale) {
8285
auto saver = QDebugStateSaver(debug);
8386
debug.nospace() << "Locale(language=" << locale.language << ", territory=" << locale.territory

src/core/iconimageprovider.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "iconimageprovider.hpp"
2+
#include <algorithm>
23

34
#include <qcolor.h>
45
#include <qicon.h>
@@ -49,8 +50,8 @@ IconImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& re
4950
QPixmap IconImageProvider::missingPixmap(const QSize& size) {
5051
auto width = size.width() % 2 == 0 ? size.width() : size.width() + 1;
5152
auto height = size.height() % 2 == 0 ? size.height() : size.height() + 1;
52-
if (width < 2) width = 2;
53-
if (height < 2) height = 2;
53+
width = std::max(width, 2);
54+
height = std::max(height, 2);
5455

5556
auto pixmap = QPixmap(width, height);
5657
pixmap.fill(QColorConstants::Black);

src/core/imageprovider.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,21 @@
88
#include <qpixmap.h>
99
#include <qqmlengine.h>
1010

11-
static QMap<QString, QsImageHandle*> liveImages; // NOLINT
11+
namespace {
12+
13+
QMap<QString, QsImageHandle*> liveImages; // NOLINT
14+
15+
void parseReq(const QString& req, QString& target, QString& param) {
16+
auto splitIdx = req.indexOf('/');
17+
if (splitIdx != -1) {
18+
target = req.sliced(0, splitIdx);
19+
param = req.sliced(splitIdx + 1);
20+
} else {
21+
target = req;
22+
}
23+
}
24+
25+
} // namespace
1226

1327
QsImageHandle::QsImageHandle(QQmlImageProviderBase::ImageType type, QObject* parent)
1428
: QObject(parent)
@@ -43,16 +57,6 @@ QPixmap QsImageHandle::
4357
return QPixmap();
4458
}
4559

46-
void parseReq(const QString& req, QString& target, QString& param) {
47-
auto splitIdx = req.indexOf('/');
48-
if (splitIdx != -1) {
49-
target = req.sliced(0, splitIdx);
50-
param = req.sliced(splitIdx + 1);
51-
} else {
52-
target = req;
53-
}
54-
}
55-
5660
QImage QsImageProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize) {
5761
QString target;
5862
QString param;

src/core/module.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ headers = [
2828
"types.hpp",
2929
"qsmenuanchor.hpp",
3030
"clock.hpp",
31+
"scriptmodel.hpp",
3132
]
3233
-----

src/core/paths.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
#include "instanceinfo.hpp"
1717

18+
namespace {
1819
Q_LOGGING_CATEGORY(logPaths, "quickshell.paths", QtWarningMsg);
20+
}
1921

2022
QsPaths* QsPaths::instance() {
2123
static auto* instance = new QsPaths(); // NOLINT

src/core/plugin.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@ static QVector<QsEnginePlugin*> plugins; // NOLINT
1010
void QsEnginePlugin::registerPlugin(QsEnginePlugin& plugin) { plugins.push_back(&plugin); }
1111

1212
void QsEnginePlugin::initPlugins() {
13-
plugins.erase(
14-
std::remove_if(
15-
plugins.begin(),
16-
plugins.end(),
17-
[](QsEnginePlugin* plugin) { return !plugin->applies(); }
18-
),
19-
plugins.end()
20-
);
21-
22-
std::sort(plugins.begin(), plugins.end(), [](QsEnginePlugin* a, QsEnginePlugin* b) {
13+
plugins.removeIf([](QsEnginePlugin* plugin) { return !plugin->applies(); });
14+
15+
std::ranges::sort(plugins, [](QsEnginePlugin* a, QsEnginePlugin* b) {
2316
return b->dependencies().contains(a->name());
2417
});
2518

src/core/popupanchor.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "popupanchor.hpp"
2+
#include <algorithm>
23

34
#include <qcontainerfwd.h>
45
#include <qlogging.h>
@@ -276,19 +277,15 @@ void PopupPositioner::reposition(PopupAnchor* anchor, QWindow* window, bool only
276277
effectiveX = screenGeometry.right() - windowGeometry.width() + 1;
277278
}
278279

279-
if (effectiveX < screenGeometry.left()) {
280-
effectiveX = screenGeometry.left();
281-
}
280+
effectiveX = std::max(effectiveX, screenGeometry.left());
282281
}
283282

284283
if (adjustment.testFlag(PopupAdjustment::SlideY)) {
285284
if (effectiveY + windowGeometry.height() > screenGeometry.bottom()) {
286285
effectiveY = screenGeometry.bottom() - windowGeometry.height() + 1;
287286
}
288287

289-
if (effectiveY < screenGeometry.top()) {
290-
effectiveY = screenGeometry.top();
291-
}
288+
effectiveY = std::max(effectiveY, screenGeometry.top());
292289
}
293290

294291
if (adjustment.testFlag(PopupAdjustment::ResizeX)) {

src/core/test/scriptmodel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ bool ModelOperation::operator==(const ModelOperation& other) const {
2222
&& other.length == this->length && other.destIndex == this->destIndex;
2323
}
2424

25+
// NOLINTNEXTLINE(misc-use-internal-linkage)
2526
QDebug& operator<<(QDebug& debug, const ModelOperation& op) {
2627
auto saver = QDebugStateSaver(debug);
2728
debug.nospace();
@@ -43,6 +44,7 @@ QDebug& operator<<(QDebug& debug, const ModelOperation& op) {
4344
return debug;
4445
}
4546

47+
// NOLINTNEXTLINE(misc-use-internal-linkage)
4648
QDebug& operator<<(QDebug& debug, const QVariantList& list) {
4749
auto str = QString();
4850

0 commit comments

Comments
 (0)