From: Matthieu Gallien Date: Fri, 18 Nov 2022 08:19:03 +0000 (+0100) Subject: remove a few warnings reported by sonarcloud to tidy the code X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~11^2~131^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ad32bc7ce55c01e17f7063860a4dcd6f9205b419;p=nextcloud-desktop.git remove a few warnings reported by sonarcloud to tidy the code Signed-off-by: Matthieu Gallien --- diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp index e7cb6e9b7..112f16e9f 100644 --- a/src/libsync/propagatorjobs.cpp +++ b/src/libsync/propagatorjobs.cpp @@ -250,8 +250,7 @@ void PropagateLocalRename::start() emit propagator()->touchedFile(existingFile); emit propagator()->touchedFile(targetFile); - QString renameError; - if (!FileSystem::rename(existingFile, targetFile, &renameError)) { + if (QString renameError; !FileSystem::rename(existingFile, targetFile, &renameError)) { done(SyncFileItem::NormalError, renameError); return; } @@ -279,7 +278,7 @@ void PropagateLocalRename::start() const auto oldFile = _item->_file; if (!_item->isDirectory()) { // Directories are saved at the end - SyncFileItem newItem(*_item); + auto newItem(*_item); if (oldRecord.isValid()) { newItem._checksumHeader = oldRecord._checksumHeader; } @@ -292,7 +291,7 @@ void PropagateLocalRename::start() return; } } else { - auto dbQueryResult = propagator()->_journal->getFilesBelowPath(oldFile.toUtf8(), [oldFile, this] (const SyncJournalFileRecord &record) -> void { + const auto dbQueryResult = propagator()->_journal->getFilesBelowPath(oldFile.toUtf8(), [oldFile, this] (const SyncJournalFileRecord &record) -> void { const auto oldFileName = record._path; const auto oldFileNameString = QString::fromUtf8(oldFileName); auto newFileNameString = oldFileNameString; @@ -314,7 +313,7 @@ void PropagateLocalRename::start() return; } - auto newItem = SyncFileItem::fromSyncJournalFileRecord(oldRecord); + const auto newItem = SyncFileItem::fromSyncJournalFileRecord(oldRecord); newItem->_file = newFileNameString; const auto result = propagator()->updateMetadata(*newItem); if (!result) { @@ -345,8 +344,7 @@ void PropagateLocalRename::start() bool PropagateLocalRename::deleteOldDbRecord(const QString &fileName) { - SyncJournalFileRecord oldRecord; - if (!propagator()->_journal->getFileRecord(fileName, &oldRecord)) { + if (SyncJournalFileRecord oldRecord; !propagator()->_journal->getFileRecord(fileName, &oldRecord)) { qCWarning(lcPropagateLocalRename) << "could not get file from local DB" << fileName; done(SyncFileItem::NormalError, tr("could not get file %1 from local DB").arg(fileName)); return false;