remove a few warnings reported by sonarcloud to tidy the code

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2022-11-18 09:19:03 +01:00
parent 37c867bf30
commit ad32bc7ce5
No known key found for this signature in database
GPG key ID: 7D0F74F05C22F553

View file

@ -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;