| 92 | } |
| 93 | |
| 94 | QUrl JobGlobalParameters::defaultDocsPath() |
| 95 | { |
| 96 | const auto urlOfDir = [](const QDir& dir) { |
| 97 | return QUrl::fromLocalFile(dir.canonicalPath()); |
| 98 | }; |
| 99 | |
| 100 | std::optional<QDir> firstDocsDir; |
| 101 | |
| 102 | const QString subPathsCandidates[2]{ |
| 103 | // since clazy 1.4 |
| 104 | QStringLiteral("doc/clazy"), |
| 105 | // before |
| 106 | QStringLiteral("clazy/doc"), |
| 107 | }; |
| 108 | for (auto subPath : subPathsCandidates) { |
| 109 | const auto docsPaths = |
| 110 | QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, subPath, QStandardPaths::LocateDirectory); |
| 111 | for (const auto& path : docsPaths) { |
| 112 | static const auto readmeFileName = QStringLiteral("README.md"); |
| 113 | static const auto checksFileName = QStringLiteral("checks.json"); |
| 114 | |
| 115 | QDir dir(path); |
| 116 | // These two files are usually present in the installed directory doc/clazy. If not, the directory |
| 117 | // might be a leftover from an uninstalled clazy version, so check other possible candidates. |
| 118 | if (dir.exists(readmeFileName) || dir.exists(checksFileName)) { |
| 119 | qCDebug(KDEV_CLAZY) << "detected documentation path:" << path; |
| 120 | return urlOfDir(dir); |
| 121 | } |
| 122 | qCDebug(KDEV_CLAZY) << "candidate documentation path" << path << "does not contain indicator files" |
| 123 | << readmeFileName << "and" << checksFileName; |
| 124 | if (!firstDocsDir) { |
| 125 | firstDocsDir = std::move(dir); |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | if (firstDocsDir) { |
| 131 | qCWarning(KDEV_CLAZY) << "falling back to the first candidate documentation path" << firstDocsDir->path() |
| 132 | << "even though it does not contain indicator files"; |
| 133 | return urlOfDir(*firstDocsDir); |
| 134 | } |
| 135 | return {}; |
| 136 | } |
| 137 | |
| 138 | bool JobGlobalParameters::isValid() const |
| 139 | { |
nothing calls this directly
no test coverage detected