[education/rkward] rkward: Address (or disable) clazy warnings
Thomas Friedrichsmeier
null at kde.org
Sun Sep 21 20:45:24 BST 2025
Git commit 96907a3b5257ff2d87457df4dd32e53593aeca01 by Thomas Friedrichsmeier.
Committed on 21/09/2025 at 19:36.
Pushed by tfry into branch 'master'.
Address (or disable) clazy warnings
M +1 -1 rkward/autotests/core_test.cpp
M +3 -3 rkward/autotests/rkparsedscript_test.cpp
M +2 -2 rkward/misc/rkcompatibility.h
M +3 -1 rkward/misc/rktableview.cpp
M +2 -2 rkward/misc/rkxmlguisyncer.cpp
M +4 -5 rkward/misc/rkxmlguisyncer.h
M +5 -7 rkward/misc/xmlhelper.cpp
M +3 -3 rkward/settings/rksettings.cpp
M +5 -5 rkward/windows/rkcommandeditorwindow.cpp
https://invent.kde.org/education/rkward/-/commit/96907a3b5257ff2d87457df4dd32e53593aeca01
diff --git a/rkward/autotests/core_test.cpp b/rkward/autotests/core_test.cpp
index e34327a7b..be4646b45 100644
--- a/rkward/autotests/core_test.cpp
+++ b/rkward/autotests/core_test.cpp
@@ -508,7 +508,7 @@ class RKWardCoreTest : public QObject {
if (out.output.contains(u"before"_s)) RInterface::instance()->cancelAll();
QVERIFY(!out.output.contains(u"after"_s));
});
- runCommandWithTimeout(c, nullptr, [this](RCommand *command) {
+ runCommandWithTimeout(c, nullptr, [](RCommand *command) {
// QVERIFY(command->wasCanceled()); we're currenly mis-detecting that, which is not a real-world problem, however.
// The real test is the command neither times out (below), nor prints "after" (above)
QVERIFY(command->failed()); }, 2000);
diff --git a/rkward/autotests/rkparsedscript_test.cpp b/rkward/autotests/rkparsedscript_test.cpp
index e49ceafcf..fd2ba9d7d 100644
--- a/rkward/autotests/rkparsedscript_test.cpp
+++ b/rkward/autotests/rkparsedscript_test.cpp
@@ -168,7 +168,7 @@ class RKParsedScriptTest : public QObject {
int posa = ps.getContext(ps.firstContextInStatement(ctx)).start;
int posb = ps.lastPositionInStatement(ctx);
QVERIFY(posb > posa);
- QVERIFY(script.mid(posa).startsWith(u"symb.last"_s));
+ QVERIFY(script.mid(posa).startsWith(u"symb.last"_s)); // clazy:exclude=qstring-ref
QVERIFY(!ps.nextStatement(ctx).valid());
ctx = ps.contextAtPos(script.indexOf(u"FunctionList"));
@@ -324,9 +324,9 @@ class RKParsedScriptTest : public QObject {
QVERIFY(posb > posa);
// NOTE: Note sure wether or not we want to include the trailing comment,
// as part of the statement, so this test will only check the start
- QVERIFY(script.mid(posa, posb - posa + 1).startsWith(u"symb07"_s));
+ QVERIFY(script.mid(posa, posb - posa + 1).startsWith(u"symb07"_s)); // clazy:exclude=qstring-ref
// We do not want to include the delimiting newline, however
- QVERIFY(!script.mid(posa, posb - posa + 1).contains(u'\n'));
+ QVERIFY(!script.mid(posa, posb - posa + 1).contains(u'\n')); // clazy:exclude=qstring-ref
QVERIFY(!ps.nextStatement(ctx).valid());
ctx = ps.contextAtPos(script.indexOf(u"symb14"));
diff --git a/rkward/misc/rkcompatibility.h b/rkward/misc/rkcompatibility.h
index 78ab98fa9..6c7945ef8 100644
--- a/rkward/misc/rkcompatibility.h
+++ b/rkward/misc/rkcompatibility.h
@@ -15,9 +15,9 @@ This namespace holds helpers for supporting different versions of Q6/KF6, withou
*/
namespace RKCompatibility {
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
-inline constexpr auto QCheckBox_checkStateChanged = &QCheckBox::checkStateChanged;
+inline const constexpr auto QCheckBox_checkStateChanged = &QCheckBox::checkStateChanged;
#else
-inline constexpr auto QCheckBox_checkStateChanged = &QCheckBox::stateChanged;
+inline const constexpr auto QCheckBox_checkStateChanged = &QCheckBox::stateChanged;
#endif
}; //namespace RKCompatibility
diff --git a/rkward/misc/rktableview.cpp b/rkward/misc/rktableview.cpp
index 4912563ac..af5e74731 100644
--- a/rkward/misc/rktableview.cpp
+++ b/rkward/misc/rktableview.cpp
@@ -161,7 +161,9 @@ QWidget *RKItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewIte
ed->setFont(option.font);
// NOTE: Can't use new SIGNAL/SLOT syntax, here, as the editors are of different types (TODO: define a common base class)
- connect(ed, SIGNAL(done(QWidget *, RKItemDelegate::EditorDoneReason)), this, SLOT(editorDone(QWidget *, RKItemDelegate::EditorDoneReason)));
+ // clang-format off
+ connect(ed, SIGNAL(done(QWidget*,RKItemDelegate::EditorDoneReason)), this, SLOT(editorDone(QWidget*,RKItemDelegate::EditorDoneReason)));
+ // clang-format on
return ed;
}
diff --git a/rkward/misc/rkxmlguisyncer.cpp b/rkward/misc/rkxmlguisyncer.cpp
index b52957f07..53890045c 100644
--- a/rkward/misc/rkxmlguisyncer.cpp
+++ b/rkward/misc/rkxmlguisyncer.cpp
@@ -57,13 +57,13 @@ void RKXMLGUISyncer::watchXMLGUIClientUIrc(KXMLGUIClient *client, bool recursive
}
}
-void RKXMLGUISyncer::registerChangeListener(KXMLGUIClient *watched_client, QObject *receiver, const char *method) {
+void RKXMLGUISyncer::registerChangeListener(KXMLGUIClient *watched_client, QObject *receiver, std::function<void(KXMLGUIClient *)> method) {
RK_TRACE(MISC);
KActionCollection *ac = watched_client->actionCollection();
RKXMLGUISyncerNotifier *notifier = new RKXMLGUISyncerNotifier(nullptr);
- d->connect(notifier, SIGNAL(changed(KXMLGUIClient *)), receiver, method);
+ d->connect(notifier, &RKXMLGUISyncerNotifier::changed, receiver, method);
d->notifier_map.insert(ac, notifier);
}
diff --git a/rkward/misc/rkxmlguisyncer.h b/rkward/misc/rkxmlguisyncer.h
index 10b1e34ca..d564f7178 100644
--- a/rkward/misc/rkxmlguisyncer.h
+++ b/rkward/misc/rkxmlguisyncer.h
@@ -8,6 +8,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
#ifndef RKXMLGUISYNCER_H
#define RKXMLGUISYNCER_H
+#include <functional>
+
class KXMLGUIClient;
class QObject;
class RKXMLGUISyncerPrivate;
@@ -26,12 +28,9 @@ class RKXMLGUISyncer {
/** You can use this function to receive a signal, when an KXMLGUIClient's ui.rc file has been reloaded (after the reload, before the factory is told to rebuild).
@param watched_client The client to monitor. This needs to be registered using watchXMLGUIClientUIrc, first.
@param receiver QObject to receive notification
- @param method slot to receive notification. This needs to have the signature
- \code
- void someSlotName (KXMLGUIClient *changed_client);
- \endcode
+ @param method function to call when the client's ui.rc file has changed
*/
- void registerChangeListener(KXMLGUIClient *watched_client, QObject *receiver, const char *method);
+ void registerChangeListener(KXMLGUIClient *watched_client, QObject *receiver, std::function<void(KXMLGUIClient *)> method);
protected:
RKXMLGUISyncer();
diff --git a/rkward/misc/xmlhelper.cpp b/rkward/misc/xmlhelper.cpp
index 8d968a7bf..30701b809 100644
--- a/rkward/misc/xmlhelper.cpp
+++ b/rkward/misc/xmlhelper.cpp
@@ -48,19 +48,17 @@ XMLHelper::~XMLHelper() {
QDomElement XMLHelper::openXMLFile(int debug_level, bool with_includes, bool with_snippets) {
RK_TRACE(XML);
- int error_line, error_column;
- QString error_message;
QDomDocument doc;
-
QFile f(filename);
if (!f.open(QIODevice::ReadOnly)) displayError(nullptr, i18n("Could not open file %1 for reading", filename), debug_level, DL_ERROR);
QXmlStreamReader reader(&f);
- DummyEntityResolver res;
- reader.setEntityResolver(&res);
- if (!doc.setContent(&reader, false, &error_message, &error_line, &error_column)) {
+ DummyEntityResolver resolver;
+ reader.setEntityResolver(&resolver);
+ auto res = doc.setContent(&reader, QDomDocument::ParseOption::Default);
+ if (!res) {
displayError(nullptr,
i18n("Error parsing XML-file. Error-message was: '%1' in line '%2', column '%3'. Expect further errors to be reported below",
- error_message, error_line, error_column),
+ res.errorMessage, res.errorLine, res.errorColumn),
debug_level, DL_ERROR);
return QDomElement();
}
diff --git a/rkward/settings/rksettings.cpp b/rkward/settings/rksettings.cpp
index d855817d9..9e77cc6fa 100644
--- a/rkward/settings/rksettings.cpp
+++ b/rkward/settings/rksettings.cpp
@@ -161,9 +161,9 @@ void RKSettings::applyAll() {
changed_modules.insert(kateconfig->parentModule());
}
- for (auto it = changed_modules.constBegin(); it != changed_modules.constEnd(); ++it) {
- (*it)->syncConfig(KSharedConfig::openConfig().data(), RKConfigBase::SaveConfig);
- Q_EMIT(*it)->settingsChanged();
+ for (auto mod : std::as_const(changed_modules)) {
+ mod->syncConfig(KSharedConfig::openConfig().data(), RKConfigBase::SaveConfig);
+ Q_EMIT mod->settingsChanged();
}
button(QDialogButtonBox::Apply)->setEnabled(false);
}
diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index 233d0fdc3..08647f6b2 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -239,7 +239,7 @@ RKCommandEditorWindow::RKCommandEditorWindow(QWidget *parent, const QUrl &_url,
}
}
initializeActivationSignals();
- RKXMLGUISyncer::self()->registerChangeListener(m_view, this, SLOT(fixupPartGUI()));
+ RKXMLGUISyncer::self()->registerChangeListener(m_view, this, [this](KXMLGUIClient *) { fixupPartGUI(); });
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
@@ -522,9 +522,9 @@ void RKCommandEditorWindow::autoSaveHandlerModifiedChanged() {
}
}
-static QString r_script_mode = QStringLiteral("R Script");
-static QString r_interactive_mode = QStringLiteral("R interactive session");
-static QString r_markdown_mode = QStringLiteral("R Markdown");
+static const constexpr QLatin1String r_script_mode("R Script"); // we'd like QString for these, but static QString is non-POD
+static const constexpr QLatin1String r_interactive_mode("R interactive session");
+static const constexpr QLatin1String r_markdown_mode("R Markdown");
static QString modeToString(RKCommandHighlighter::HighlightingMode mode, KTextEditor::Document *doc) {
if (mode == RKCommandHighlighter::RScript) return r_script_mode;
@@ -822,7 +822,7 @@ void RKCommandEditorWindow::initPreviewModes(KActionMenu *menu) {
for (auto *b : preview_buttons) {
l->addWidget(b);
if (b == action_no_preview) continue;
- for (auto ob : static_cast<RKPreviewMode *>(b)->options) {
+ for (auto ob : std::as_const(static_cast<RKPreviewMode *>(b)->options)) {
r->addWidget(ob);
ob->setVisible(false);
// the following is a little hackish...
More information about the rkward-tracker
mailing list