Skip to content

Commit

Permalink
chore: Speed up clang-tidy run using clangd.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Jan 11, 2025
1 parent 4891a05 commit 8dd3d55
Show file tree
Hide file tree
Showing 15 changed files with 634 additions and 148 deletions.
9 changes: 1 addition & 8 deletions .ci-scripts/build-qtox-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,7 @@ cmake --build "$BUILD_DIR"
ccache --show-stats

if [ ! -z "${TIDY+x}" ]; then
run-clang-tidy -quiet -fix -format -p "$BUILD_DIR" \
audio/include \
audio/src/ \
src/ \
test/include \
test/src/ \
util/include/ \
util/src/
tools/lsp_tidy.py --compile-commands-dir "$BUILD_DIR"
else
ctest -j"$(nproc)" --test-dir "$BUILD_DIR" --output-on-failure
fi
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ Checks: "-*
, readability-inconsistent-declaration-parameter-name
"
WarningsAsErrors: "*"
ExcludeHeaderFilterRegex: "/usr/.*"
HeaderFilterRegex: ".*"
5 changes: 4 additions & 1 deletion .github/workflows/build-test-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ jobs:
- name: Cache compiler output
uses: actions/cache@v4
with:
path: ".cache/ccache"
path: |
.cache/ccache
.cache/clangd
.lsp_tidy_cache
key: ${{ github.job }}-ccache
- name: Run build
run: docker compose run --rm fedora .ci-scripts/build-qtox-linux.sh --build-type Release --full --tidy || (git diff --exit-code && false)
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ target/

# IDE support
/compile_commands.json
/.lsp_tidy_cache
2 changes: 2 additions & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ words:
- "chatformheader"
- "chatlist"
- "citri"
- "clangd"
- "codecpar"
- "codepoint"
- "codepoints"
Expand Down Expand Up @@ -102,6 +103,7 @@ words:
- "frnd"
- "gdigrab"
- "generalform"
- "getpid"
- "gfrm"
- "gitter"
- "gpgsign"
Expand Down
2 changes: 1 addition & 1 deletion src/model/notificationgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ QString generateContent(const QHash<const Friend*, size_t>& friendNotifications,
const QHash<const Conference*, size_t>& conferenceNotifications,
QString lastMessage, const ToxPk& sender)
{
assert(friendNotifications.size() > 0 || conferenceNotifications.size() > 0);
assert(!friendNotifications.empty() || !conferenceNotifications.empty());

auto numChats = getNumChats(friendNotifications, conferenceNotifications);
if (numChats > 1) {
Expand Down
11 changes: 5 additions & 6 deletions src/nexus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,14 @@ void Nexus::updateWindowsArg(QWindow* closedWindow)
else
activeWindow = nullptr;

for (int i = 0; i < windowList.size(); ++i) {
if (closedWindow == windowList[i])
for (auto& i : windowList) {
if (closedWindow == i)
continue;

QAction* action = windowActions->addAction(windowList[i]->title());
QAction* action = windowActions->addAction(i->title());
action->setCheckable(true);
action->setChecked(windowList[i] == activeWindow);
connect(action, &QAction::triggered, this,
[this, window = windowList[i]] { onOpenWindow(window); });
action->setChecked(i == activeWindow);
connect(action, &QAction::triggered, this, [this, window = i] { onOpenWindow(window); });
windowMenu->addAction(action);
dockMenu->insertAction(dockLast, action);
}
Expand Down
36 changes: 18 additions & 18 deletions src/platform/camera/avfoundation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,26 @@
if (index >= [devices count]) {
// It's a desktop capture.
return result;
} else {
AVCaptureDevice* device = [devices objectAtIndex:index];
}

if (device == nil) {
qWarning() << "Device not found:" << devName;
return result;
}
AVCaptureDevice* device = [devices objectAtIndex:index];

if (device == nil) {
qWarning() << "Device not found:" << devName;
return result;
}

for (AVCaptureDeviceFormat* format in [device formats]) {
CMFormatDescriptionRef formatDescription = static_cast<CMFormatDescriptionRef>(
[format performSelector:@selector(formatDescription)]);
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);

for (AVFrameRateRange* range in format.videoSupportedFrameRateRanges) {
VideoMode mode;
mode.width = dimensions.width;
mode.height = dimensions.height;
mode.fps = range.maxFrameRate;
result.append(mode);
}
for (AVCaptureDeviceFormat* format in [device formats]) {
CMFormatDescriptionRef formatDescription = static_cast<CMFormatDescriptionRef>(
[format performSelector:@selector(formatDescription)]);
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);

for (AVFrameRateRange* range in format.videoSupportedFrameRateRanges) {
VideoMode mode;
mode.width = dimensions.width;
mode.height = dimensions.height;
mode.fps = range.maxFrameRate;
result.append(mode);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ struct DBusPortalImage
QImage image;
};

Q_DECL_UNUSED
QDBusArgument& operator<<(QDBusArgument& argument, const DBusPortalImage& image)
{
argument.beginStructure();
Expand All @@ -118,6 +119,7 @@ QDBusArgument& operator<<(QDBusArgument& argument, const DBusPortalImage& image)
return argument;
}

Q_DECL_UNUSED
const QDBusArgument& operator>>(const QDBusArgument& argument, DBusPortalImage& image)
{
QString type;
Expand All @@ -142,6 +144,7 @@ struct DBusNotifyImage
QImage image;
};

Q_DECL_UNUSED
QDBusArgument& operator<<(QDBusArgument& argument, const DBusNotifyImage& image)
{
const QImage rgba = image.image.convertToFormat(QImage::Format_RGBA8888);
Expand All @@ -157,6 +160,7 @@ QDBusArgument& operator<<(QDBusArgument& argument, const DBusNotifyImage& image)
return argument;
}

Q_DECL_UNUSED
const QDBusArgument& operator>>(const QDBusArgument& argument, DBusNotifyImage& image)
{
int width;
Expand Down
31 changes: 15 additions & 16 deletions test/model/conferencemessagedispatcher_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "src/model/conferencemessagedispatcher.h"
#include "src/model/message.h"
#include "src/persistence/iconferencesettings.h"
#include "src/persistence/settings.h"
#include "util/interface.h"

#include "mock/mockconferencequery.h"
Expand All @@ -19,6 +18,7 @@
#include <QtTest/QtTest>

#include <deque>
#include <memory>
#include <set>

#include <tox/tox.h> // tox_max_message_length
Expand Down Expand Up @@ -140,19 +140,18 @@ TestConferenceMessageDispatcher::TestConferenceMessageDispatcher() = default;
*/
void TestConferenceMessageDispatcher::init()
{
friendList = std::unique_ptr<FriendList>(new FriendList());
conferenceSettings = std::unique_ptr<MockConferenceSettings>(new MockConferenceSettings());
conferenceQuery = std::unique_ptr<MockConferenceQuery>(new MockConferenceQuery());
coreIdHandler = std::unique_ptr<MockCoreIdHandler>(new MockCoreIdHandler());
g = std::unique_ptr<Conference>(new Conference(0, ConferenceId(), "TestConference", false, "me",
*conferenceQuery, *coreIdHandler, *friendList));
messageSender = std::unique_ptr<MockConferenceMessageSender>(new MockConferenceMessageSender());
sharedProcessorParams = std::unique_ptr<MessageProcessor::SharedParams>(
new MessageProcessor::SharedParams(tox_max_message_length()));
messageProcessor = std::unique_ptr<MessageProcessor>(new MessageProcessor(*sharedProcessorParams));
conferenceMessageDispatcher = std::unique_ptr<ConferenceMessageDispatcher>(
new ConferenceMessageDispatcher(*g, *messageProcessor, *coreIdHandler, *messageSender,
*conferenceSettings));
friendList = std::make_unique<FriendList>();
conferenceSettings = std::make_unique<MockConferenceSettings>();
conferenceQuery = std::make_unique<MockConferenceQuery>();
coreIdHandler = std::make_unique<MockCoreIdHandler>();
g = std::make_unique<Conference>(0, ConferenceId(), "TestConference", false, "me",
*conferenceQuery, *coreIdHandler, *friendList);
messageSender = std::make_unique<MockConferenceMessageSender>();
sharedProcessorParams = std::make_unique<MessageProcessor::SharedParams>(tox_max_message_length());
messageProcessor = std::make_unique<MessageProcessor>(*sharedProcessorParams);
conferenceMessageDispatcher =
std::make_unique<ConferenceMessageDispatcher>(*g, *messageProcessor, *coreIdHandler,
*messageSender, *conferenceSettings);

connect(conferenceMessageDispatcher.get(), &ConferenceMessageDispatcher::messageSent, this,
&TestConferenceMessageDispatcher::onMessageSent);
Expand All @@ -174,7 +173,7 @@ void TestConferenceMessageDispatcher::testSignals()
conferenceMessageDispatcher->sendMessage(false, "test");

// For conferences we pair our sent and completed signals since we have no receiver reports
QVERIFY(outgoingMessages.size() == 0);
QVERIFY(outgoingMessages.empty());
QVERIFY(!sentMessages.empty());
QVERIFY(sentMessages.front().isAction == false);
QVERIFY(sentMessages.front().content == "test");
Expand Down Expand Up @@ -227,7 +226,7 @@ void TestConferenceMessageDispatcher::testSelfReceive()
{
uint8_t selfId[ToxPk::size] = {0};
conferenceMessageDispatcher->onMessageReceived(ToxPk(selfId), false, "Test");
QVERIFY(receivedMessages.size() == 0);
QVERIFY(receivedMessages.empty());

uint8_t id[ToxPk::size] = {1};
conferenceMessageDispatcher->onMessageReceived(ToxPk(id), false, "Test");
Expand Down
14 changes: 7 additions & 7 deletions test/model/friendmessagedispatcher_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <QtTest/QtTest>

#include <deque>
#include <memory>
#include <set>

#include <tox/tox.h> // tox_max_message_length
Expand Down Expand Up @@ -112,15 +113,14 @@ TestFriendMessageDispatcher::TestFriendMessageDispatcher() = default;
*/
void TestFriendMessageDispatcher::init()
{
f = std::unique_ptr<Friend>(new Friend(0, ToxPk()));
f = std::make_unique<Friend>(0, ToxPk());
f->setStatus(Status::Status::Online);
messageSender = std::unique_ptr<MockFriendMessageSender>(new MockFriendMessageSender());
sharedProcessorParams = std::unique_ptr<MessageProcessor::SharedParams>(
new MessageProcessor::SharedParams(tox_max_message_length()));
messageSender = std::make_unique<MockFriendMessageSender>();
sharedProcessorParams = std::make_unique<MessageProcessor::SharedParams>(tox_max_message_length());

messageProcessor = std::unique_ptr<MessageProcessor>(new MessageProcessor(*sharedProcessorParams));
friendMessageDispatcher = std::unique_ptr<FriendMessageDispatcher>(
new FriendMessageDispatcher(*f, *messageProcessor, *messageSender));
messageProcessor = std::make_unique<MessageProcessor>(*sharedProcessorParams);
friendMessageDispatcher =
std::make_unique<FriendMessageDispatcher>(*f, *messageProcessor, *messageSender);

connect(friendMessageDispatcher.get(), &FriendMessageDispatcher::messageSent, this,
&TestFriendMessageDispatcher::onMessageSent);
Expand Down
11 changes: 6 additions & 5 deletions test/model/notificationgenerator_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <QObject>
#include <QtTest/QtTest>
#include <memory>

namespace {
class MockNotificationSettings : public INotificationSettings
Expand Down Expand Up @@ -131,11 +132,11 @@ private slots:

void TestNotificationGenerator::init()
{
friendList.reset(new FriendList());
notificationSettings.reset(new MockNotificationSettings());
notificationGenerator.reset(new NotificationGenerator(*notificationSettings, nullptr));
conferenceQuery.reset(new MockConferenceQuery());
coreIdHandler.reset(new MockCoreIdHandler());
friendList = std::make_unique<FriendList>();
notificationSettings = std::make_unique<MockNotificationSettings>();
notificationGenerator = std::make_unique<NotificationGenerator>(*notificationSettings, nullptr);
conferenceQuery = std::make_unique<MockConferenceQuery>();
coreIdHandler = std::make_unique<MockCoreIdHandler>();
}

void TestNotificationGenerator::testSingleFriendMessage()
Expand Down
8 changes: 4 additions & 4 deletions test/model/sessionchatlog_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "src/model/sessionchatlog.h"

#include <QtTest/QtTest>
#include <memory>

namespace {
const QString TEST_USERNAME = "qTox Tester #1";
Expand Down Expand Up @@ -66,10 +67,9 @@ private slots:
*/
void TestSessionChatLog::init()
{
friendList = std::unique_ptr<FriendList>(new FriendList());
conferenceList = std::unique_ptr<ConferenceList>(new ConferenceList());
chatLog =
std::unique_ptr<SessionChatLog>(new SessionChatLog(idHandler, *friendList, *conferenceList));
friendList = std::make_unique<FriendList>();
conferenceList = std::make_unique<ConferenceList>();
chatLog = std::make_unique<SessionChatLog>(idHandler, *friendList, *conferenceList);
}

/**
Expand Down
Loading

0 comments on commit 8dd3d55

Please sign in to comment.