[education/rkward] rkward: Fix some clazy warnings
Thomas Friedrichsmeier
null at kde.org
Sun May 12 16:32:29 BST 2024
Git commit 8e948471d6f34f193c43fe2bd179e773d13ec52f by Thomas Friedrichsmeier.
Committed on 10/05/2024 at 20:54.
Pushed by tfry into branch 'master'.
Fix some clazy warnings
M +4 -2 rkward/core/rcontainerobject.cpp
M +1 -1 rkward/misc/rkaccordiontable.cpp
M +1 -1 rkward/misc/rkaccordiontable.h
M +1 -1 rkward/plugin/rkoptionset.cpp
M +1 -1 rkward/rbackend/rkfrontendtransmitter.cpp
M +2 -2 rkward/rbackend/rkrbackend.cpp
M +1 -1 rkward/rbackend/rkrbackend_dlopen.cpp
M +2 -2 rkward/rbackend/rkrbackendprotocol_backend.cpp
M +1 -1 rkward/rbackend/rkrinterface.cpp
M +6 -5 rkward/settings/rksettingsmoduleplugins.cpp
M +1 -1 rkward/settings/rksettingsmoduler.cpp
M +2 -2 rkward/windows/katepluginintegration.cpp
https://invent.kde.org/education/rkward/-/commit/8e948471d6f34f193c43fe2bd179e773d13ec52f
diff --git a/rkward/core/rcontainerobject.cpp b/rkward/core/rcontainerobject.cpp
index 676b56259..0b7b000fd 100644
--- a/rkward/core/rcontainerobject.cpp
+++ b/rkward/core/rcontainerobject.cpp
@@ -371,12 +371,14 @@ QString RContainerObject::renameChildCommand (RObject *object, const QString &ne
QString RContainerObject::validizeName (const QString &child_name, bool unique) const {
RK_TRACE (OBJECTS);
RK_ASSERT (isType (GlobalEnv) || isInGlobalEnv ());
+ static const QRegularExpression validizename1("[^a-zA-Z0-9_]");
+ static const QRegularExpression validizename2("^\\.*[0-9]+");
QString ret = child_name;
if (ret.isEmpty ()) ret = "var";
else {
- ret = ret.replace (QRegularExpression ("[^a-zA-Z0-9_]"), ".");
- ret = ret.replace (QRegularExpression ("^\\.*[0-9]+"), ".");
+ ret = ret.replace(validizename1, ".");
+ ret = ret.replace(validizename2, ".");
}
if (!unique) return ret;
diff --git a/rkward/misc/rkaccordiontable.cpp b/rkward/misc/rkaccordiontable.cpp
index 3cf417cbc..2697613a4 100644
--- a/rkward/misc/rkaccordiontable.cpp
+++ b/rkward/misc/rkaccordiontable.cpp
@@ -394,7 +394,7 @@ void RKAccordionTable::currentChanged (const QModelIndex& current, const QModelI
if (handling_a_click) return;
if (!pmodel->isFake (current)) {
setExpanded (current, true);
- Q_EMIT activated(current.row());
+ Q_EMIT activatedRow(current.row());
}
}
diff --git a/rkward/misc/rkaccordiontable.h b/rkward/misc/rkaccordiontable.h
index 9e21c680f..0b763b657 100644
--- a/rkward/misc/rkaccordiontable.h
+++ b/rkward/misc/rkaccordiontable.h
@@ -32,7 +32,7 @@ public Q_SLOTS:
void removeClicked ();
void activateRow (int row);
Q_SIGNALS:
- void activated (int row);
+ void activatedRow(int row);
void addRow (int where);
void removeRow (int which);
protected:
diff --git a/rkward/plugin/rkoptionset.cpp b/rkward/plugin/rkoptionset.cpp
index 1a1450a14..3159a1629 100644
--- a/rkward/plugin/rkoptionset.cpp
+++ b/rkward/plugin/rkoptionset.cpp
@@ -44,7 +44,7 @@ RKOptionSet::RKOptionSet (const QDomElement &element, RKComponent *parent_compon
accordion = new RKAccordionTable (this);
layout->addWidget (accordion);
- connect (accordion, static_cast<void (RKAccordionTable::*)(int)>(&RKAccordionTable::activated), this, &RKOptionSet::currentRowChanged);
+ connect (accordion, &RKAccordionTable::activatedRow, this, &RKOptionSet::currentRowChanged);
connect (accordion, &RKAccordionTable::addRow, this, &RKOptionSet::addRow);
connect (accordion, &RKAccordionTable::removeRow, this, &RKOptionSet::removeRow);
diff --git a/rkward/rbackend/rkfrontendtransmitter.cpp b/rkward/rbackend/rkfrontendtransmitter.cpp
index b00f67a9b..eb4bbbc86 100644
--- a/rkward/rbackend/rkfrontendtransmitter.cpp
+++ b/rkward/rbackend/rkfrontendtransmitter.cpp
@@ -122,7 +122,7 @@ void RKFrontendTransmitter::run () {
QStringList env = QProcess::systemEnvironment ();
// Try to synchronize language selection in frontend and backend
- int index = env.indexOf (QRegularExpression(QStringLiteral("^LANGUAGE=.*"), QRegularExpression::CaseInsensitiveOption));
+ int index = env.indexOf(QRegularExpression(QStringLiteral("^LANGUAGE=.*"), QRegularExpression::CaseInsensitiveOption)); // clazy:exclude=use-static-quregularexpression ; it'LL only be craeted once
if (index >= 0) env.removeAt (index);
env.append ("LANGUAGE=" + QLocale ().name ().section ('_', 0, 0));
diff --git a/rkward/rbackend/rkrbackend.cpp b/rkward/rbackend/rkrbackend.cpp
index cf6486e6a..8b771fb93 100644
--- a/rkward/rbackend/rkrbackend.cpp
+++ b/rkward/rbackend/rkrbackend.cpp
@@ -818,8 +818,8 @@ void RKRBackend::connectCallbacks () {
// IMPORTANT: see also the #ifdef QS_WS_WIN-portion!
// connect R standard callback to our own functions. Important: Don't do so, before our own versions are ready to be used!
- ROb(R_Outputfile) = NULL;
- ROb(R_Consolefile) = NULL;
+ ROb(R_Outputfile) = nullptr;
+ ROb(R_Consolefile) = nullptr;
ROb(ptr_R_Suicide) = RSuicide;
ROb(ptr_R_ShowMessage) = RShowMessage; // rarely used in R on unix
ROb(ptr_R_ReadConsole) = RReadConsole;
diff --git a/rkward/rbackend/rkrbackend_dlopen.cpp b/rkward/rbackend/rkrbackend_dlopen.cpp
index b177ee914..aea7d3b0a 100644
--- a/rkward/rbackend/rkrbackend_dlopen.cpp
+++ b/rkward/rbackend/rkrbackend_dlopen.cpp
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) {
}
setenv(LD_LIBRARY_PATH, curldpath.c_str(), 1);
unsetenv(RK_ADD_LDPATH);
- char* const args[] = { argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], NULL };
+ char* const args[] = { argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], nullptr };
execv(argv[0], args);
}
#endif
diff --git a/rkward/rbackend/rkrbackendprotocol_backend.cpp b/rkward/rbackend/rkrbackendprotocol_backend.cpp
index 6b14ad58f..cf0d0623b 100644
--- a/rkward/rbackend/rkrbackendprotocol_backend.cpp
+++ b/rkward/rbackend/rkrbackendprotocol_backend.cpp
@@ -85,8 +85,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
#endif
QCoreApplication app (argc, argv);
- setvbuf (stdout, NULL, _IONBF, 0);
- setvbuf (stderr, NULL, _IONBF, 0);
+ setvbuf(stdout, nullptr, _IONBF, 0);
+ setvbuf(stderr, nullptr, _IONBF, 0);
RK_Debug::RK_Debug_Flags = RBACKEND;
if (RK_Debug::setupLogFile (QDir::tempPath () + "/rkward.rbackend")) qInstallMessageHandler (RKDebugMessageOutput);
diff --git a/rkward/rbackend/rkrinterface.cpp b/rkward/rbackend/rkrinterface.cpp
index 876d04ffe..a8a257a4a 100644
--- a/rkward/rbackend/rkrinterface.cpp
+++ b/rkward/rbackend/rkrinterface.cpp
@@ -325,7 +325,7 @@ void RInterface::handleRequest (RBackendRequest* request) {
if (request->type == RBackendRequest::OutputStartedNotification) {
// We do _not_ flush the output right away, as it is likely to arrive in minuscule chunks. But we _do_ want to check, soon
- QTimer::singleShot(FLUSH_INTERVAL, [this]() { flushOutput(false); });
+ QTimer::singleShot(FLUSH_INTERVAL, this, [this]() { flushOutput(false); });
RKRBackendProtocolFrontend::setRequestCompleted (request);
return;
}
diff --git a/rkward/settings/rksettingsmoduleplugins.cpp b/rkward/settings/rksettingsmoduleplugins.cpp
index 6779587bd..ae3f44d1e 100644
--- a/rkward/settings/rksettingsmoduleplugins.cpp
+++ b/rkward/settings/rksettingsmoduleplugins.cpp
@@ -398,16 +398,17 @@ RKSettingsModulePlugins::PluginMapStoredInfo RKSettingsModulePlugins::parsePlugi
QStringList RKSettingsModulePlugins::findPluginMapsRecursive (const QString &basedir) {
RK_TRACE (SETTINGS);
- QDir dir (basedir);
- const QStringList maps = dir.entryList (QDir::Files).filter (QRegularExpression (".*\\.pluginmap$"));
+ QDir dir(basedir);
+ static const QRegularExpression pluginmapfile_ext((".*\\.pluginmap$"));
+ const QStringList maps = dir.entryList(QDir::Files).filter(pluginmapfile_ext);
QStringList ret;
for (const QString &map : maps) {
- ret.append (dir.absoluteFilePath (map));
+ ret.append(dir.absoluteFilePath(map));
}
- QStringList subdirs = dir.entryList (QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
+ const QStringList subdirs = dir.entryList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
for (const QString& subdir : subdirs) {
- ret.append (findPluginMapsRecursive (dir.absoluteFilePath (subdir)));
+ ret.append(findPluginMapsRecursive(dir.absoluteFilePath(subdir)));
}
return ret;
diff --git a/rkward/settings/rksettingsmoduler.cpp b/rkward/settings/rksettingsmoduler.cpp
index 53c277f1b..b77fcbfcf 100755
--- a/rkward/settings/rksettingsmoduler.cpp
+++ b/rkward/settings/rksettingsmoduler.cpp
@@ -253,7 +253,7 @@ QStringList RKSettingsModuleR::makeRRunTimeOptionCommands () {
if (!options_further.get().isEmpty ()) list.append (options_further.get() + '\n');
if (!options_addpaths.get().isEmpty ()) {
QString command = "rk.adjust.system.path (add=c(";
- for (const QString &p : options_addpaths.get()) {
+ for (const QString &p : std::as_const(options_addpaths.get())) {
command.append (RObject::rQuote (p));
}
list.append (command + "))\n");
diff --git a/rkward/windows/katepluginintegration.cpp b/rkward/windows/katepluginintegration.cpp
index d5de3405a..bf002b0e2 100644
--- a/rkward/windows/katepluginintegration.cpp
+++ b/rkward/windows/katepluginintegration.cpp
@@ -247,7 +247,7 @@ void KatePluginIntegrationApp::saveConfigAndUnload() {
// "Global" tool views such as the Diagnostic Window did not get unloaded with any plugin, but need to be torn down, while KXML (factory) is still availalbe
if (window->plugin_resources.contains(nullptr)) {
- auto wins = window->plugin_resources[nullptr].windows;
+ const auto wins = window->plugin_resources[nullptr].windows;
for(auto win : wins) delete win;
}
}
@@ -452,7 +452,7 @@ QWidgetList KatePluginIntegrationWindow::widgets() {
RK_TRACE(APP);
QWidgetList ret;
- auto list = RKWorkplace::mainWorkplace()->getObjectList();
+ const auto list = RKWorkplace::mainWorkplace()->getObjectList();
for (const auto win : list) {
if (win->isType(RKMDIWindow::KatePluginWindow) && win->isType(RKMDIWindow::DocumentWindow)) {
auto w = qobject_cast<KatePluginWindow*>(win)->internalWidget();
More information about the rkward-tracker
mailing list