Commit 41a9526d authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix some clazy warnings

parent 8c3174ec
Pipeline #78201 passed with stage
in 43 minutes and 6 seconds
......@@ -768,11 +768,11 @@ void MessageFactoryTest::testCreateRedirect()
QString datetime = rdir->date()->asUnicodeString();
const QRegularExpression rx(QLatin1String("Resent-Message-ID: ([^\n]*)"));
const QRegularExpression rx(QStringLiteral("Resent-Message-ID: ([^\n]*)"));
const QRegularExpressionMatch rxMatch = rx.match(QString::fromLatin1(rdir->head()));
QVERIFY(rxMatch.hasMatch());
const QRegularExpression rxmessageid(QLatin1String("Message-ID: ([^\n]+)"));
const QRegularExpression rxmessageid(QStringLiteral("Message-ID: ([^\n]+)"));
const QRegularExpressionMatch rxmessageidMatch = rxmessageid.match(QString::fromLatin1(rdir->head()));
QVERIFY(rxmessageidMatch.hasMatch());
......
......@@ -106,7 +106,7 @@ void AutocryptUtilsTest::test_gossip()
auto storage = AutocryptStorage::self();
QCOMPARE(storage->d_func()->recipients.keys().size(), expectedKeys.size());
for (const auto &addr : expectedKeys) {
for (const auto &addr : std::as_const(expectedKeys)) {
QVERIFY2(storage->getRecipient(addr), qPrintable(QStringLiteral("storage missing %1").arg(QString::fromLatin1(addr))));
}
......
......@@ -2357,7 +2357,8 @@ bool View::event(QEvent *e)
break;
}
} else {
if (ghi->label().contains(QRegularExpression(QStringLiteral("[0-9]")))) {
static const QRegularExpression reg(QStringLiteral("[0-9]"));
if (ghi->label().contains(reg)) {
if (storageModel()->containsOutboundMessages()) {
description = i18nc("@info:tooltip Formats to something like 'Messages sent on 2008-12-21'", "Messages sent on %1", ghi->label());
} else {
......@@ -2476,9 +2477,7 @@ bool View::event(QEvent *e)
"<nobr>%2</nobr>"
"</td>"
"</tr>")
.arg(darkerColorName)
.arg(statsText)
.arg(textDirection);
.arg(darkerColorName, statsText, textDirection);
}
break;
......
......@@ -68,7 +68,7 @@ Q_SIGNALS:
void statusButtonsClicked();
void forceLostFocus();
void saveFilter();
void activateFilter(Filter *f);
void activateFilter(MessageList::Core::Filter *f);
protected:
bool eventFilter(QObject *object, QEvent *e) override;
......
......@@ -324,7 +324,8 @@ QString DKIMCheckSignatureJob::headerCanonizationSimple() const
DKIMHeaderParser parser = mHeaderParser;
for (const QString &header : mDkimInfo.listSignedHeader()) {
const auto listSignedHeader{mDkimInfo.listSignedHeader()};
for (const QString &header : listSignedHeader) {
const QString str = parser.headerType(header.toLower());
if (!str.isEmpty()) {
if (!headers.isEmpty()) {
......
......@@ -56,7 +56,8 @@ QString MessageViewer::DKIMUtil::bodyCanonizationSimple(QString body)
// Note that a completely empty or missing body is canonicalized as a
// single "CRLF"; that is, the canonicalized length will be 2 octets.
body.replace(QStringLiteral("\n"), QStringLiteral("\r\n"));
body.replace(QRegularExpression(QStringLiteral("((\r\n)+)?$")), QStringLiteral("\r\n"));
static const QRegularExpression reg(QStringLiteral("((\r\n)+)?$"));
body.replace(reg, QStringLiteral("\r\n"));
if (body.endsWith(QLatin1String("\r\n"))) { // Remove it from start
body.chop(2);
}
......@@ -103,9 +104,12 @@ QString MessageViewer::DKIMUtil::headerCanonizationRelaxed(const QString &header
// colon separator MUST be retained.
QString newHeaderName = headerName.toLower();
QString newHeaderValue = headerValue;
newHeaderValue.replace(QRegularExpression(QStringLiteral("\r\n[ \t]+")), QStringLiteral(" "));
newHeaderValue.replace(QRegularExpression(QStringLiteral("[ \t]+")), QStringLiteral(" "));
newHeaderValue.replace(QRegularExpression(QStringLiteral("[ \t]+\r\n")), QStringLiteral("\r\n"));
static const QRegularExpression reg1(QStringLiteral("\r\n[ \t]+"));
newHeaderValue.replace(reg1, QStringLiteral(" "));
static const QRegularExpression reg2(QStringLiteral("[ \t]+"));
newHeaderValue.replace(reg2, QStringLiteral(" "));
static const QRegularExpression reg3(QStringLiteral("[ \t]+\r\n"));
newHeaderValue.replace(reg3, QStringLiteral("\r\n"));
// Perhaps remove tab after headername and before value name
// newHeaderValue.replace(QRegularExpression(QStringLiteral("[ \t]*:[ \t]")), QStringLiteral(":"));
if (newHeaderName == QLatin1String("content-type") && removeQuoteOnContentType) { // Remove quote in charset
......
......@@ -274,10 +274,12 @@ HeaderStyleUtil::xfaceSettings HeaderStyleUtil::xface(const MessageViewer::Heade
style->nodeHelper()->setBodyPartMemento(message, "contactphoto", photoMemento);
QObject::connect(photoMemento, SIGNAL(update(MimeTreeParser::UpdateMode)), style->sourceObject(), SLOT(update(MimeTreeParser::UpdateMode)));
// clang-format off
QObject::connect(photoMemento,
SIGNAL(changeDisplayMail(Viewer::DisplayFormatMessage, bool)),
SIGNAL(changeDisplayMail(Viewer::DisplayFormatMessage,bool)),
style->sourceObject(),
SIGNAL(changeDisplayMail(Viewer::DisplayFormatMessage, bool)));
SIGNAL(changeDisplayMail(Viewer::DisplayFormatMessage,bool)));
// clang-format on
}
if (photoMemento->finished()) {
......
......@@ -200,7 +200,8 @@ QStringList HeaderStylePluginManager::pluginListName() const
{
QStringList lst;
lst.reserve(d->pluginsList().count());
for (MessageViewer::HeaderStylePlugin *plugin : d->pluginsList()) {
const auto pluginsList{d->pluginsList()};
for (MessageViewer::HeaderStylePlugin *plugin : pluginsList) {
lst << plugin->name();
}
return lst;
......
......@@ -62,7 +62,7 @@ public Q_SLOTS:
/** Switch to "normal mode". */
void setNormalMode();
/** Switch to mode @p m */
void setMode(MimeTreeParser::Util::HtmlMode m, UpdateMode mode = Update);
void setMode(MimeTreeParser::Util::HtmlMode m, MessageViewer::HtmlStatusBar::UpdateMode mode = Update);
Q_SIGNALS:
/** The user has clicked the status bar. */
......
......@@ -681,7 +681,8 @@ void TemplateParserJob::slotExtractInfoDone(const TemplateParserExtractHtmlInfoR
// insert specified content of header from current message
qCDebug(TEMPLATEPARSER_LOG) << "Command: HEADER(";
QRegularExpressionMatch match;
const int res = cmd.indexOf(QRegularExpression(QStringLiteral("^HEADER\\((.+)\\)")), 0, &match);
static QRegularExpression reg(QStringLiteral("^HEADER\\((.+)\\)"));
const int res = cmd.indexOf(reg, 0, &match);
if (res != 0) {
// something wrong
i += strlen("HEADER( ");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment