Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
{
ConfigFile configFile;
const auto shouldTryToMigrate = configFile.shouldTryToMigrate();
if (!shouldTryToMigrate) {

Check warning on line 127 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "shouldTryToMigrate" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAM&open=AZ2HjjS4QxzoGwv4YnAM&pullRequest=9830
qCInfo(lcApplication) << "This is not an upgrade/downgrade/migration. Proceed to read current application config file.";
configFile.setMigrationPhase(ConfigFile::MigrationPhase::Done);
return false;
Expand Down Expand Up @@ -300,7 +300,7 @@
qCDebug(lcApplication) << "Failed to move the old config directory to its new location (" << legacyDir << "to" << confDir << ")";

// Try to move the files one by one
if (QFileInfo(confDir).isDir() || QDir().mkdir(confDir)) {

Check failure on line 303 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this TOCTOU race condition window when accessing files

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAO&open=AZ2HjjS4QxzoGwv4YnAO&pullRequest=9830
const QStringList filesList = QDir(legacyDir).entryList(QDir::Files);
qCDebug(lcApplication) << "Will move the individual files" << filesList;
for (const auto &name : filesList) {
Expand All @@ -312,7 +312,7 @@
} else {
#ifndef Q_OS_WIN
// Create a symbolic link so a downgrade of the client would still find the config.
QFile::link(confDir, legacyDir);

Check failure on line 315 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this TOCTOU race condition window when accessing files

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAN&open=AZ2HjjS4QxzoGwv4YnAN&pullRequest=9830
#endif
}
}
Expand All @@ -320,7 +320,7 @@
setupConfigFile();
}

if (_theme->doNotUseProxy()) {

Check warning on line 323 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace "->" with "::" for access to "Theme::doNotUseProxy".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAP&open=AZ2HjjS4QxzoGwv4YnAP&pullRequest=9830
ConfigFile().setProxyType(QNetworkProxy::NoProxy);
const auto &allAccounts = AccountManager::instance()->accounts();
for (const auto &accountState : allAccounts) {
Expand Down Expand Up @@ -418,7 +418,7 @@
_gui->setupCloudProviders();
#endif

if (_theme->doNotUseProxy()) {

Check warning on line 421 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace "->" with "::" for access to "Theme::doNotUseProxy".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAQ&open=AZ2HjjS4QxzoGwv4YnAQ&pullRequest=9830
ConfigFile().setProxyType(QNetworkProxy::NoProxy);
const auto &allAccounts = AccountManager::instance()->accounts();
for (const auto &accountState : allAccounts) {
Expand Down Expand Up @@ -478,6 +478,18 @@

handleEditLocallyFromOptions();

#ifdef Q_OS_MACOS
// If any sync folder needs sandbox reapproval after upgrading to v33+,
// automatically open the settings dialog on the first affected account
// so the user is guided to grant access as quickly as possible.
for (const auto &folder : FolderMan::instance()->map()) {
if (folder->needsSandboxBookmark()) {
QTimer::singleShot(0, _gui.data(), &ownCloudGui::slotShowSettingsForSandboxReapproval);
break;
}
}
#endif

if (AccountSetupCommandLineManager::instance()->isCommandLineParsed()) {
AccountSetupCommandLineManager::instance()->setupAccountFromCommandLine();
}
Expand Down Expand Up @@ -588,7 +600,7 @@
const auto foldersRestoreMessage = foldersListSize > 1
? tr("%1 folders", "number of folders imported").arg(QString::number(foldersListSize))
: tr("1 folder");
const auto messageBox = new QMessageBox(QMessageBox::Information,

Check failure on line 603 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAR&open=AZ2HjjS4QxzoGwv4YnAR&pullRequest=9830
tr("Legacy import"),
tr("Imported %1 and %2 from a legacy desktop client.\n%3",
"number of accounts and folders imported. list of users.")
Expand Down Expand Up @@ -640,11 +652,11 @@
qCDebug(lcApplication) << "Failed to move the old config directory to its new location (" << oldDir << "to" << confDir << ")";

// Try to move the files one by one
if (QFileInfo(confDir).isDir() || QDir().mkdir(confDir)) {

Check failure on line 655 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this TOCTOU race condition window when accessing files

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAU&open=AZ2HjjS4QxzoGwv4YnAU&pullRequest=9830
const QStringList filesList = QDir(oldDir).entryList(QDir::Files);
qCDebug(lcApplication) << "Will move the individual files" << filesList;
for (const auto &name : filesList) {
if (!QFile::rename(oldDir + "/" + name, confDir + "/" + name)) {

Check failure on line 659 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAT&open=AZ2HjjS4QxzoGwv4YnAT&pullRequest=9830
qCDebug(lcApplication) << "Fallback move of " << name << "also failed";
}
}
Expand All @@ -657,9 +669,9 @@
}
}

AccountManager::AccountsRestoreResult Application::restoreLegacyAccount()

Check warning on line 672 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAV&open=AZ2HjjS4QxzoGwv4YnAV&pullRequest=9830
{
ConfigFile cfg;

Check warning on line 674 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "cfg" of type "class OCC::ConfigFile" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAW&open=AZ2HjjS4QxzoGwv4YnAW&pullRequest=9830
const auto tryMigrate = cfg.overrideServerUrl().isEmpty();
auto accountsRestoreResult = AccountManager::AccountsRestoreFailure;
if (accountsRestoreResult = AccountManager::instance()->restore(tryMigrate);
Expand Down Expand Up @@ -736,7 +748,7 @@
// FIXME: This is not ideal yet since a ConnectionValidator might already be running and is in
// progress of timing out in some seconds.
// Maybe we need 2 validators, one triggered by timer, one by network configuration changes?
void Application::slotSystemOnlineConfigurationChanged()

Check warning on line 751 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAX&open=AZ2HjjS4QxzoGwv4YnAX&pullRequest=9830

Check warning on line 751 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAY&open=AZ2HjjS4QxzoGwv4YnAY&pullRequest=9830
{
if (QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Site ||
QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online) {
Expand Down Expand Up @@ -930,7 +942,7 @@
}
} else if (option == QStringLiteral("--overrideserverurl")) {
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
const auto overrideUrl = it.next();

Check warning on line 945 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid this unnecessary copy by using a "const" reference.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAZ&open=AZ2HjjS4QxzoGwv4YnAZ&pullRequest=9830
const auto isUrlValid = (overrideUrl.startsWith(QStringLiteral("http://")) || overrideUrl.startsWith(QStringLiteral("https://")))
&& QUrl::fromUserInput(overrideUrl).isValid();
if (!isUrlValid) {
Expand Down Expand Up @@ -1073,7 +1085,7 @@
{
const ConfigFile cfg;
const auto configLanguage = cfg.language();
if (!configLanguage.isEmpty()) {

Check warning on line 1088 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "configLanguage" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAa&open=AZ2HjjS4QxzoGwv4YnAa&pullRequest=9830
// always prefer value from configuration
return configLanguage;
}
Expand Down Expand Up @@ -1125,8 +1137,8 @@
const QString qtBaseTrFile = QLatin1String("qtbase_") + choosenLanguage;
if (!qtTranslator->load(qtTrFile, qtTrPath)) {
if (!qtTranslator->load(qtTrFile, trPath)) {
if (!qtTranslator->load(qtBaseTrFile, qtTrPath)) {

Check failure on line 1140 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAb&open=AZ2HjjS4QxzoGwv4YnAb&pullRequest=9830
if (!qtTranslator->load(qtBaseTrFile, trPath)) {

Check warning on line 1141 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this "if" statement with the enclosing one.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAd&open=AZ2HjjS4QxzoGwv4YnAd&pullRequest=9830
qCDebug(lcApplication()) << "impossible to load Qt translation catalog" << qtBaseTrFile;
}
}
Expand All @@ -1134,7 +1146,7 @@
}
const QString qtkeychainTrFile = QLatin1String("qtkeychain_") + choosenLanguage;
if (!qtkeychainTranslator->load(qtkeychainTrFile, qtTrPath)) {
if (!qtkeychainTranslator->load(qtkeychainTrFile, trPath)) {

Check warning on line 1149 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this "if" statement with the enclosing one.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAc&open=AZ2HjjS4QxzoGwv4YnAc&pullRequest=9830
qCDebug(lcApplication()) << "impossible to load QtKeychain translation catalog" << qtkeychainTrFile;
}
}
Expand Down Expand Up @@ -1184,7 +1196,7 @@

void Application::openVirtualFile(const QString &filename)
{
QString virtualFileExt = QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX);

Check warning on line 1199 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the redundant type with "auto".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjS4QxzoGwv4YnAe&open=AZ2HjjS4QxzoGwv4YnAe&pullRequest=9830
if (!filename.endsWith(virtualFileExt)) {
qWarning(lcApplication) << "Can only handle file ending in .owncloud. Unable to open" << filename;
return;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderstatusmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2014 ownCloud GmbH
Expand Down Expand Up @@ -66,7 +66,7 @@
connect(FolderMan::instance(), &FolderMan::scheduleQueueChanged,
this, &FolderStatusModel::slotFolderScheduleQueueChanged, Qt::UniqueConnection);

auto folders = FolderMan::instance()->map();

Check warning on line 69 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "folders" of type "class QMap<class QString, class OCC::Folder *>" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_1&open=AZ2HjjPCQxzoGwv4Ym_1&pullRequest=9830
for (const auto &folder : folders) {
if (!accountState) {
break;
Expand All @@ -85,7 +85,7 @@
}

// Sort by header text
std::sort(_folders.begin(), _folders.end(), sortByFolderHeader);

Check warning on line 88 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace with the version of "std::ranges::sort" that takes a range.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_0&open=AZ2HjjPCQxzoGwv4Ym_0&pullRequest=9830

// Set the root _pathIdx after the sorting
for (auto i = 0; i < _folders.size(); ++i) {
Expand Down Expand Up @@ -126,7 +126,7 @@
return Qt::ItemIsEnabled | Qt::ItemNeverHasChildren;
case RootFolder:
return Qt::ItemIsEnabled;
case SubFolder:

Check warning on line 129 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Reduce this switch case number of lines from 8 to at most 5, for example by extracting code into methods.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_2&open=AZ2HjjPCQxzoGwv4Ym_2&pullRequest=9830
if (supportsSelectiveSync) {
if (info && info->_isEncrypted && !_accountState->account()->capabilities().clientSideEncryptionAvailable()) {
return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
Expand Down Expand Up @@ -231,7 +231,7 @@
return {};
}

const auto progress = folderInfo._progress;

Check warning on line 234 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid this unnecessary copy by using a "const" reference.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_6&open=AZ2HjjPCQxzoGwv4Ym_6&pullRequest=9830
const auto accountConnected = _accountState->isConnected();

switch (role) {
Expand All @@ -243,16 +243,16 @@
return (folder->syncResult().hasUnresolvedConflicts())
? QStringList(tr("There are unresolved conflicts. Click for details."))
: QStringList();
case FolderStatusDelegate::FolderErrorMsg: {

Check warning on line 246 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Reduce this switch case number of lines from 11 to at most 5, for example by extracting code into methods.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_5&open=AZ2HjjPCQxzoGwv4Ym_5&pullRequest=9830
auto errors = folder->syncResult().errorStrings();
const auto legacyError = FolderMan::instance()->unsupportedConfiguration(folder->path());
if (!legacyError) {

Check warning on line 249 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "legacyError" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_3&open=AZ2HjjPCQxzoGwv4Ym_3&pullRequest=9830
// the error message might contain new lines, the delegate only expect multiple single line values
errors.append(legacyError.error().split(QLatin1Char('\n')));
}
#ifdef Q_OS_MACOS
if (folder->needsSandboxBookmark()) {
errors.prepend(tr("Select the synchronization folder to restore access."));
errors.prepend(tr("Due to recent security improvements, the client no longer has access to the folder. Your approval is required one time to restore access. Please select the synchronization folder root."));
}
#endif
return errors;
Expand Down Expand Up @@ -287,7 +287,7 @@
toolTip += folderInfo._folder->path();
return toolTip;
}
case FolderStatusDelegate::FolderStatusIconRole: {

Check warning on line 290 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Reduce this switch case number of lines from 18 to at most 5, for example by extracting code into methods.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_4&open=AZ2HjjPCQxzoGwv4Ym_4&pullRequest=9830
if (!accountConnected) {
return Theme::instance()->folderStateIcon(SyncResult::SetupError);
}
Expand Down Expand Up @@ -337,7 +337,7 @@
Q_ASSERT(info->_folder && info->_folder->supportsSelectiveSync());
const auto checked = static_cast<Qt::CheckState>(value.toInt());

if (info->_checked != checked) {

Check warning on line 340 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "checked" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_7&open=AZ2HjjPCQxzoGwv4Ym_7&pullRequest=9830
info->_checked = checked;
if (checked == Qt::Checked) {
// If we are checked, check that we may need to check the parent as well if
Expand Down Expand Up @@ -374,7 +374,7 @@
}

// Uncheck all the children
for (auto i = 0; i < info->_subs.count(); ++i) {

Check failure on line 377 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_8&open=AZ2HjjPCQxzoGwv4Ym_8&pullRequest=9830
if (info->_subs.at(i)._checked != Qt::Unchecked) {
setData(this->index(i, 0, index), Qt::Unchecked, Qt::CheckStateRole);
}
Expand Down Expand Up @@ -408,16 +408,16 @@
if (!parent.isValid()) {
if (Theme::instance()->singleSyncFolder() && _folders.count() != 0) {
// "Add folder" button not visible in the singleSyncFolder configuration.
return _folders.count();

Check warning on line 411 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_t&open=AZ2HjjPCQxzoGwv4Ym_t&pullRequest=9830
}
return _folders.count() + 1; // +1 for the "add folder" button

Check warning on line 413 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_u&open=AZ2HjjPCQxzoGwv4Ym_u&pullRequest=9830
}
const auto info = infoForIndex(parent);
if (!info)
return 0;
if (info->hasLabel())
return 1;
return info->_subs.count();

Check warning on line 420 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_v&open=AZ2HjjPCQxzoGwv4Ym_v&pullRequest=9830
}

FolderStatusModel::ItemType FolderStatusModel::classify(const QModelIndex &index) const
Expand Down Expand Up @@ -470,7 +470,7 @@
return false;
}

QModelIndex FolderStatusModel::indexForPath(Folder *folder, const QString &path) const

Check warning on line 473 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "folder" of type "class OCC::Folder *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_-&open=AZ2HjjPCQxzoGwv4Ym_-&pullRequest=9830

Check failure on line 473 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 26 to the 25 allowed.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_9&open=AZ2HjjPCQxzoGwv4Ym_9&pullRequest=9830
{
if (!folder) {
return {};
Expand Down Expand Up @@ -536,7 +536,7 @@
auto pinfo = static_cast<SubFolderInfo *>(parent.internalPointer());
if (pinfo->_subs.count() <= parent.row())
return {}; // should not happen
auto &info = pinfo->_subs[parent.row()];

Check warning on line 539 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this variable a reference-to-const. The current type of "info" is "struct OCC::FolderStatusModel::SubFolderInfo &".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym__&open=AZ2HjjPCQxzoGwv4Ym__&pullRequest=9830
if (!info.hasLabel()
&& info._subs.count() <= row)
return {}; // should not happen
Expand Down Expand Up @@ -620,7 +620,7 @@
path += infoPath;
}

const auto job = new LsColJob(_accountState->account(), path);

Check failure on line 623 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4YnAA&open=AZ2HjjPCQxzoGwv4YnAA&pullRequest=9830
info->_fetchingJob = job;
const auto props = QList<QByteArray>() << "resourcetype"
<< "http://owncloud.org/ns:size"
Expand Down Expand Up @@ -754,7 +754,7 @@
SubFolderInfo newInfo;
newInfo._folder = parentInfo->_folder;
newInfo._pathIdx = parentInfo->_pathIdx;
newInfo._pathIdx << newSubs.size();

Check warning on line 757 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'parameter_type' (aka 'int')

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_w&open=AZ2HjjPCQxzoGwv4Ym_w&pullRequest=9830
newInfo._isExternal = permissionMap.value(removeTrailingSlash(path)).toString().contains("M"_L1);
newInfo._isEncrypted = encryptionMap.value(removeTrailingSlash(path)).toString() == "1"_L1;
newInfo._path = relativePath;
Expand Down Expand Up @@ -823,7 +823,7 @@
}

if (!newSubs.isEmpty()) {
beginInsertRows(parentIdx, 0, newSubs.size() - 1);

Check warning on line 826 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_x&open=AZ2HjjPCQxzoGwv4Ym_x&pullRequest=9830
parentInfo->_subs = std::move(newSubs);
endInsertRows();
}
Expand All @@ -831,9 +831,9 @@
for (const auto undecidedIndex : std::as_const(undecidedIndexes)) {
emit suggestExpand(index(undecidedIndex, 0, parentIdx));
}
/* Try to remove from the undecided lists the items that are not on the server. */

Check warning on line 834 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Edit this comment to use the C++ format, i.e. "//".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_s&open=AZ2HjjPCQxzoGwv4Ym_s&pullRequest=9830
const auto it = std::remove_if(selectiveSyncUndecidedList.begin(), selectiveSyncUndecidedList.end(),
[&](const QString &s) { return selectiveSyncUndecidedSet.count(s); });

Check warning on line 836 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace with the version of "std::ranges::remove_if" that takes a range.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4YnAE&open=AZ2HjjPCQxzoGwv4YnAE&pullRequest=9830
if (it != selectiveSyncUndecidedList.end()) {
selectiveSyncUndecidedList.erase(it, selectiveSyncUndecidedList.end());
parentInfo->_folder->journalDb()->setSelectiveSyncList(
Expand All @@ -842,7 +842,7 @@
}
}

void FolderStatusModel::slotLscolFinishedWithError(QNetworkReply *reply)

Check warning on line 845 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "reply" is "class QNetworkReply *".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4YnAF&open=AZ2HjjPCQxzoGwv4YnAF&pullRequest=9830

Check warning on line 845 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "reply" of type "class QNetworkReply *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4YnAG&open=AZ2HjjPCQxzoGwv4YnAG&pullRequest=9830
{
const auto job = qobject_cast<LsColJob *>(sender());
ASSERT(job);
Expand Down Expand Up @@ -887,7 +887,7 @@
}
} else {
// We did not load from the server so we reuse the one from the old black list
const auto path = root._path;

Check warning on line 890 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid this unnecessary copy by using a "const" reference.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4YnAH&open=AZ2HjjPCQxzoGwv4YnAH&pullRequest=9830
for (const auto &it : oldBlackList) {
if (it.startsWith(path))
result += it;
Expand Down Expand Up @@ -927,8 +927,8 @@
const auto blackList = createBlackList(folderInfo, oldBlackList);
folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blackList);

auto blackListSet = QSet<QString>{blackList.begin(), blackList.end()};

Check warning on line 930 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "blackListSet" of type "class QSet<class QString>" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4YnAI&open=AZ2HjjPCQxzoGwv4YnAI&pullRequest=9830
auto oldBlackListSet = QSet<QString>{oldBlackList.begin(), oldBlackList.end()};

Check warning on line 931 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "oldBlackListSet" of type "class QSet<class QString>" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4YnAJ&open=AZ2HjjPCQxzoGwv4YnAJ&pullRequest=9830

// The folders that were undecided or blacklisted and that are now checked should go on the white list.
// The user confirmed them already just now.
Expand Down Expand Up @@ -1049,7 +1049,7 @@
curItemProgress = curItem._size;
}

const auto itemFileName = curItem._file;

Check warning on line 1052 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid this unnecessary copy by using a "const" reference.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4YnAK&open=AZ2HjjPCQxzoGwv4YnAK&pullRequest=9830
const auto kindString = Progress::asActionString(curItem);
const auto allFilenames = filenamesList.join(", ");
QString fileProgressString;
Expand Down Expand Up @@ -1151,7 +1151,7 @@
}
}

void FolderStatusModel::slotFolderSyncStateChange(Folder *folder)

Check warning on line 1154 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "folder" of type "class OCC::Folder *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4YnAL&open=AZ2HjjPCQxzoGwv4YnAL&pullRequest=9830
{
if (!folder) {
return;
Expand Down Expand Up @@ -1182,7 +1182,7 @@
pos += 1;
}
}
const auto message = pos <= 0 ? tr("About to start syncing") : tr("Waiting for %n other folder(s) …", "", pos);

Check warning on line 1185 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_y&open=AZ2HjjPCQxzoGwv4Ym_y&pullRequest=9830
pi = SubFolderInfo::Progress();
pi._overallSyncString = message;
} else if (state == SyncResult::SyncPrepare) {
Expand Down Expand Up @@ -1349,7 +1349,7 @@
_hasError = false;
model->endRemoveRows();
} else if (!_subs.isEmpty()) {
model->beginRemoveRows(index, 0, _subs.count() - 1);

Check warning on line 1352 in src/gui/folderstatusmodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2HjjPCQxzoGwv4Ym_z&open=AZ2HjjPCQxzoGwv4Ym_z&pullRequest=9830
_subs.clear();
model->endRemoveRows();
}
Expand Down