Enable the modernize-loop-convert check on clang-tidy

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
Kevin Ottens 2020-08-13 12:23:02 +02:00 коммит произвёл Kevin Ottens (Rebase PR Action)
Родитель a5b4922a0e
Коммит 866ffc2a6b
11 изменённых файлов: 43 добавлений и 43 удалений

Просмотреть файл

@ -4,6 +4,7 @@ Checks: '-*,
modernize-concat-nested-namespaces,
modernize-deprecated-headers,
modernize-deprecated-ios-base-aliases,
modernize-loop-convert,
modernize-make-*,
modernize-raw-string-literal,
modernize-redundant-void-arg,

Просмотреть файл

@ -730,8 +730,8 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
endInsertRows();
}
for (auto it = undecidedIndexes.begin(); it != undecidedIndexes.end(); ++it) {
suggestExpand(index(*it, 0, idx));
for (int undecidedIndex : qAsConst(undecidedIndexes)) {
suggestExpand(index(undecidedIndex, 0, idx));
}
/* We need lambda function for the following code.

Просмотреть файл

@ -605,8 +605,8 @@ Q_INVOKABLE QString UserModel::currentUserServer()
void UserModel::addUser(AccountStatePtr &user, const bool &isCurrent)
{
bool containsUser = false;
for (int i = 0; i < _users.size(); i++) {
if (_users[i]->account() == user->account()) {
for (const auto &u : qAsConst(_users)) {
if (u->account() == user->account()) {
containsUser = true;
continue;
}

Просмотреть файл

@ -34,8 +34,8 @@ QDataStream &operator<<(QDataStream &stream, const QList<QNetworkCookie> &list)
{
stream << JAR_VERSION;
stream << quint32(list.size());
for (int i = 0; i < list.size(); ++i)
stream << list.at(i).toRawForm();
for (const auto &cookie : list)
stream << cookie.toRawForm();
return stream;
}

Просмотреть файл

@ -796,16 +796,16 @@ bool PropagatorCompositeJob::scheduleSelfOrChild()
}
// Ask all the running composite jobs if they have something new to schedule.
for (int i = 0; i < _runningJobs.size(); ++i) {
ASSERT(_runningJobs.at(i)->_state == Running);
for (auto runningJob : qAsConst(_runningJobs)) {
ASSERT(runningJob->_state == Running);
if (possiblyRunNextJob(_runningJobs.at(i))) {
if (possiblyRunNextJob(runningJob)) {
return true;
}
// If any of the running sub jobs is not parallel, we have to cancel the scheduling
// of the rest of the list and wait for the blocking job to finish and schedule the next one.
auto paral = _runningJobs.at(i)->parallelism();
auto paral = runningJob->parallelism();
if (paral == WaitForFinished) {
return false;
}

Просмотреть файл

@ -193,9 +193,9 @@ bool PropagateRemoteMove::adjustSelectiveSync(SyncJournalDb *journal, const QStr
QString from = from_ + QLatin1String("/");
QString to = to_ + QLatin1String("/");
for (auto it = list.begin(); it != list.end(); ++it) {
if (it->startsWith(from)) {
*it = it->replace(0, from.size(), to);
for (auto &s : list) {
if (s.startsWith(from)) {
s = s.replace(0, from.size(), to);
changed = true;
}
}

Просмотреть файл

@ -157,8 +157,8 @@ void PropagateUploadFileNG::slotPropfindFinished()
// Make sure that if there is a "hole" and then a few more chunks, on the server
// we should remove the later chunks. Otherwise when we do dynamic chunk sizing, we may end up
// with corruptions if there are too many chunks, or if we abort and there are still stale chunks.
for (auto it = _serverChunks.begin(); it != _serverChunks.end(); ++it) {
auto job = new DeleteJob(propagator()->account(), Utility::concatUrlPath(chunkUrl(), it->originalName), this);
for (const auto &serverChunk : qAsConst(_serverChunks)) {
auto job = new DeleteJob(propagator()->account(), Utility::concatUrlPath(chunkUrl(), serverChunk.originalName), this);
QObject::connect(job, &DeleteJob::finishedSignal, this, &PropagateUploadFileNG::slotDeleteJobFinished);
_jobs.append(job);
job->start();

Просмотреть файл

@ -1086,9 +1086,8 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
_syncItemMap.clear(); // free memory
// Adjust the paths for the renames.
for (SyncFileItemVector::iterator it = syncItems.begin();
it != syncItems.end(); ++it) {
(*it)->_file = adjustRenamedPath((*it)->_file);
for (const auto &syncItem : qAsConst(syncItems)) {
syncItem->_file = adjustRenamedPath(syncItem->_file);
}
// Check for invalid character in old server version
@ -1104,12 +1103,12 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
}
if (!invalidFilenamePattern.isEmpty()) {
const QRegExp invalidFilenameRx(invalidFilenamePattern);
for (auto it = syncItems.begin(); it != syncItems.end(); ++it) {
if ((*it)->_direction == SyncFileItem::Up
&& isFileModifyingInstruction((*it)->_instruction)
&& (*it)->destination().contains(invalidFilenameRx)) {
(*it)->_errorString = tr("File name contains at least one invalid character");
(*it)->_instruction = CSYNC_INSTRUCTION_IGNORE;
for (const auto &syncItem : qAsConst(syncItems)) {
if (syncItem->_direction == SyncFileItem::Up
&& isFileModifyingInstruction(syncItem->_instruction)
&& syncItem->destination().contains(invalidFilenameRx)) {
syncItem->_errorString = tr("File name contains at least one invalid character");
syncItem->_instruction = CSYNC_INSTRUCTION_IGNORE;
}
}
}
@ -1677,19 +1676,19 @@ void SyncEngine::restoreOldFiles(SyncFileItemVector &syncItems)
upload the client file. But we still downloaded the old file in a conflict file just in case
*/
for (auto it = syncItems.begin(); it != syncItems.end(); ++it) {
if ((*it)->_direction != SyncFileItem::Down)
for (const auto &syncItem : qAsConst(syncItems)) {
if (syncItem->_direction != SyncFileItem::Down)
continue;
switch ((*it)->_instruction) {
switch (syncItem->_instruction) {
case CSYNC_INSTRUCTION_SYNC:
qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << (*it)->_file;
(*it)->_instruction = CSYNC_INSTRUCTION_CONFLICT;
qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << syncItem->_file;
syncItem->_instruction = CSYNC_INSTRUCTION_CONFLICT;
break;
case CSYNC_INSTRUCTION_REMOVE:
qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << (*it)->_file;
(*it)->_instruction = CSYNC_INSTRUCTION_NEW;
(*it)->_direction = SyncFileItem::Up;
qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << syncItem->_file;
syncItem->_instruction = CSYNC_INSTRUCTION_NEW;
syncItem->_direction = SyncFileItem::Up;
break;
case CSYNC_INSTRUCTION_RENAME:
case CSYNC_INSTRUCTION_NEW:

Просмотреть файл

@ -244,16 +244,16 @@ void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector &items)
// Swap into a copy since fileStatus() reads _dirtyPaths to determine the status
QSet<QString> oldDirtyPaths;
std::swap(_dirtyPaths, oldDirtyPaths);
for (auto it = oldDirtyPaths.constBegin(); it != oldDirtyPaths.constEnd(); ++it)
emit fileStatusChanged(getSystemDestination(*it), fileStatus(*it));
for (const auto &oldDirtyPath : qAsConst(oldDirtyPaths))
emit fileStatusChanged(getSystemDestination(oldDirtyPath), fileStatus(oldDirtyPath));
// Make sure to push any status that might have been resolved indirectly since the last sync
// (like an error file being deleted from disk)
for (auto it = _syncProblems.begin(); it != _syncProblems.end(); ++it)
oldProblems.erase(it->first);
for (auto it = oldProblems.begin(); it != oldProblems.end(); ++it) {
const QString &path = it->first;
SyncFileStatus::SyncFileStatusTag severity = it->second;
for (const auto &syncProblem : _syncProblems)
oldProblems.erase(syncProblem.first);
for (const auto &oldProblem : oldProblems) {
const QString &path = oldProblem.first;
SyncFileStatus::SyncFileStatusTag severity = oldProblem.second;
if (severity == SyncFileStatus::StatusError)
invalidateParentPaths(path);
emit fileStatusChanged(getSystemDestination(path), fileStatus(path));

Просмотреть файл

@ -13,9 +13,9 @@ int getRandomNumber(int max) {
unsigned int num = 0;
for (int i = 0; i < 8; i++) {
for (unsigned char c : d) {
num = num << 8;
num += d[i];
num += c;
}
return num % max;

Просмотреть файл

@ -18,8 +18,8 @@ static void changeAllFileId(FileInfo &info) {
if (!info.isDir)
return;
info.etag = generateEtag();
for (auto it = info.children.begin(); it != info.children.end(); ++it) {
changeAllFileId(*it);
for (auto &child : info.children) {
changeAllFileId(child);
}
}