triage: Implement Clang-Tidy and Clazy hints (#1674)

These are mainly readability and optimization changes.
This commit is contained in:
Sebastian 2019-02-16 17:52:36 +01:00 committed by GitHub
parent 7629923b65
commit ff16995b26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View File

@ -7,5 +7,5 @@ int main(int argc, char *argv[])
MainWindow w; MainWindow w;
w.show(); w.show();
return a.exec(); return QApplication::exec();
} }

View File

@ -118,12 +118,12 @@ bool MainWindow::runProcess(const QString &programName, const QStringList &argum
return success; return success;
} }
bool MainWindow::wget(const QString url) bool MainWindow::wget(const QString &url)
{ {
return runProcess("wget", QStringList() << url); return runProcess("wget", QStringList() << url);
} }
bool MainWindow::unpackArchive(const QString archiveName) bool MainWindow::unpackArchive(const QString &archiveName)
{ {
// Unpack archive // Unpack archive
QStringList args; QStringList args;
@ -164,14 +164,14 @@ void MainWindow::showResult(QListWidgetItem *item)
const int pos1 = msg.indexOf(":"); const int pos1 = msg.indexOf(":");
const int pos2 = msg.indexOf(":", pos1+1); const int pos2 = msg.indexOf(":", pos1+1);
const QString fileName = WORK_FOLDER + '/' + msg.left(msg.indexOf(":")); const QString fileName = WORK_FOLDER + '/' + msg.left(msg.indexOf(":"));
const int lineNumber = msg.mid(pos1+1,pos2-pos1-1).toInt(); const int lineNumber = msg.midRef(pos1+1,pos2-pos1-1).toInt();
if (!QFileInfo(fileName).exists()) { if (!QFileInfo::exists(fileName)) {
if (QFileInfo(DACA2_PACKAGES + '/' + archiveName.mid(0,archiveName.indexOf(".tar.")) + ".tar.xz").exists()) { if (QFileInfo::exists(DACA2_PACKAGES + '/' + archiveName.mid(0,archiveName.indexOf(".tar.")) + ".tar.xz")) {
if (!unpackArchive(DACA2_PACKAGES + '/' + archiveName.mid(0,archiveName.indexOf(".tar.")) + ".tar.xz")) if (!unpackArchive(DACA2_PACKAGES + '/' + archiveName.mid(0,archiveName.indexOf(".tar.")) + ".tar.xz"))
return; return;
} else { } else {
if (!QFileInfo(WORK_FOLDER + '/' + archiveName).exists()) { if (!QFileInfo::exists(WORK_FOLDER + '/' + archiveName)) {
// Download archive // Download archive
if (!wget(url)) if (!wget(url))
return; return;
@ -186,7 +186,7 @@ void MainWindow::showResult(QListWidgetItem *item)
QFile f(fileName); QFile f(fileName);
if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
const QString errorMsg = const QString errorMsg =
QString("Opening file %1 failed: %2").arg(f.fileName()).arg(f.errorString()); QString("Opening file %1 failed: %2").arg(f.fileName(), f.errorString());
ui->statusBar->showMessage(errorMsg); ui->statusBar->showMessage(errorMsg);
} else { } else {
QTextStream textStream(&f); QTextStream textStream(&f);

View File

@ -29,8 +29,8 @@ private:
void load(QTextStream &textStream); void load(QTextStream &textStream);
bool runProcess(const QString &programName, const QStringList & arguments); bool runProcess(const QString &programName, const QStringList & arguments);
bool wget(const QString url); bool wget(const QString &url);
bool unpackArchive(const QString archiveName); bool unpackArchive(const QString &archiveName);
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H