MailJDTourDownloadDocsQualityTestsCoverage

Which source lines and branches the tests execute. Lines 91.5 %, branches 75.0 % (minimum 85 % and 72 %). main @ 399ffe3d · 21 October 2026 · pipeline 7238.

GCC Code Coverage Report


Directory: src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 98.1% 104 / 0 / 106
Functions: 100.0% 11 / 0 / 11
Branches: 77.7% 143 / 0 / 184

data/ComposeSettingsSync.cpp
Line Branch Exec Source
1 #include "ComposeSettingsSync.h"
2
3 #include "IdentityStore.h"
4 #include "TemplateStore.h"
5
6 #include <QJsonArray>
7 #include <QUuid>
8
9 namespace ComposeSettingsSync {
10
11 namespace {
12
13 15 QString bounded(const QJsonObject &object, const char *key, qsizetype limit) {
14
2/2
✓ Branch 3 → 4 taken 15 times.
✓ Branch 4 → 5 taken 15 times.
15 const QString value = object.value(QLatin1String(key)).toString();
15
1/2
✗ Branch 7 → 8 not taken.
✓ Branch 7 → 9 taken 15 times.
30 return value.size() > limit ? QString() : value;
16 15 }
17
18 3 bool singleLine(const QString &value) {
19
6/9
✓ Branch 4 → 5 taken 3 times.
✓ Branch 5 → 6 taken 3 times.
✗ Branch 5 → 14 not taken.
✓ Branch 8 → 9 taken 3 times.
✓ Branch 9 → 10 taken 3 times.
✗ Branch 9 → 14 not taken.
✓ Branch 11 → 12 taken 3 times.
✓ Branch 12 → 13 taken 3 times.
✗ Branch 12 → 14 not taken.
3 return !value.contains(QLatin1Char('\r')) && !value.contains(QLatin1Char('\n')) && !value.contains(QChar::Null);
20 }
21
22 8 QString signatureName(const Identity &identity, const QString &id) {
23
2/2
✓ Branch 10 → 4 taken 10 times.
✓ Branch 10 → 11 taken 2 times.
12 for (const Signature &signature : identity.signatures)
24
2/2
✓ Branch 6 → 7 taken 6 times.
✓ Branch 6 → 8 taken 4 times.
10 if (signature.id == id) return signature.name;
25 2 return {};
26 }
27
28 4 QJsonObject identityObject(const Identity &identity) {
29
1/1
✓ Branch 2 → 3 taken 4 times.
4 QJsonArray signatures;
30
2/2
✓ Branch 34 → 5 taken 6 times.
✓ Branch 34 → 35 taken 4 times.
10 for (const Signature &signature : identity.signatures)
31
1/1
✓ Branch 20 → 21 taken 6 times.
18 signatures.append(QJsonObject{{QStringLiteral("name"), signature.name},
32 12 {QStringLiteral("html"), signature.html},
33
2/4
✓ Branch 24 → 25 taken 18 times.
✓ Branch 24 → 26 taken 6 times.
✗ Branch 93 → 94 not taken.
✗ Branch 93 → 95 not taken.
36 {QStringLiteral("text"), signature.text}});
34 8 return {{QStringLiteral("name"), identity.name},
35 8 {QStringLiteral("formattedByDefault"), identity.formattedByDefault},
36 8 {QStringLiteral("wrapPlainText"), identity.wrapPlainText},
37 8 {QStringLiteral("bccSelf"), identity.bccSelf},
38 8 {QStringLiteral("signatures"), signatures},
39
1/1
✓ Branch 58 → 59 taken 4 times.
8 {QStringLiteral("newMailSignature"), signatureName(identity, identity.newMailSignatureId)},
40
3/5
✓ Branch 63 → 64 taken 4 times.
✓ Branch 67 → 68 taken 28 times.
✓ Branch 67 → 69 taken 4 times.
✗ Branch 124 → 125 not taken.
✗ Branch 124 → 126 not taken.
40 {QStringLiteral("replySignature"), signatureName(identity, identity.replySignatureId)}};
41 60 }
42
43 } // namespace
44
45 3 QString identityKey(const QString &accountAddress, const QString &accountServer, const QString &email) {
46
5/5
✓ Branch 6 → 7 taken 3 times.
✓ Branch 7 → 8 taken 3 times.
✓ Branch 8 → 9 taken 3 times.
✓ Branch 9 → 10 taken 3 times.
✓ Branch 10 → 11 taken 3 times.
3 return (accountAddress + QLatin1Char('|') + accountServer + QLatin1Char('|') + email).toLower();
47 }
48
49
2/2
✓ Branch 2 → 3 taken 8 times.
✓ Branch 3 → 4 taken 8 times.
8 QString templateKey(const QString &name) { return name.trimmed().toLower(); }
50
51 4 QMap<QString, QJsonObject> collectIdentities(const IdentityStore &store) {
52 4 QMap<QString, QJsonObject> out;
53
2/2
✓ Branch 13 → 5 taken 2 times.
✓ Branch 13 → 14 taken 4 times.
6 for (const Identity &identity : store.identities())
54
3/3
✓ Branch 6 → 7 taken 2 times.
✓ Branch 7 → 8 taken 2 times.
✓ Branch 8 → 9 taken 2 times.
2 out.insert(identityKey(identity.accountAddress, identity.accountServer, identity.email), identityObject(identity));
55 4 return out;
56 ✗ }
57
58 4 QMap<QString, QJsonObject> collectTemplates(const TemplateStore &store) {
59 4 QMap<QString, QJsonObject> out;
60
2/2
✓ Branch 40 → 5 taken 4 times.
✓ Branch 40 → 41 taken 4 times.
8 for (const MailTemplate &value : store.templates())
61
2/2
✓ Branch 23 → 24 taken 4 times.
✓ Branch 24 → 25 taken 4 times.
12 out.insert(templateKey(value.name), QJsonObject{{QStringLiteral("name"), value.name},
62 8 {QStringLiteral("subject"), value.subject},
63 8 {QStringLiteral("html"), value.html},
64
2/4
✓ Branch 28 → 29 taken 16 times.
✓ Branch 28 → 30 taken 4 times.
✗ Branch 49 → 50 not taken.
✗ Branch 49 → 51 not taken.
28 {QStringLiteral("text"), value.text}});
65 4 return out;
66 20 }
67
68 1 bool applyIdentities(IdentityStore &store, const QMap<QString, QJsonObject> &remote) {
69 1 bool changed = false;
70 1 const QList<Identity> current = store.identities(); // upsert changes the store
71
2/2
✓ Branch 182 → 6 taken 1 time.
✓ Branch 182 → 183 taken 1 time.
2 for (Identity identity : current) {
72
2/2
✓ Branch 8 → 9 taken 1 time.
✓ Branch 9 → 10 taken 1 time.
1 const auto found = remote.constFind(identityKey(identity.accountAddress, identity.accountServer, identity.email));
73
2/3
✓ Branch 11 → 12 taken 1 time.
✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 1 time.
1 if (found == remote.constEnd()) continue;
74 1 const QJsonObject object = found.value();
75
1/1
✓ Branch 17 → 18 taken 1 time.
1 const QJsonObject before = identityObject(identity);
76
2/3
✓ Branch 18 → 19 taken 1 time.
✗ Branch 19 → 20 not taken.
✓ Branch 19 → 21 taken 1 time.
1 if (object == before) continue;
77
1/1
✓ Branch 21 → 22 taken 1 time.
1 const QString name = bounded(object, "name", 200);
78
2/3
✓ Branch 22 → 23 taken 1 time.
✓ Branch 23 → 24 taken 1 time.
✗ Branch 23 → 25 not taken.
1 if (singleLine(name)) identity.name = name;
79
2/2
✓ Branch 28 → 29 taken 1 time.
✓ Branch 29 → 30 taken 1 time.
1 identity.formattedByDefault = object.value(QStringLiteral("formattedByDefault")).toBool();
80
2/2
✓ Branch 36 → 37 taken 1 time.
✓ Branch 37 → 38 taken 1 time.
1 identity.wrapPlainText = object.value(QStringLiteral("wrapPlainText")).toBool();
81
2/2
✓ Branch 44 → 45 taken 1 time.
✓ Branch 45 → 46 taken 1 time.
1 identity.bccSelf = object.value(QStringLiteral("bccSelf")).toBool();
82 // Signatures by name: an unchanged name keeps its id (a draft refers to it).
83 1 QList<Signature> signatures;
84
7/7
✓ Branch 52 → 53 taken 1 time.
✓ Branch 53 → 54 taken 1 time.
✓ Branch 57 → 58 taken 1 time.
✓ Branch 58 → 59 taken 1 time.
✓ Branch 61 → 62 taken 2 times.
✓ Branch 121 → 60 taken 2 times.
✓ Branch 121 → 122 taken 1 time.
3 for (const QJsonValue &value : object.value(QStringLiteral("signatures")).toArray()) {
85
1/2
✗ Branch 63 → 64 not taken.
✓ Branch 63 → 65 taken 2 times.
2 if (signatures.size() >= IdentityStore::MaxSignaturesPerIdentity) break;
86
1/1
✓ Branch 65 → 66 taken 2 times.
2 const QJsonObject entry = value.toObject();
87 2 Signature signature;
88
2/2
✓ Branch 66 → 67 taken 2 times.
✓ Branch 67 → 68 taken 2 times.
2 signature.name = bounded(entry, "name", 120).trimmed();
89
1/1
✓ Branch 71 → 72 taken 2 times.
2 signature.html = bounded(entry, "html", IdentityStore::MaxSignatureBytes);
90
1/1
✓ Branch 74 → 75 taken 2 times.
2 signature.text = bounded(entry, "text", IdentityStore::MaxSignatureBytes);
91
4/7
✓ Branch 78 → 79 taken 2 times.
✗ Branch 78 → 81 not taken.
✓ Branch 79 → 80 taken 2 times.
✗ Branch 80 → 81 not taken.
✓ Branch 80 → 82 taken 2 times.
✗ Branch 83 → 84 not taken.
✓ Branch 83 → 85 taken 2 times.
2 if (signature.name.isEmpty() || !singleLine(signature.name)) continue;
92
4/4
✓ Branch 85 → 86 taken 2 times.
✓ Branch 86 → 87 taken 2 times.
✓ Branch 95 → 88 taken 2 times.
✓ Branch 95 → 96 taken 2 times.
4 for (const Signature &existing : identity.signatures) {
93
2/2
✓ Branch 90 → 91 taken 1 time.
✓ Branch 90 → 92 taken 1 time.
2 if (existing.name != signature.name) continue;
94 1 signature.id = existing.id;
95 }
96
4/4
✓ Branch 97 → 98 taken 1 time.
✓ Branch 97 → 103 taken 1 time.
✓ Branch 98 → 99 taken 1 time.
✓ Branch 99 → 100 taken 1 time.
2 if (signature.id.isEmpty()) signature.id = QUuid::createUuid().toString(QUuid::WithoutBraces);
97
1/1
✓ Branch 103 → 104 taken 2 times.
2 signatures.append(signature);
98 3 }
99 1 identity.signatures = signatures;
100 2 const auto idOf = [&signatures](const QString &name) {
101
3/4
✓ Branch 2 → 3 taken 2 times.
✓ Branch 3 → 4 taken 2 times.
✓ Branch 16 → 5 taken 3 times.
✗ Branch 16 → 17 not taken.
3 for (const Signature &signature : signatures)
102
5/6
✓ Branch 7 → 8 taken 3 times.
✗ Branch 7 → 11 not taken.
✓ Branch 9 → 10 taken 2 times.
✓ Branch 9 → 11 taken 1 time.
✓ Branch 12 → 13 taken 2 times.
✓ Branch 12 → 14 taken 1 time.
3 if (!name.isEmpty() && signature.name == name) return signature.id;
103 ✗ return QString();
104 1 };
105
3/3
✓ Branch 127 → 128 taken 1 time.
✓ Branch 128 → 129 taken 1 time.
✓ Branch 129 → 130 taken 1 time.
1 identity.newMailSignatureId = idOf(object.value(QStringLiteral("newMailSignature")).toString());
106
3/3
✓ Branch 139 → 140 taken 1 time.
✓ Branch 140 → 141 taken 1 time.
✓ Branch 141 → 142 taken 1 time.
1 identity.replySignatureId = idOf(object.value(QStringLiteral("replySignature")).toString());
107
3/4
✓ Branch 148 → 149 taken 1 time.
✓ Branch 149 → 150 taken 1 time.
✗ Branch 151 → 152 not taken.
✓ Branch 151 → 153 taken 1 time.
1 if (identityObject(identity) == before) continue;
108
2/5
✓ Branch 153 → 154 taken 1 time.
✗ Branch 154 → 155 not taken.
✓ Branch 154 → 156 taken 1 time.
✗ Branch 155 → 156 not taken.
✗ Branch 155 → 157 not taken.
1 changed = store.upsert(identity) || changed;
109 1 }
110 1 return changed;
111 1 }
112
113 1 bool applyTemplates(TemplateStore &store, const QMap<QString, QJsonObject> &remote) {
114 1 bool changed = false;
115 1 QStringList stale;
116
2/2
✓ Branch 13 → 5 taken 2 times.
✓ Branch 13 → 14 taken 1 time.
3 for (const MailTemplate &value : store.templates())
117
5/5
✓ Branch 6 → 7 taken 2 times.
✓ Branch 7 → 8 taken 2 times.
✓ Branch 9 → 10 taken 1 time.
✓ Branch 9 → 11 taken 1 time.
✓ Branch 10 → 11 taken 1 time.
2 if (!remote.contains(templateKey(value.name))) stale.append(value.id);
118
6/9
✓ Branch 14 → 15 taken 1 time.
✓ Branch 15 → 16 taken 1 time.
✓ Branch 18 → 19 taken 1 time.
✗ Branch 19 → 20 not taken.
✓ Branch 19 → 21 taken 1 time.
✗ Branch 20 → 21 not taken.
✗ Branch 20 → 22 not taken.
✓ Branch 25 → 17 taken 1 time.
✓ Branch 25 → 26 taken 1 time.
2 for (const QString &id : stale) changed = store.remove(id) || changed;
119
4/4
✓ Branch 26 → 27 taken 1 time.
✓ Branch 95 → 96 taken 3 times.
✓ Branch 97 → 28 taken 2 times.
✓ Branch 97 → 98 taken 1 time.
3 for (auto it = remote.constBegin(); it != remote.constEnd(); ++it) {
120 2 MailTemplate value;
121
1/1
✓ Branch 29 → 30 taken 2 times.
2 value.name = bounded(it.value(), "name", TemplateStore::MaxNameChars);
122
1/1
✓ Branch 33 → 34 taken 2 times.
2 value.subject = bounded(it.value(), "subject", 998);
123
1/1
✓ Branch 37 → 38 taken 2 times.
2 value.html = bounded(it.value(), "html", TemplateStore::MaxTemplateBytes);
124
1/1
✓ Branch 41 → 42 taken 2 times.
2 value.text = bounded(it.value(), "text", TemplateStore::MaxTemplateBytes);
125
2/3
✓ Branch 45 → 46 taken 2 times.
✗ Branch 48 → 49 not taken.
✓ Branch 48 → 50 taken 2 times.
2 if (templateKey(value.name) != it.key()) continue;
126
1/1
✓ Branch 50 → 51 taken 2 times.
2 const auto existing = store.findByName(value.name);
127
8/12
✓ Branch 52 → 53 taken 1 time.
✓ Branch 52 → 66 taken 1 time.
✓ Branch 55 → 56 taken 1 time.
✗ Branch 55 → 66 not taken.
✓ Branch 58 → 59 taken 1 time.
✗ Branch 58 → 66 not taken.
✓ Branch 61 → 62 taken 1 time.
✗ Branch 61 → 66 not taken.
✓ Branch 64 → 65 taken 1 time.
✗ Branch 64 → 66 not taken.
✓ Branch 67 → 68 taken 1 time.
✓ Branch 67 → 69 taken 1 time.
3 if (existing && existing->name == value.name && existing->subject == value.subject && existing->html == value.html &&
128 1 existing->text == value.text)
129 1 continue;
130
1/2
✗ Branch 70 → 71 not taken.
✓ Branch 70 → 73 taken 1 time.
1 if (existing) value.id = existing->id;
131
4/13
✓ Branch 74 → 75 taken 1 time.
✗ Branch 76 → 77 not taken.
✓ Branch 76 → 78 taken 1 time.
✗ Branch 77 → 78 not taken.
✗ Branch 77 → 79 not taken.
✓ Branch 80 → 81 taken 1 time.
✗ Branch 80 → 82 not taken.
✓ Branch 82 → 83 taken 1 time.
✗ Branch 82 → 84 not taken.
✗ Branch 111 → 112 not taken.
✗ Branch 111 → 113 not taken.
✗ Branch 115 → 116 not taken.
✗ Branch 115 → 117 not taken.
1 changed = store.upsert(value).has_value() || changed;
132 3 }
133 1 return changed;
134 1 }
135
136 } // namespace ComposeSettingsSync
137