Skip to content

Commit

Permalink
Fixed #12316 - partially revert "Fix two types of Clazy warnings (#5807
Browse files Browse the repository at this point in the history
…)" (#5902)

This partially reverts commit 4a9b921
  • Loading branch information
firewave authored Jan 20, 2024
1 parent b959c11 commit 3cb0a31
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 66 deletions.
15 changes: 8 additions & 7 deletions gui/codeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,15 @@ void CodeEditor::lineNumberAreaPaintEvent(const QPaintEvent *event)
QString CodeEditor::generateStyleString()
{
QString bgcolor = QString("background:rgb(%1,%2,%3);")
.arg(mWidgetStyle->widgetBGColor.red(),
mWidgetStyle->widgetBGColor.green(),
mWidgetStyle->widgetBGColor.blue());
.arg(mWidgetStyle->widgetBGColor.red())
.arg(mWidgetStyle->widgetBGColor.green())
.arg(mWidgetStyle->widgetBGColor.blue());
QString fgcolor = QString("color:rgb(%1,%2,%3);")
.arg(mWidgetStyle->widgetFGColor.red(),
mWidgetStyle->widgetFGColor.green(),
mWidgetStyle->widgetFGColor.blue());
.arg(mWidgetStyle->widgetFGColor.red())
.arg(mWidgetStyle->widgetFGColor.green())
.arg(mWidgetStyle->widgetFGColor.blue());
QString style = QString("%1 %2")
.arg(bgcolor, fgcolor);
.arg(bgcolor)
.arg(fgcolor);
return style;
}
2 changes: 1 addition & 1 deletion gui/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ QString toFilterString(const QMap<QString,QString>& filters, bool addAllSupporte
// name patterns are our values. The generated filter string list will
// thus be sorted alphabetically over the descriptions.
for (const auto& k: filters.keys()) {
entries << QString("%1 (%2)").arg(k, filters.value(k));
entries << QString("%1 (%2)").arg(k).arg(filters.value(k));
}

return entries.join(";;");
Expand Down
2 changes: 1 addition & 1 deletion gui/compliancereportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void ComplianceReportDialog::save()
} catch (InternalError &e) {
QMessageBox msg(QMessageBox::Critical,
tr("Save compliance report"),
tr("Failed to import '%1' (%2), can not show files in compliance report").arg(prjfile, QString::fromStdString(e.errorMessage)),
tr("Failed to import '%1' (%2), can not show files in compliance report").arg(prjfile).arg(QString::fromStdString(e.errorMessage)),
QMessageBox::Ok,
this);
msg.exec();
Expand Down
4 changes: 2 additions & 2 deletions gui/cppchecklibrarydata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ static std::string mandatoryAttibuteMissing(const QXmlStreamReader &xmlReader, c
{
throw std::runtime_error(QObject::tr("line %1: Mandatory attribute '%2' missing in '%3'")
.arg(xmlReader.lineNumber())
.arg(attributeName, xmlReader.name().toString())
.toStdString());
.arg(attributeName)
.arg(xmlReader.name().toString()).toStdString());
}

static CppcheckLibraryData::Container loadContainer(QXmlStreamReader &xmlReader)
Expand Down
4 changes: 2 additions & 2 deletions gui/csvreport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void CsvReport::writeError(const ErrorItem &error)
*/

const QString file = QDir::toNativeSeparators(error.errorPath.back().file);
QString line = QString("%1,%2,").arg(file, error.errorPath.back().line);
line += QString("%1,%2,%3").arg(GuiSeverity::toString(error.severity), error.errorId, error.summary);
QString line = QString("%1,%2,").arg(file).arg(error.errorPath.back().line);
line += QString("%1,%2,%3").arg(GuiSeverity::toString(error.severity)).arg(error.errorId).arg(error.summary);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
mTxtWriter << line << Qt::endl;
#else
Expand Down
2 changes: 1 addition & 1 deletion gui/librarydialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void LibraryDialog::openCfg()
if (!errmsg.isNull()) {
QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"),
tr("Failed to load %1. %2.").arg(selectedFile, errmsg),
tr("Failed to load %1. %2.").arg(selectedFile).arg(errmsg),
QMessageBox::Ok,
this);
msg.exec();
Expand Down
12 changes: 6 additions & 6 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ bool MainWindow::tryLoadLibrary(Library *library, const QString& filename)
const Library::Error error = loadLibrary(library, filename);
if (error.errorcode != Library::ErrorCode::OK) {
if (error.errorcode == Library::ErrorCode::UNKNOWN_ELEMENT) {
QMessageBox::information(this, tr("Information"), tr("The library '%1' contains unknown elements:\n%2").arg(filename, error.reason.c_str()));
QMessageBox::information(this, tr("Information"), tr("The library '%1' contains unknown elements:\n%2").arg(filename).arg(error.reason.c_str()));
return true;
}

Expand Down Expand Up @@ -899,7 +899,7 @@ bool MainWindow::tryLoadLibrary(Library *library, const QString& filename)
}
if (!error.reason.empty())
errmsg += " '" + QString::fromStdString(error.reason) + "'";
QMessageBox::information(this, tr("Information"), tr("Failed to load the selected library '%1'.\n%2").arg(filename, errmsg));
QMessageBox::information(this, tr("Information"), tr("Failed to load the selected library '%1'.\n%2").arg(filename).arg(errmsg));
return false;
}
return true;
Expand Down Expand Up @@ -958,7 +958,7 @@ Settings MainWindow::getCppcheckSettings()
{
const QString cfgErr = QString::fromStdString(result.loadCppcheckCfg());
if (!cfgErr.isEmpty())
QMessageBox::critical(this, tr("Error"), tr("Failed to load %1 - %2").arg("cppcheck.cfg", cfgErr));
QMessageBox::critical(this, tr("Error"), tr("Failed to load %1 - %2").arg("cppcheck.cfg").arg(cfgErr));

const auto cfgAddons = result.addons;
result.addons.clear();
Expand Down Expand Up @@ -1787,7 +1787,7 @@ void MainWindow::analyzeProject(const ProjectFile *projectFile, const bool check
if (!errorMessage.isEmpty()) {
QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"),
tr("Failed to import '%1': %2\n\nAnalysis is stopped.").arg(prjfile, errorMessage),
tr("Failed to import '%1': %2\n\nAnalysis is stopped.").arg(prjfile).arg(errorMessage),
QMessageBox::Ok,
this);
msg.exec();
Expand All @@ -1796,7 +1796,7 @@ void MainWindow::analyzeProject(const ProjectFile *projectFile, const bool check
} catch (InternalError &e) {
QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"),
tr("Failed to import '%1' (%2), analysis is stopped").arg(prjfile, QString::fromStdString(e.errorMessage)),
tr("Failed to import '%1' (%2), analysis is stopped").arg(prjfile).arg(QString::fromStdString(e.errorMessage)),
QMessageBox::Ok,
this);
msg.exec();
Expand Down Expand Up @@ -2100,7 +2100,7 @@ void MainWindow::replyFinished(QNetworkReply *reply) {
}
mUI->mButtonHideInformation->setVisible(true);
mUI->mLabelInformation->setVisible(true);
mUI->mLabelInformation->setText(tr("New version available: %1. %2").arg(str.trimmed(), install));
mUI->mLabelInformation->setText(tr("New version available: %1. %2").arg(str.trimmed()).arg(install));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gui/printablereport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void PrintableReport::writeError(const ErrorItem &error)
{
const QString file = QDir::toNativeSeparators(error.errorPath.back().file);
QString line = QString("%1,%2,").arg(file).arg(error.errorPath.back().line);
line += QString("%1,%2").arg(GuiSeverity::toString(error.severity), error.summary);
line += QString("%1,%2").arg(GuiSeverity::toString(error.severity)).arg(error.summary);

mFormattedReport += line;
mFormattedReport += "\n";
Expand Down
2 changes: 1 addition & 1 deletion gui/resultstree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ void ResultsTree::startApplication(const QStandardItem *target, int application)
}
#endif // Q_OS_WIN

const QString cmdLine = QString("%1 %2").arg(program, params);
const QString cmdLine = QString("%1 %2").arg(program).arg(params);

// this is reported as deprecated in Qt 5.15.2 but no longer in Qt 6
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
Expand Down
2 changes: 1 addition & 1 deletion gui/resultsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ void ResultsView::updateDetails(const QModelIndex &index)

const QString file0 = data["file0"].toString();
if (!file0.isEmpty() && Path::isHeader2(data["file"].toString().toStdString()))
formattedMsg += QString("\n\n%1: %2").arg(tr("First included by"), QDir::toNativeSeparators(file0));
formattedMsg += QString("\n\n%1: %2").arg(tr("First included by")).arg(QDir::toNativeSeparators(file0));

if (data["cwe"].toInt() > 0)
formattedMsg.prepend("CWE: " + QString::number(data["cwe"].toInt()) + "\n");
Expand Down
86 changes: 43 additions & 43 deletions gui/statsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ void StatsDialog::pdfExport()
"<font color=\"blue\"><h3>%9 : %10</h3></font>\n"
"<font color=\"blue\"><h3>%11 : %12</h3></font>\n"
"<font color=\"purple\"><h3>%13 : %14</h3></font>\n")
.arg(tr("Statistics"),
QDate::currentDate().toString("dd.MM.yyyy"),
tr("Errors"))
.arg(tr("Statistics"))
.arg(QDate::currentDate().toString("dd.MM.yyyy"))
.arg(tr("Errors"))
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowErrors))
.arg(tr("Warnings"))
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowWarnings))
Expand Down Expand Up @@ -246,31 +246,31 @@ void StatsDialog::copyToClipboard()
"\t%8:\t%9\n"
"\t%10:\t%11\n"
)
.arg(projSettings,
project,
mUI->mProject->text(),
paths,
mUI->mPaths->text(),
incPaths,
mUI->mIncludePaths->text(),
defines)
.arg(mUI->mDefines->text(),
undefines,
mUI->mUndefines->text());
.arg(projSettings)
.arg(project)
.arg(mUI->mProject->text())
.arg(paths)
.arg(mUI->mPaths->text())
.arg(incPaths)
.arg(mUI->mIncludePaths->text())
.arg(defines)
.arg(mUI->mDefines->text())
.arg(undefines)
.arg(mUI->mUndefines->text());

const QString previous = QString(
"%1\n"
"\t%2:\t%3\n"
"\t%4:\t%5\n"
"\t%6:\t%7\n"
)
.arg(prevScan,
selPath,
mUI->mPath->text(),
numFiles,
mUI->mNumberOfFilesScanned->text(),
duration,
mUI->mScanDuration->text());
.arg(prevScan)
.arg(selPath)
.arg(mUI->mPath->text())
.arg(numFiles)
.arg(mUI->mNumberOfFilesScanned->text())
.arg(duration)
.arg(mUI->mScanDuration->text());

const QString statistics = QString(
"%1\n"
Expand All @@ -281,8 +281,8 @@ void StatsDialog::copyToClipboard()
"\t%10:\t%11\n"
"\t%12:\t%13\n"
)
.arg(stats,
errors)
.arg(stats)
.arg(errors)
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowErrors))
.arg(warnings)
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowWarnings))
Expand All @@ -308,17 +308,17 @@ void StatsDialog::copyToClipboard()
" <tr><th>%10:</th><td>%11</td></tr>\n"
"</table>\n"
)
.arg(projSettings,
project,
mUI->mProject->text(),
paths,
mUI->mPaths->text(),
incPaths,
mUI->mIncludePaths->text(),
defines)
.arg(mUI->mDefines->text(),
undefines,
mUI->mUndefines->text());
.arg(projSettings)
.arg(project)
.arg(mUI->mProject->text())
.arg(paths)
.arg(mUI->mPaths->text())
.arg(incPaths)
.arg(mUI->mIncludePaths->text())
.arg(defines)
.arg(mUI->mDefines->text())
.arg(undefines)
.arg(mUI->mUndefines->text());

const QString htmlPrevious = QString(
"<h3>%1</h3>\n"
Expand All @@ -328,13 +328,13 @@ void StatsDialog::copyToClipboard()
" <tr><th>%6:</th><td>%7</td></tr>\n"
"</table>\n"
)
.arg(prevScan,
selPath,
mUI->mPath->text(),
numFiles,
mUI->mNumberOfFilesScanned->text(),
duration,
mUI->mScanDuration->text());
.arg(prevScan)
.arg(selPath)
.arg(mUI->mPath->text())
.arg(numFiles)
.arg(mUI->mNumberOfFilesScanned->text())
.arg(duration)
.arg(mUI->mScanDuration->text());

const QString htmlStatistics = QString(
"<h3>%1</h3>\n"
Expand All @@ -346,8 +346,8 @@ void StatsDialog::copyToClipboard()
" <tr><th>%12:</th><td>%13</td></tr>\n"
"</table>\n"
)
.arg(stats,
errors)
.arg(stats)
.arg(errors)
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowErrors))
.arg(warnings)
.arg(mStatistics->getCount(CPPCHECK,ShowTypes::ShowWarnings))
Expand Down

0 comments on commit 3cb0a31

Please sign in to comment.