From fe594e874242fcc55c16cec1ba7c0b5d660fe7e2 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 23 Feb 2021 20:57:37 +0200 Subject: [PATCH] Run clang-format on all cpp/h files NO_CHANGELOG --- CMakeLists.txt | 2 +- autotests/dupetest.cpp | 13 +++------- autotests/newlinetest.cpp | 8 ++---- autotests/scalabletest.cpp | 51 ++++++++++++++++++++------------------ autotests/symlinktest.cpp | 18 +++++--------- qrcAlias.cpp | 22 ++++++++-------- 6 files changed, 51 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e84af963..dacbcd10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,4 +143,4 @@ kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT) # Remove these 3 lines when the ECM version is bumped to 5.80 include(KDEClangFormat) file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h) -kde_clang_format() +kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES}) diff --git a/autotests/dupetest.cpp b/autotests/dupetest.cpp index e1a83ba7..95328f51 100644 --- a/autotests/dupetest.cpp +++ b/autotests/dupetest.cpp @@ -19,9 +19,9 @@ */ #include -#include -#include #include +#include +#include #include "testhelpers.h" @@ -55,8 +55,7 @@ class DupeTest : public QObject QString line; while (proc.canReadLine() || proc.waitForReadyRead()) { line = proc.readLine(); - failListContent(splitOnUnescapedSpace(line.simplified()), - "The following files are duplicates but not links:\n"); + failListContent(splitOnUnescapedSpace(line.simplified()), "The following files are duplicates but not links:\n"); } } @@ -64,11 +63,7 @@ class DupeTest : public QObject { QProcess proc; proc.setProgram(QStringLiteral("fdupes")); - proc.setArguments(QStringList() - << QStringLiteral("--recurse") - << QStringLiteral("--sameline") - << QStringLiteral("--nohidden") - << path); + proc.setArguments(QStringList() << QStringLiteral("--recurse") << QStringLiteral("--sameline") << QStringLiteral("--nohidden") << path); proc.start(); proc.waitForStarted(); readLines(proc); diff --git a/autotests/newlinetest.cpp b/autotests/newlinetest.cpp index 9407f570..3187755c 100644 --- a/autotests/newlinetest.cpp +++ b/autotests/newlinetest.cpp @@ -33,19 +33,15 @@ private Q_SLOTS: void test_whitespace() { QList brokenFiles; - QDirIterator it(PROJECT_SOURCE_DIR, - QDir::Files | QDir::System, - QDirIterator::Subdirectories); + QDirIterator it(PROJECT_SOURCE_DIR, QDir::Files | QDir::System, QDirIterator::Subdirectories); while (it.hasNext()) { it.next(); if (it.fileName().simplified() != it.fileName()) { brokenFiles << it.filePath(); } } - failListContent(brokenFiles, - QStringLiteral("Found file with bad characters (http://doc.qt.io/qt-5/qstring.html#simplified):\n")); + failListContent(brokenFiles, QStringLiteral("Found file with bad characters (http://doc.qt.io/qt-5/qstring.html#simplified):\n")); } - }; QTEST_GUILESS_MAIN(NewlineTest) diff --git a/autotests/scalabletest.cpp b/autotests/scalabletest.cpp index 2f6352bf..eb2b0f68 100644 --- a/autotests/scalabletest.cpp +++ b/autotests/scalabletest.cpp @@ -19,17 +19,17 @@ License along with this library. If not, see . */ +#include #include #include -#include -#include // parsing the ini files as desktop files #include "testhelpers.h" +#include // parsing the ini files as desktop files // lift a bit of code from KIconLoader to get the unit test running without tier 3 libraries class KIconLoaderDummy : public QObject { -Q_OBJECT + Q_OBJECT public: enum Context { Any, @@ -55,7 +55,6 @@ public: Q_ENUM(Type) }; - /** * Represents icon directory to conduct simple icon lookup within. */ @@ -63,8 +62,7 @@ class Dir { public: Dir(const QSettings &cg, const QString &themeDir_) - : - themeDir(themeDir_) + : themeDir(themeDir_) , path(cg.group()) , size(cg.value("Size", 0).toInt()) , contextString(cg.value("Context", QString()).toString()) @@ -74,7 +72,10 @@ public: QVERIFY2(!contextString.isEmpty(), QString("Missing 'Context' key in file %1, config group '[%2]'").arg(cg.fileName(), cg.group()).toLatin1().constData()); QVERIFY2(context != -1, - QString("Don't know how to handle 'Context=%1' in file %2, config group '[%3]'").arg(contextString, cg.fileName(), cg.group()).toLatin1().constData()); + QString("Don't know how to handle 'Context=%1' in file %2, config group '[%3]'") + .arg(contextString, cg.fileName(), cg.group()) + .toLatin1() + .constData()); } static QMetaEnum findEnum(const char *name) @@ -99,17 +100,17 @@ public: static KIconLoaderDummy::Context parseContext(const QString &string) { // Can't use QMetaEnum as the enum names are singular, the entry values are plural though. - static QHash hash { - { QStringLiteral("Actions"), KIconLoaderDummy::Action }, - { QStringLiteral("Animations"), KIconLoaderDummy::Animation }, - { QStringLiteral("Applications"), KIconLoaderDummy::Application }, - { QStringLiteral("Categories"), KIconLoaderDummy::Category }, - { QStringLiteral("Devices"), KIconLoaderDummy::Device }, - { QStringLiteral("Emblems"), KIconLoaderDummy::Emblem }, - { QStringLiteral("Emotes"), KIconLoaderDummy::Emote }, - { QStringLiteral("MimeTypes"), KIconLoaderDummy::MimeType }, - { QStringLiteral("Places"), KIconLoaderDummy::Place }, - { QStringLiteral("Status"), KIconLoaderDummy::StatusIcon }, + static QHash hash{ + {QStringLiteral("Actions"), KIconLoaderDummy::Action}, + {QStringLiteral("Animations"), KIconLoaderDummy::Animation}, + {QStringLiteral("Applications"), KIconLoaderDummy::Application}, + {QStringLiteral("Categories"), KIconLoaderDummy::Category}, + {QStringLiteral("Devices"), KIconLoaderDummy::Device}, + {QStringLiteral("Emblems"), KIconLoaderDummy::Emblem}, + {QStringLiteral("Emotes"), KIconLoaderDummy::Emote}, + {QStringLiteral("MimeTypes"), KIconLoaderDummy::MimeType}, + {QStringLiteral("Places"), KIconLoaderDummy::Place}, + {QStringLiteral("Status"), KIconLoaderDummy::StatusIcon}, }; const auto value = hash.value(string, -1); return static_cast(value); // the caller will check that it wasn't -1 @@ -179,8 +180,12 @@ private Q_SLOTS: QVERIFY(!directoryPaths.isEmpty()); for (auto directoryPath : directoryPaths) { config.beginGroup(directoryPath); - QVERIFY2(keys.contains(directoryPath+"/Size"),QString("The theme %1 has an entry 'Directories' which specifies '%2' as directory, but there's no" - " have no associated entry '%2/Size'").arg(themeDir + "/index.theme", directoryPath).toLatin1().constData()); + QVERIFY2(keys.contains(directoryPath + "/Size"), + QString("The theme %1 has an entry 'Directories' which specifies '%2' as directory, but there's no" + " have no associated entry '%2/Size'") + .arg(themeDir + "/index.theme", directoryPath) + .toLatin1() + .constData()); auto dir = QSharedPointer::create(config, themeDir); config.endGroup(); contextHash[dir->context].append(dir); @@ -261,9 +266,7 @@ private Q_SLOTS: return; } notScalableIcons.removeDuplicates(); - QFAIL(QString("The following icons are not available in a scalable directory:\n %1") - .arg(notScalableIcons.join("\n ")) - .toLatin1().constData()); + QFAIL(QString("The following icons are not available in a scalable directory:\n %1").arg(notScalableIcons.join("\n ")).toLatin1().constData()); } void test_scalableDuplicates_data() @@ -297,7 +300,7 @@ private Q_SLOTS: } QHash> duplicatedScalableIcons; - for (auto icon: scalableIcons.keys()) { + for (auto icon : scalableIcons.keys()) { auto list = scalableIcons[icon]; if (list.size() > 1) { duplicatedScalableIcons[icon] = list; diff --git a/autotests/symlinktest.cpp b/autotests/symlinktest.cpp index 69262c97..26495f9a 100644 --- a/autotests/symlinktest.cpp +++ b/autotests/symlinktest.cpp @@ -40,9 +40,7 @@ private Q_SLOTS: // By default broken symlinks are not listed unless the System filter // is used. System may however also include pipes and the like, so we // still manually need to filter for symlinks afterwards. - QDirIterator it(PROJECT_SOURCE_DIR, - QDir::System, - QDirIterator::Subdirectories); + QDirIterator it(PROJECT_SOURCE_DIR, QDir::System, QDirIterator::Subdirectories); QList brokenSymLinks; while (it.hasNext()) { it.next(); @@ -57,29 +55,25 @@ private Q_SLOTS: } brokenSymLinks << info; } - failSymlinkList(brokenSymLinks, - QStringLiteral("Found broken symlinks:\n")); + failSymlinkList(brokenSymLinks, QStringLiteral("Found broken symlinks:\n")); } // Symlinks should never point to something outside the tree, even if valid! void test_outOfTree() { - QDirIterator it(PROJECT_SOURCE_DIR, - QDir::AllEntries, - QDirIterator::Subdirectories); + QDirIterator it(PROJECT_SOURCE_DIR, QDir::AllEntries, QDirIterator::Subdirectories); QList OOTSymLinks; while (it.hasNext()) { it.next(); auto info = it.fileInfo(); - if (!info.isSymLink() || - info.symLinkTarget().startsWith(PROJECT_SOURCE_DIR)) { + if (!info.isSymLink() || info.symLinkTarget().startsWith(PROJECT_SOURCE_DIR)) { continue; } OOTSymLinks << info; } - failSymlinkList(OOTSymLinks, - QStringLiteral("Found out-of-tree symlinks:\n")); + failSymlinkList(OOTSymLinks, QStringLiteral("Found out-of-tree symlinks:\n")); } + private: QString m_buildDir; }; diff --git a/qrcAlias.cpp b/qrcAlias.cpp index 5570b39f..596b5b46 100644 --- a/qrcAlias.cpp +++ b/qrcAlias.cpp @@ -16,13 +16,13 @@ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ +#include #include +#include #include #include -#include #include -#include -#include +#include QString link(const QString &path, const QString &fileName) { @@ -46,11 +46,11 @@ QString link(const QString &path, const QString &fileName) QFileInfo linkInfo(path + QLatin1Char('/') + match.captured(1)); QString aliasLink = link(linkInfo.path(), linkInfo.fileName()); if (!aliasLink.isEmpty()) { - //qDebug() << fileName << "=" << match.captured(1) << "=" << aliasLink; + // qDebug() << fileName << "=" << match.captured(1) << "=" << aliasLink; return aliasLink; } - return path + QLatin1Char('/') + match.captured(1); + return path + QLatin1Char('/') + match.captured(1); } int parseFile(const QString &infile, const QString &outfile) @@ -72,7 +72,7 @@ int parseFile(const QString &infile, const QString &outfile) QString line = QString::fromLocal8Bit(in.readLine()); QRegularExpressionMatch match = imageReg.match(line); if (!match.hasMatch()) { - //qDebug() << "No Match: " << line; + // qDebug() << "No Match: " << line; out.write(qPrintable(line)); continue; } @@ -81,13 +81,13 @@ int parseFile(const QString &infile, const QString &outfile) QString aliasLink = link(info.path(), info.fileName()); if (aliasLink.isEmpty()) { - //qDebug() << "No alias: " << line; + // qDebug() << "No alias: " << line; out.write(qPrintable(line)); continue; } QString newLine = QStringLiteral("%2\n").arg(match.captured(1), aliasLink); - //qDebug() << newLine; + // qDebug() << newLine; out.write(qPrintable(newLine)); } return 0; @@ -103,9 +103,9 @@ int main(int argc, char *argv[]) QCommandLineOption outOption(QStringList() << QLatin1String("o") << QLatin1String("outfile"), QStringLiteral("Output qrc file"), QStringLiteral("outfile")); parser.setApplicationDescription( QLatin1String("On Windows git handles symbolic links by converting them " - "to text files containing the links to the actual file. This application " - "takes a .qrc file as input and outputs a .qrc file with the symbolic " - "links converted to qrc-aliases.")); + "to text files containing the links to the actual file. This application " + "takes a .qrc file as input and outputs a .qrc file with the symbolic " + "links converted to qrc-aliases.")); parser.addHelpOption(); parser.addVersionOption(); parser.addOption(inOption);