From f471e1d5a9ef588bf4823279303668e81c97044a Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Sat, 13 Nov 2021 20:54:54 +0300 Subject: Fix Clang-Tidy & Clazy 'clazy-qfileinfo-exists' warnings This patch fixes the "Use the static QFileInfo::exists() instead. It's documented to be faster. [clazy-qfileinfo-exists]" warnings. Change-Id: I64aa7179202674048306e1ed3d327d143e1a0ea9 Reviewed-by: Christian Kandeler --- src/app/qbs/status.cpp | 2 +- src/lib/corelib/tools/clangclinfo.cpp | 6 +++--- src/lib/corelib/tools/settingscreator.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/qbs/status.cpp b/src/app/qbs/status.cpp index a5e0c8228..127d26a50 100644 --- a/src/app/qbs/status.cpp +++ b/src/app/qbs/status.cpp @@ -146,7 +146,7 @@ int printStatus(const ProjectData &project) QStringList sourceFiles = group.allFilePaths(); std::sort(sourceFiles.begin(), sourceFiles.end()); for (const QString &sourceFile : qAsConst(sourceFiles)) { - if (!QFileInfo(sourceFile).exists()) + if (!QFileInfo::exists(sourceFile)) missingFiles.push_back(sourceFile); qbsInfo() << " " << sourceFile.mid(projectDirectoryPathLength + 1); untrackedFilesInProject.removeOne(sourceFile); diff --git a/src/lib/corelib/tools/clangclinfo.cpp b/src/lib/corelib/tools/clangclinfo.cpp index 0090b8f2c..36845da6d 100644 --- a/src/lib/corelib/tools/clangclinfo.cpp +++ b/src/lib/corelib/tools/clangclinfo.cpp @@ -122,7 +122,7 @@ std::vector ClangClInfo::installedCompilers( if (registry.contains(key)) { const auto compilerPath = QDir::fromNativeSeparators(registry.value(key).toString()) + QStringLiteral("/bin/") + compilerName; - if (QFileInfo(compilerPath).exists()) + if (QFileInfo::exists(compilerPath)) compilerPaths.push_back(compilerPath); } @@ -133,7 +133,7 @@ std::vector ClangClInfo::installedCompilers( const auto value = QDir::fromNativeSeparators(QString::fromLocal8Bit(qgetenv(envVar))); const auto compilerPath = value + QStringLiteral("/LLVM/bin/") + compilerName; - if (QFileInfo(compilerPath).exists() && !contains(compilerPaths, compilerPath)) + if (QFileInfo::exists(compilerPath) && !contains(compilerPaths, compilerPath)) compilerPaths.push_back(compilerPath); } @@ -156,7 +156,7 @@ std::vector ClangClInfo::installedCompilers( for (const auto &msvc : msvcs) { const auto compilerPath = QStringLiteral("%1/VC/Tools/Llvm/bin/%2") .arg(msvc.installDir, compilerName); - if (QFileInfo(compilerPath).exists()) { + if (QFileInfo::exists(compilerPath)) { const auto vcvarsallPath = msvc.findVcvarsallBat(); if (vcvarsallPath.isEmpty()) { logger.qbsWarning() diff --git a/src/lib/corelib/tools/settingscreator.cpp b/src/lib/corelib/tools/settingscreator.cpp index 455e35b34..f94ae6f10 100644 --- a/src/lib/corelib/tools/settingscreator.cpp +++ b/src/lib/corelib/tools/settingscreator.cpp @@ -85,7 +85,7 @@ void SettingsCreator::migrate() if (thePredecessor.isValid()) oldSettingsDir.append(QLatin1String("/qbs/")).append(thePredecessor.toString()); const QString oldSettingsFilePath = oldSettingsDir + QLatin1Char('/') + m_settingsFileName; - if (QFileInfo(oldSettingsFilePath).exists() + if (QFileInfo::exists(oldSettingsFilePath) && (!QDir::root().mkpath(m_newSettingsDir) || !QFile::copy(oldSettingsFilePath, m_newSettingsFilePath))) { qWarning() << "Error in settings migration: Could not copy" << oldSettingsFilePath -- cgit v1.2.1