Skip to content
213 changes: 128 additions & 85 deletions 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 @@ -70,32 +70,56 @@

static const char optionsC[] =
"Options:\n"
"\n"
"General options:\n"
" --help, -h : show this help screen.\n"
" --version, -v : show version information.\n"
" -q --quit : quit the running instance\n"
" --version, -v : show client version/build details.\n"
" --quit, -q : quit the running instance.\n"
" --background : launch the client in the background.\n"
" --reverse : use a reverse layout direction.\n"
"\n"
"Logging options:\n"
" --logwindow, -l : open a window to show log output.\n"
" --logfile <filename> : write log output to file <filename>.\n"
" --logdir <name> : write each sync log output in a new file\n"
" in folder <name>.\n"
" --logexpire <hours> : removes logs older than <hours> hours.\n"
" (to be used with --logdir)\n"
" --logflush : flush the log file after every write.\n"
" --logfile <filename> : write sync logs to the specified filename.\n"
" --logdir <dir> : write sync logs for each run to a new file\n"
" in the specified directory.\n"
" --logexpire <hours> : delete sync logs older than the specified\n"
" number of hours (to be used with --logdir).\n"
" Default: 24 hours.\n"
" --logflush : flush the sync log file after every write.\n"
" --logdebug : also output debug-level messages in the log.\n"
" --confdir <dirname> : Use the given configuration folder.\n"
" --background : launch the application in the background.\n"
" --overrideserverurl : specify a server URL to use for the force override to be used in the account setup wizard.\n"
" --overridelocaldir : specify a local dir to be used in the account setup wizard.\n"
" --userid : userId (username as on the server) to pass when creating an account via command-line.\n"
" --apppassword : appPassword to pass when creating an account via command-line.\n"
" --set-language <lang> : specify a language to use for the client, regardless of the OS language.\n"
" --localdirpath : (optional) path where to create a local sync folder when creating an account via command-line.\n"
" --isvfsenabled : whether to set a VFS or non-VFS folder (1 for 'yes' or 0 for 'no') when creating an account via command-line.\n"
" --remotedirpath : (optional) path to a remote subfolder when creating an account via command-line.\n"
" --serverurl : a server URL to use when creating an account via command-line.\n"
"\n"
"Configuration options:\n"
" --confdir <dir> : override the default client configuration\n"
" directory.\n"
" --set-language <lang> : use this language for the client, regardless\n"
" of the OS language.\n"
" --debug : enable debug mode and debug-level logging.\n"
#if !DISABLE_ACCOUNT_MIGRATION
" --forcelegacyconfigimport : forcefully import account configurations from legacy clients (if available).\n"
" --forcelegacyconfigimport : forcefully import account configurations from\n"
" legacy clients (if available).\n"
#endif
" --reverse : use a reverse layout direction.\n";
"\n"
"Account setup wizard options:\n"
" --overrideserverurl <url> : server URL used by the interactive account\n"
" setup wizard.\n"
" --overridelocaldir <dir> : local directory used by the interactive\n"
" account setup wizard.\n"
"\n"
"Non-interactive account provisioning options:\n"
" --serverurl <url> : server URL to use during non-interactive\n"
" account provisioning.\n"
" --userid <userid> : server-side user ID to use during\n"
" non-interactive account provisioning.\n"
" --apppassword <pass> : server-side app password to use during\n"
" non-interactive account provisioning.\n"
" --localdirpath <dir> : local sync directory to use during\n"
" non-interactive account provisioning.\n"
" --remotedirpath <dir> : server-side directory to set up for syncing\n"
" during non-interactive account provisioning.\n"
" --isvfsenabled <0|1> : toggle virtual files support (1 = yes,\n"
" 0 = no) during non-interactive account\n"
" provisioning.\n";

QString applicationTrPath()
{
Expand Down Expand Up @@ -125,7 +149,7 @@
{
ConfigFile configFile;
const auto shouldTryToMigrate = configFile.shouldTryToMigrate();
if (!shouldTryToMigrate) {

Check warning on line 152 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=AZ5GNEaM2NDva-OwA1kT&open=AZ5GNEaM2NDva-OwA1kT&pullRequest=10069
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 @@ -301,7 +325,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 328 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=AZ5GNEaM2NDva-OwA1kV&open=AZ5GNEaM2NDva-OwA1kV&pullRequest=10069
const QStringList filesList = QDir(legacyDir).entryList(QDir::Files);
qCDebug(lcApplication) << "Will move the individual files" << filesList;
for (const auto &name : filesList) {
Expand All @@ -313,7 +337,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 340 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=AZ5GNEaM2NDva-OwA1kU&open=AZ5GNEaM2NDva-OwA1kU&pullRequest=10069
#endif
}
}
Expand All @@ -321,7 +345,7 @@
setupConfigFile();
}

if (_theme->doNotUseProxy()) {

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

if (_theme->doNotUseProxy()) {

Check warning on line 446 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=AZ5GNEaM2NDva-OwA1kX&open=AZ5GNEaM2NDva-OwA1kX&pullRequest=10069
ConfigFile().setProxyType(QNetworkProxy::NoProxy);
const auto &allAccounts = AccountManager::instance()->accounts();
for (const auto &accountState : allAccounts) {
Expand Down Expand Up @@ -609,7 +633,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 636 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=AZ5GNEaM2NDva-OwA1kY&open=AZ5GNEaM2NDva-OwA1kY&pullRequest=10069
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 All @@ -626,7 +650,7 @@
qCWarning(lcApplication) << accountsListSize << "account(s) migrated:" << prettyNamesList(accounts);
}

void Application::setupConfigFile()

Check warning on line 653 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=AZ5GNEaM2NDva-OwA1kZ&open=AZ5GNEaM2NDva-OwA1kZ&pullRequest=10069
{
// Migrate from version <= 2.4
setApplicationName(_theme->appNameGUI());
Expand Down Expand Up @@ -661,11 +685,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 688 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=AZ5GNEaM2NDva-OwA1kb&open=AZ5GNEaM2NDva-OwA1kb&pullRequest=10069
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 692 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=AZ5GNEaM2NDva-OwA1ka&open=AZ5GNEaM2NDva-OwA1ka&pullRequest=10069
qCDebug(lcApplication) << "Fallback move of " << name << "also failed";
}
}
Expand All @@ -678,9 +702,9 @@
}
}

AccountManager::AccountsRestoreResult Application::restoreLegacyAccount()

Check warning on line 705 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=AZ5GNEaM2NDva-OwA1kc&open=AZ5GNEaM2NDva-OwA1kc&pullRequest=10069
{
ConfigFile cfg;

Check warning on line 707 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=AZ5GNEaM2NDva-OwA1kd&open=AZ5GNEaM2NDva-OwA1kd&pullRequest=10069
const auto tryMigrate = cfg.overrideServerUrl().isEmpty();
auto accountsRestoreResult = AccountManager::AccountsRestoreFailure;
if (accountsRestoreResult = AccountManager::instance()->restore(tryMigrate);
Expand Down Expand Up @@ -757,7 +781,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 784 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=AZ5GNEaM2NDva-OwA1ke&open=AZ5GNEaM2NDva-OwA1ke&pullRequest=10069

Check warning on line 784 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=AZ5GNEaM2NDva-OwA1kf&open=AZ5GNEaM2NDva-OwA1kf&pullRequest=10069
{
if (QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Site ||
QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online) {
Expand Down Expand Up @@ -880,119 +904,138 @@
void Application::parseOptions(const QStringList &options)
{
QStringListIterator it(options);
// skip file name;
// skip file name
if (it.hasNext()) {
it.next();
}

bool shouldExit = false;
const auto hasNextValue = [&it]() {
return it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"));
};

//parse options; if help or bad option exit
const auto isOption = [](const QString &option, const char *name, const char *shortName = nullptr) {

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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "shortName" of type "const char *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5GNEaM2NDva-OwA1kj&open=AZ5GNEaM2NDva-OwA1kj&pullRequest=10069

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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "name" of type "const char *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5GNEaM2NDva-OwA1ki&open=AZ5GNEaM2NDva-OwA1ki&pullRequest=10069
return option == QLatin1String(name)
|| (shortName && option == QLatin1String(shortName));
};

// parse options; if help or bad option exit
while (it.hasNext()) {
QString option = it.next();
if (option == QLatin1String("--help") || option == QLatin1String("-h")) {

// Help / version / exit-related
if (isOption(option, "--help", "-h")) {
setHelp();
break;
} else if (option == QLatin1String("--quit") || option == QLatin1String("-q")) {
} else if (isOption(option, "--version", "-v")) {
_versionOnly = true;
} else if (isOption(option, "--quit", "-q")) {
_quitInstance = true;
} else if (option == QLatin1String("--logwindow") || option == QLatin1String("-l")) {

// Simple boolean toggles
} else if (isOption(option, "--logwindow", "-l")) {
_showLogWindow = true;
} else if (option == QLatin1String("--logfile")) {
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
} else if (isOption(option, "--logflush")) {
_logFlush = true;
} else if (isOption(option, "--logdebug")) {
_logDebug = true;
} else if (isOption(option, "--background")) {
_backgroundMode = true;
} else if (isOption(option, "--reverse")) {
// FIXME: This is current implemented as a toggle, but help text suggests it should set RTL

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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Take the required action to fix the issue indicated by this "FIXME" comment.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5GNEaM2NDva-OwA1kR&open=AZ5GNEaM2NDva-OwA1kR&pullRequest=10069

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad
it should reverse the usual direction allowing use of French locale (for example) to test RTL layout
maybe you can fix the description of the option ?

setLayoutDirection(layoutDirection() == Qt::LeftToRight ? Qt::RightToLeft : Qt::LeftToRight);
} else if (isOption(option, "--debug")) {
_logDebug = true;
_debugMode = true;

// Value options
} else if (isOption(option, "--logfile")) {
if (hasNextValue()) {
_logFile = it.next();
} else {
showHint("Log file not specified");
showHint("Missing value for --logfile");
}
} else if (option == QLatin1String("--logdir")) {
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
} else if (isOption(option, "--logdir")) {
if (hasNextValue()) {
_logDir = it.next();
} else {
showHint("Log dir not specified");
showHint("Missing value for --logdir");
}
} else if (option == QLatin1String("--logexpire")) {
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
_logExpire = it.next().toInt();
} else if (isOption(option, "--logexpire")) {
if (hasNextValue()) {
bool ok = false;
const auto logExpire = it.next().toInt(&ok);
if (!ok) {

Check failure on line 967 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=AZ5GNEaM2NDva-OwA1kh&open=AZ5GNEaM2NDva-OwA1kh&pullRequest=10069
showHint("Invalid value passed to --logexpire");
}
_logExpire = logExpire;
} else {
showHint("Log expiration not specified");
showHint("Missing value for --logexpire");
}
} else if (option == QLatin1String("--logflush")) {
_logFlush = true;
} else if (option == QLatin1String("--logdebug")) {
_logDebug = true;
} else if (option == QLatin1String("--confdir")) {
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
} else if (isOption(option, "--confdir")) {
if (hasNextValue()) {
QString confDir = it.next();
if (!ConfigFile::setConfDir(confDir)) {
showHint("Invalid path passed to --confdir");
}
} else {
showHint("Path for confdir not specified");
}
} else if (option == QLatin1String("--debug")) {
_logDebug = true;
_debugMode = true;
} else if (option == QLatin1String("--background")) {
_backgroundMode = true;
} else if (option == QLatin1String("--version") || option == QLatin1String("-v")) {
_versionOnly = true;
} else if (option == QLatin1String("--reverse")) {
setLayoutDirection(layoutDirection() == Qt::LeftToRight ? Qt::RightToLeft : Qt::LeftToRight);
} else if (option.endsWith(QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX))) {
// virtual file, open it after the Folder were created (if the app is not terminated)
QTimer::singleShot(0, this, [this, option] { openVirtualFile(option); });
} else if (option.startsWith(QStringLiteral(APPLICATION_URI_HANDLER_SCHEME "://open"))) {
// see the section Local file editing of the Architecture page of the user documentation
_editFileLocallyUrl = QUrl::fromUserInput(option);
if (!_editFileLocallyUrl.isValid()) {
_editFileLocallyUrl.clear();
const auto errorParsingLocalFileEditingUrl = QStringLiteral("The supplied url for local file editing '%1' is invalid!").arg(option);
qCInfo(lcApplication) << errorParsingLocalFileEditingUrl;
showHint(errorParsingLocalFileEditingUrl.toStdString());
showHint("Missing value for --confdir");
}
} else if (option == QStringLiteral("--overrideserverurl")) {
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
} else if (isOption(option, "--overrideserverurl")) {
if (hasNextValue()) {
const auto overrideUrl = it.next();

Check warning on line 985 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=AZ5GNEaM2NDva-OwA1kk&open=AZ5GNEaM2NDva-OwA1kk&pullRequest=10069
const auto isUrlValid = (overrideUrl.startsWith(QStringLiteral("http://")) || overrideUrl.startsWith(QStringLiteral("https://")))
const auto isUrlValid =
(overrideUrl.startsWith(QStringLiteral("http://"))
|| overrideUrl.startsWith(QStringLiteral("https://")))
&& QUrl::fromUserInput(overrideUrl).isValid();
if (!isUrlValid) {

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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5GNEaM2NDva-OwA1kg&open=AZ5GNEaM2NDva-OwA1kg&pullRequest=10069
showHint("Invalid URL passed to --overrideserverurl");
shouldExit = true;
} else {
_overrideServerUrl = overrideUrl;
}
_overrideServerUrl = overrideUrl;
} else {
showHint("Invalid URL passed to --overrideserverurl");
showHint("Missing value for --overrideserverurl");
}
} else if (option == QStringLiteral("--overridelocaldir")) {
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
} else if (isOption(option, "--overridelocaldir")) {
if (hasNextValue()) {
// FIXME: validate specified path

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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Take the required action to fix the issue indicated by this "FIXME" comment.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5GNEaM2NDva-OwA1kS&open=AZ5GNEaM2NDva-OwA1kS&pullRequest=10069
_overrideLocalDir = it.next();
} else {
showHint("Invalid URL passed to --overridelocaldir");
showHint("Missing value for --overridelocaldir");
}
} else if (option == QStringLiteral("--set-language")) {
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
} else if (isOption(option, "--set-language")) {
if (hasNextValue()) {
_setLanguage = it.next();
} else {
showHint("Missing value for --set-language");
}

// Special startup handlers
} else if (option.endsWith(QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX))) {
// virtual file, open it after the Folder were created (if the app is not terminated)
QTimer::singleShot(0, this, [this, option] { openVirtualFile(option); });
} else if (option.startsWith(QStringLiteral(APPLICATION_URI_HANDLER_SCHEME "://open"))) {
// see the section Local file editing of the Architecture page of the user documentation
_editFileLocallyUrl = QUrl::fromUserInput(option);
if (!_editFileLocallyUrl.isValid()) {
_editFileLocallyUrl.clear();
const auto errorParsingLocalFileEditingUrl =
QStringLiteral("The supplied url for local file editing '%1' is invalid!").arg(option);
qCInfo(lcApplication) << errorParsingLocalFileEditingUrl;
showHint(errorParsingLocalFileEditingUrl.toStdString());
}
}
#if !DISABLE_ACCOUNT_MIGRATION
else if (option == QStringLiteral("--forcelegacyconfigimport")) {
} else if (isOption(option, "--forcelegacyconfigimport")) {
AccountManager::instance()->setForceLegacyImport(true);
}
#endif
else {
} else {
QString errorMessage;
if (!AccountSetupCommandLineManager::instance()->parseCommandlineOption(option, it, errorMessage)) {
if (!errorMessage.isEmpty()) {
showHint(errorMessage.toStdString());
return;
}
showHint("Unrecognized option '" + option.toStdString() + "'");
}
}
}
if (shouldExit) {
std::exit(0);
}
}

// Helpers for displaying messages. Note that there is no console on Windows.
Expand Down Expand Up @@ -1094,7 +1137,7 @@
{
const ConfigFile cfg;
const auto configLanguage = cfg.language();
if (!configLanguage.isEmpty()) {

Check warning on line 1140 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=AZ5GNEaM2NDva-OwA1kl&open=AZ5GNEaM2NDva-OwA1kl&pullRequest=10069
// always prefer value from configuration
return configLanguage;
}
Expand Down Expand Up @@ -1146,8 +1189,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 1192 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=AZ5GNEaM2NDva-OwA1km&open=AZ5GNEaM2NDva-OwA1km&pullRequest=10069
if (!qtTranslator->load(qtBaseTrFile, trPath)) {

Check warning on line 1193 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=AZ5GNEaM2NDva-OwA1ko&open=AZ5GNEaM2NDva-OwA1ko&pullRequest=10069
qCDebug(lcApplication()) << "impossible to load Qt translation catalog" << qtBaseTrFile;
}
}
Expand All @@ -1155,7 +1198,7 @@
}
const QString qtkeychainTrFile = QLatin1String("qtkeychain_") + choosenLanguage;
if (!qtkeychainTranslator->load(qtkeychainTrFile, qtTrPath)) {
if (!qtkeychainTranslator->load(qtkeychainTrFile, trPath)) {

Check warning on line 1201 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=AZ5GNEaM2NDva-OwA1kn&open=AZ5GNEaM2NDva-OwA1kn&pullRequest=10069
qCDebug(lcApplication()) << "impossible to load QtKeychain translation catalog" << qtkeychainTrFile;
}
}
Expand Down Expand Up @@ -1205,7 +1248,7 @@

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

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