MCPcopy Create free account
hub / github.com/KDE/kdevelop / ChecksDB

Method ChecksDB

plugins/clazy/checksdb.cpp:20–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18{
19
20ChecksDB::ChecksDB(const QUrl& docsPath)
21{
22 static const QHash<QString, QString> levelName = {
23 { QStringLiteral("manuallevel"), QStringLiteral("manual") },
24 { QStringLiteral("hiddenlevel"), QStringLiteral("manual") }
25 };
26
27 static const QHash<QString, QString> levelDisplayName = {
28 { QStringLiteral("level0"), i18nc("@item level of checks", "Level 0") },
29 { QStringLiteral("level1"), i18nc("@item level of checks", "Level 1") },
30 { QStringLiteral("level2"), i18nc("@item level of checks", "Level 2") },
31 { QStringLiteral("level3"), i18nc("@item level of checks", "Level 3") },
32 { QStringLiteral("manual"), i18nc("@item level of checks", "Manual Level") }
33 };
34
35 static const QHash<QString, QString> levelDescription = {
36 { QStringLiteral("level0"),
37 i18n("Very stable checks, 99.99% safe, mostly no false-positives, very desirable.") },
38
39 { QStringLiteral("level1"),
40 i18n("The default level. Very similar to level 0, slightly more false-positives but very few.") },
41
42 { QStringLiteral("level2"),
43 i18n("Also very few false-positives, but contains noisy checks which not everyone agree should be default.") },
44
45 { QStringLiteral("level3"),
46 i18n("Contains checks with high rate of false-positives.") },
47
48 { QStringLiteral("manual"),
49 i18n("Checks here need to be enabled explicitly, as they don't belong to any level. "
50 "Checks here are very stable and have very few false-positives.") }
51 };
52
53 const QString defaultError = i18n(
54 "Unable to load Clazy checks information from '%1'. Please check your settings.",
55 docsPath.toLocalFile());
56
57 QDir docsDir(docsPath.toLocalFile());
58 if (!docsDir.exists()) {
59 m_error = defaultError;
60 return;
61 }
62
63 const QRegularExpression levelRE(QStringLiteral(".*level.*"));
64 const QRegularExpression checkRE(QStringLiteral("^README-(.+)\\.md$"));
65
66 const auto levelsDirs = docsDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
67 for (const auto& levelDir : levelsDirs) {
68 if (!levelRE.match(levelDir).hasMatch()) {
69 continue;
70 }
71
72 if (!docsDir.cd(levelDir)) {
73 continue;
74 }
75
76 auto level = new Level;
77 level->name = levelName.value(levelDir, levelDir);

Callers

nothing calls this directly

Calls 9

markdown2htmlFunction · 0.85
toLocalFileMethod · 0.80
existsMethod · 0.80
hasMatchMethod · 0.80
cdMethod · 0.80
matchMethod · 0.45
valueMethod · 0.45
openMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected