зеркало из https://github.com/nextcloud/desktop.git
Enable the modernize-loop-convert check on clang-tidy
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
Родитель
a5b4922a0e
Коммит
866ffc2a6b
|
@ -4,6 +4,7 @@ Checks: '-*,
|
||||||
modernize-concat-nested-namespaces,
|
modernize-concat-nested-namespaces,
|
||||||
modernize-deprecated-headers,
|
modernize-deprecated-headers,
|
||||||
modernize-deprecated-ios-base-aliases,
|
modernize-deprecated-ios-base-aliases,
|
||||||
|
modernize-loop-convert,
|
||||||
modernize-make-*,
|
modernize-make-*,
|
||||||
modernize-raw-string-literal,
|
modernize-raw-string-literal,
|
||||||
modernize-redundant-void-arg,
|
modernize-redundant-void-arg,
|
||||||
|
|
|
@ -730,8 +730,8 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = undecidedIndexes.begin(); it != undecidedIndexes.end(); ++it) {
|
for (int undecidedIndex : qAsConst(undecidedIndexes)) {
|
||||||
suggestExpand(index(*it, 0, idx));
|
suggestExpand(index(undecidedIndex, 0, idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We need lambda function for the following code.
|
/* 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)
|
void UserModel::addUser(AccountStatePtr &user, const bool &isCurrent)
|
||||||
{
|
{
|
||||||
bool containsUser = false;
|
bool containsUser = false;
|
||||||
for (int i = 0; i < _users.size(); i++) {
|
for (const auto &u : qAsConst(_users)) {
|
||||||
if (_users[i]->account() == user->account()) {
|
if (u->account() == user->account()) {
|
||||||
containsUser = true;
|
containsUser = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ QDataStream &operator<<(QDataStream &stream, const QList<QNetworkCookie> &list)
|
||||||
{
|
{
|
||||||
stream << JAR_VERSION;
|
stream << JAR_VERSION;
|
||||||
stream << quint32(list.size());
|
stream << quint32(list.size());
|
||||||
for (int i = 0; i < list.size(); ++i)
|
for (const auto &cookie : list)
|
||||||
stream << list.at(i).toRawForm();
|
stream << cookie.toRawForm();
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -796,16 +796,16 @@ bool PropagatorCompositeJob::scheduleSelfOrChild()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask all the running composite jobs if they have something new to schedule.
|
// Ask all the running composite jobs if they have something new to schedule.
|
||||||
for (int i = 0; i < _runningJobs.size(); ++i) {
|
for (auto runningJob : qAsConst(_runningJobs)) {
|
||||||
ASSERT(_runningJobs.at(i)->_state == Running);
|
ASSERT(runningJob->_state == Running);
|
||||||
|
|
||||||
if (possiblyRunNextJob(_runningJobs.at(i))) {
|
if (possiblyRunNextJob(runningJob)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If any of the running sub jobs is not parallel, we have to cancel the scheduling
|
// 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.
|
// 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) {
|
if (paral == WaitForFinished) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,9 +193,9 @@ bool PropagateRemoteMove::adjustSelectiveSync(SyncJournalDb *journal, const QStr
|
||||||
QString from = from_ + QLatin1String("/");
|
QString from = from_ + QLatin1String("/");
|
||||||
QString to = to_ + QLatin1String("/");
|
QString to = to_ + QLatin1String("/");
|
||||||
|
|
||||||
for (auto it = list.begin(); it != list.end(); ++it) {
|
for (auto &s : list) {
|
||||||
if (it->startsWith(from)) {
|
if (s.startsWith(from)) {
|
||||||
*it = it->replace(0, from.size(), to);
|
s = s.replace(0, from.size(), to);
|
||||||
changed = true;
|
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
|
// 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
|
// 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.
|
// 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) {
|
for (const auto &serverChunk : qAsConst(_serverChunks)) {
|
||||||
auto job = new DeleteJob(propagator()->account(), Utility::concatUrlPath(chunkUrl(), it->originalName), this);
|
auto job = new DeleteJob(propagator()->account(), Utility::concatUrlPath(chunkUrl(), serverChunk.originalName), this);
|
||||||
QObject::connect(job, &DeleteJob::finishedSignal, this, &PropagateUploadFileNG::slotDeleteJobFinished);
|
QObject::connect(job, &DeleteJob::finishedSignal, this, &PropagateUploadFileNG::slotDeleteJobFinished);
|
||||||
_jobs.append(job);
|
_jobs.append(job);
|
||||||
job->start();
|
job->start();
|
||||||
|
|
|
@ -1086,9 +1086,8 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
|
||||||
_syncItemMap.clear(); // free memory
|
_syncItemMap.clear(); // free memory
|
||||||
|
|
||||||
// Adjust the paths for the renames.
|
// Adjust the paths for the renames.
|
||||||
for (SyncFileItemVector::iterator it = syncItems.begin();
|
for (const auto &syncItem : qAsConst(syncItems)) {
|
||||||
it != syncItems.end(); ++it) {
|
syncItem->_file = adjustRenamedPath(syncItem->_file);
|
||||||
(*it)->_file = adjustRenamedPath((*it)->_file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for invalid character in old server version
|
// Check for invalid character in old server version
|
||||||
|
@ -1104,12 +1103,12 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
|
||||||
}
|
}
|
||||||
if (!invalidFilenamePattern.isEmpty()) {
|
if (!invalidFilenamePattern.isEmpty()) {
|
||||||
const QRegExp invalidFilenameRx(invalidFilenamePattern);
|
const QRegExp invalidFilenameRx(invalidFilenamePattern);
|
||||||
for (auto it = syncItems.begin(); it != syncItems.end(); ++it) {
|
for (const auto &syncItem : qAsConst(syncItems)) {
|
||||||
if ((*it)->_direction == SyncFileItem::Up
|
if (syncItem->_direction == SyncFileItem::Up
|
||||||
&& isFileModifyingInstruction((*it)->_instruction)
|
&& isFileModifyingInstruction(syncItem->_instruction)
|
||||||
&& (*it)->destination().contains(invalidFilenameRx)) {
|
&& syncItem->destination().contains(invalidFilenameRx)) {
|
||||||
(*it)->_errorString = tr("File name contains at least one invalid character");
|
syncItem->_errorString = tr("File name contains at least one invalid character");
|
||||||
(*it)->_instruction = CSYNC_INSTRUCTION_IGNORE;
|
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
|
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) {
|
for (const auto &syncItem : qAsConst(syncItems)) {
|
||||||
if ((*it)->_direction != SyncFileItem::Down)
|
if (syncItem->_direction != SyncFileItem::Down)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch ((*it)->_instruction) {
|
switch (syncItem->_instruction) {
|
||||||
case CSYNC_INSTRUCTION_SYNC:
|
case CSYNC_INSTRUCTION_SYNC:
|
||||||
qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << (*it)->_file;
|
qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << syncItem->_file;
|
||||||
(*it)->_instruction = CSYNC_INSTRUCTION_CONFLICT;
|
syncItem->_instruction = CSYNC_INSTRUCTION_CONFLICT;
|
||||||
break;
|
break;
|
||||||
case CSYNC_INSTRUCTION_REMOVE:
|
case CSYNC_INSTRUCTION_REMOVE:
|
||||||
qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << (*it)->_file;
|
qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << syncItem->_file;
|
||||||
(*it)->_instruction = CSYNC_INSTRUCTION_NEW;
|
syncItem->_instruction = CSYNC_INSTRUCTION_NEW;
|
||||||
(*it)->_direction = SyncFileItem::Up;
|
syncItem->_direction = SyncFileItem::Up;
|
||||||
break;
|
break;
|
||||||
case CSYNC_INSTRUCTION_RENAME:
|
case CSYNC_INSTRUCTION_RENAME:
|
||||||
case CSYNC_INSTRUCTION_NEW:
|
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
|
// Swap into a copy since fileStatus() reads _dirtyPaths to determine the status
|
||||||
QSet<QString> oldDirtyPaths;
|
QSet<QString> oldDirtyPaths;
|
||||||
std::swap(_dirtyPaths, oldDirtyPaths);
|
std::swap(_dirtyPaths, oldDirtyPaths);
|
||||||
for (auto it = oldDirtyPaths.constBegin(); it != oldDirtyPaths.constEnd(); ++it)
|
for (const auto &oldDirtyPath : qAsConst(oldDirtyPaths))
|
||||||
emit fileStatusChanged(getSystemDestination(*it), fileStatus(*it));
|
emit fileStatusChanged(getSystemDestination(oldDirtyPath), fileStatus(oldDirtyPath));
|
||||||
|
|
||||||
// Make sure to push any status that might have been resolved indirectly since the last sync
|
// Make sure to push any status that might have been resolved indirectly since the last sync
|
||||||
// (like an error file being deleted from disk)
|
// (like an error file being deleted from disk)
|
||||||
for (auto it = _syncProblems.begin(); it != _syncProblems.end(); ++it)
|
for (const auto &syncProblem : _syncProblems)
|
||||||
oldProblems.erase(it->first);
|
oldProblems.erase(syncProblem.first);
|
||||||
for (auto it = oldProblems.begin(); it != oldProblems.end(); ++it) {
|
for (const auto &oldProblem : oldProblems) {
|
||||||
const QString &path = it->first;
|
const QString &path = oldProblem.first;
|
||||||
SyncFileStatus::SyncFileStatusTag severity = it->second;
|
SyncFileStatus::SyncFileStatusTag severity = oldProblem.second;
|
||||||
if (severity == SyncFileStatus::StatusError)
|
if (severity == SyncFileStatus::StatusError)
|
||||||
invalidateParentPaths(path);
|
invalidateParentPaths(path);
|
||||||
emit fileStatusChanged(getSystemDestination(path), fileStatus(path));
|
emit fileStatusChanged(getSystemDestination(path), fileStatus(path));
|
||||||
|
|
|
@ -13,9 +13,9 @@ int getRandomNumber(int max) {
|
||||||
|
|
||||||
unsigned int num = 0;
|
unsigned int num = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (unsigned char c : d) {
|
||||||
num = num << 8;
|
num = num << 8;
|
||||||
num += d[i];
|
num += c;
|
||||||
}
|
}
|
||||||
|
|
||||||
return num % max;
|
return num % max;
|
||||||
|
|
|
@ -18,8 +18,8 @@ static void changeAllFileId(FileInfo &info) {
|
||||||
if (!info.isDir)
|
if (!info.isDir)
|
||||||
return;
|
return;
|
||||||
info.etag = generateEtag();
|
info.etag = generateEtag();
|
||||||
for (auto it = info.children.begin(); it != info.children.end(); ++it) {
|
for (auto &child : info.children) {
|
||||||
changeAllFileId(*it);
|
changeAllFileId(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче