Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/gui/application.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 @@ -125,7 +125,7 @@
{
ConfigFile configFile;
const auto shouldTryToMigrate = configFile.shouldTryToMigrate();
if (!shouldTryToMigrate) {

Check warning on line 128 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=AZ8clfaQGT3uPLl7RN-S&open=AZ8clfaQGT3uPLl7RN-S&pullRequest=10277
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 @@ -310,7 +310,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 313 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=AZ8clfaQGT3uPLl7RN-U&open=AZ8clfaQGT3uPLl7RN-U&pullRequest=10277
const QStringList filesList = QDir(legacyDir).entryList(QDir::Files);
qCDebug(lcApplication) << "Will move the individual files" << filesList;
for (const auto &name : filesList) {
Expand All @@ -322,7 +322,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 325 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=AZ8clfaQGT3uPLl7RN-T&open=AZ8clfaQGT3uPLl7RN-T&pullRequest=10277
#endif
}
}
Expand All @@ -330,7 +330,7 @@
setupConfigFile();
}

if (_theme->doNotUseProxy()) {

Check warning on line 333 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=AZ8clfaQGT3uPLl7RN-V&open=AZ8clfaQGT3uPLl7RN-V&pullRequest=10277
ConfigFile().setProxyType(QNetworkProxy::NoProxy);
const auto &allAccounts = AccountManager::instance()->accounts();
for (const auto &accountState : allAccounts) {
Expand Down Expand Up @@ -430,7 +430,7 @@
_gui->setupCloudProviders();
#endif

if (_theme->doNotUseProxy()) {

Check warning on line 433 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=AZ8clfaQGT3uPLl7RN-W&open=AZ8clfaQGT3uPLl7RN-W&pullRequest=10277
ConfigFile().setProxyType(QNetworkProxy::NoProxy);
const auto &allAccounts = AccountManager::instance()->accounts();
for (const auto &accountState : allAccounts) {
Expand Down Expand Up @@ -620,7 +620,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 623 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=AZ8clfaQGT3uPLl7RN-X&open=AZ8clfaQGT3uPLl7RN-X&pullRequest=10277
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 @@ -674,7 +674,7 @@
AccountSetupCommandLineManager::destroy();
}

void Application::setupConfigFile()

Check warning on line 677 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=AZ8clfaQGT3uPLl7RN-Y&open=AZ8clfaQGT3uPLl7RN-Y&pullRequest=10277
{
// Migrate from version <= 2.4
setApplicationName(_theme->appNameGUI());
Expand Down Expand Up @@ -709,11 +709,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 712 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=AZ8clfaQGT3uPLl7RN-a&open=AZ8clfaQGT3uPLl7RN-a&pullRequest=10277
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 716 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=AZ8clfaQGT3uPLl7RN-Z&open=AZ8clfaQGT3uPLl7RN-Z&pullRequest=10277
qCDebug(lcApplication) << "Fallback move of " << name << "also failed";
}
}
Expand All @@ -726,9 +726,9 @@
}
}

AccountManager::AccountsRestoreResult Application::restoreLegacyAccount()

Check warning on line 729 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=AZ8clfaQGT3uPLl7RN-b&open=AZ8clfaQGT3uPLl7RN-b&pullRequest=10277
{
ConfigFile cfg;

Check warning on line 731 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=AZ8clfaQGT3uPLl7RN-c&open=AZ8clfaQGT3uPLl7RN-c&pullRequest=10277
const auto tryMigrate = cfg.overrideServerUrl().isEmpty();
auto accountsRestoreResult = AccountManager::AccountsRestoreFailure;
if (accountsRestoreResult = AccountManager::instance()->restore(tryMigrate);
Expand Down Expand Up @@ -805,7 +805,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 808 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=AZ8clfaQGT3uPLl7RN-d&open=AZ8clfaQGT3uPLl7RN-d&pullRequest=10277

Check warning on line 808 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=AZ8clfaQGT3uPLl7RN-e&open=AZ8clfaQGT3uPLl7RN-e&pullRequest=10277
{
if (QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Site ||
QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online) {
Expand Down Expand Up @@ -881,7 +881,8 @@
<< "locale:" << QLocale::system().name()
<< "ui_lang:" << property("ui_lang")
<< "version:" << _theme->version()
<< "os:" << Utility::platformName();
<< "os:" << Utility::platformName()
<< "platform:" << QApplication::platformName();
qCInfo(lcApplication) << "Arguments:" << qApp->arguments();
}

Expand Down Expand Up @@ -982,7 +983,7 @@
}
} else if (option == QStringLiteral("--overrideserverurl")) {
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
const auto overrideUrl = it.next();

Check warning on line 986 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=AZ8clfaQGT3uPLl7RN-f&open=AZ8clfaQGT3uPLl7RN-f&pullRequest=10277
const auto isUrlValid = (overrideUrl.startsWith(QStringLiteral("http://")) || overrideUrl.startsWith(QStringLiteral("https://")))
&& QUrl::fromUserInput(overrideUrl).isValid();
if (!isUrlValid) {
Expand Down Expand Up @@ -1135,7 +1136,7 @@
{
const ConfigFile cfg;
const auto configLanguage = cfg.language();
if (!configLanguage.isEmpty()) {

Check warning on line 1139 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=AZ8clfaQGT3uPLl7RN-g&open=AZ8clfaQGT3uPLl7RN-g&pullRequest=10277
// always prefer value from configuration
return configLanguage;
}
Expand Down Expand Up @@ -1187,8 +1188,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 1191 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=AZ8clfaQGT3uPLl7RN-h&open=AZ8clfaQGT3uPLl7RN-h&pullRequest=10277
if (!qtTranslator->load(qtBaseTrFile, trPath)) {

Check warning on line 1192 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=AZ8clfaQGT3uPLl7RN-j&open=AZ8clfaQGT3uPLl7RN-j&pullRequest=10277
qCDebug(lcApplication()) << "impossible to load Qt translation catalog" << qtBaseTrFile;
}
}
Expand All @@ -1196,7 +1197,7 @@
}
const QString qtkeychainTrFile = QLatin1String("qtkeychain_") + choosenLanguage;
if (!qtkeychainTranslator->load(qtkeychainTrFile, qtTrPath)) {
if (!qtkeychainTranslator->load(qtkeychainTrFile, trPath)) {

Check warning on line 1200 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=AZ8clfaQGT3uPLl7RN-i&open=AZ8clfaQGT3uPLl7RN-i&pullRequest=10277
qCDebug(lcApplication()) << "impossible to load QtKeychain translation catalog" << qtkeychainTrFile;
}
}
Expand Down Expand Up @@ -1246,7 +1247,7 @@

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

Check warning on line 1250 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=AZ8clfaQGT3uPLl7RN-k&open=AZ8clfaQGT3uPLl7RN-k&pullRequest=10277
if (!filename.endsWith(virtualFileExt)) {
qWarning(lcApplication) << "Can only handle file ending in .owncloud. Unable to open" << filename;
return;
Expand Down
Loading