diff options
| author | Sami Shalayel <sami.shalayel@qt.io> | 2025-03-21 12:11:28 +0100 |
|---|---|---|
| committer | Sami Shalayel <sami.shalayel@qt.io> | 2025-03-25 22:54:41 +0100 |
| commit | ca0348fad24b4eb3ee2843ae2dae4b9e260d650e (patch) | |
| tree | 71edd34c896ce2bf47d35cfc74af8068d03d5610 /src | |
| parent | 2b720dbe79d8a4a69188f44359dcf44f305b402c (diff) | |
qmllint: fix setting for alias cycle and unresolved alias
Make sure both have their own setting key, but still support the
previous "buggy" setting key. Print a deprecated warning when finding
the buggy setting key in a setting file.
Task-number: QTBUG-135020
Change-Id: I364e7e41380de43a0883bcf4d3f6cefcf11b6c90
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/qmlcompiler/qqmljslogger.cpp | 6 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljsloggingutils.cpp | 23 |
2 files changed, 24 insertions, 5 deletions
diff --git a/src/qmlcompiler/qqmljslogger.cpp b/src/qmlcompiler/qqmljslogger.cpp index b7b5c6153a..e05bf18378 100644 --- a/src/qmlcompiler/qqmljslogger.cpp +++ b/src/qmlcompiler/qqmljslogger.cpp @@ -28,10 +28,10 @@ using namespace Qt::StringLiterals; #define QMLLINT_DEFAULT_CATEGORIES \ X(qmlRequired, "required", "RequiredProperty", "Warn about required properties", QtWarningMsg, \ false, false) \ - X(qmlAliasCycle, "alias-cycle", "PropertyAliasCycles", "Warn about alias cycles", \ + X(qmlAliasCycle, "alias-cycle", "AliasCycle", "Warn about alias cycles", QtWarningMsg, false, \ + false) \ + X(qmlUnresolvedAlias, "unresolved-alias", "UnresolvedAlias", "Warn about unresolved aliases", \ QtWarningMsg, false, false) \ - X(qmlUnresolvedAlias, "unresolved-alias", "PropertyAliasCycles", \ - "Warn about unresolved aliases", QtWarningMsg, false, false) \ X(qmlImport, "import", "ImportFailure", "Warn about failing imports and deprecated qmltypes", \ QtWarningMsg, false, false) \ X(qmlRecursionDepthErrors, "recursion-depth-errors", "ImportFailure", \ diff --git a/src/qmlcompiler/qqmljsloggingutils.cpp b/src/qmlcompiler/qqmljsloggingutils.cpp index 5a75fb7a59..8eecd08242 100644 --- a/src/qmlcompiler/qqmljsloggingutils.cpp +++ b/src/qmlcompiler/qqmljsloggingutils.cpp @@ -173,6 +173,25 @@ static QStringList settingsNamesForCategory(const LoggerCategory &category) return result; } +static QString lookInSettings(const LoggerCategory &category, const QQmlToolingSettings &settings, + const QString &settingsName) +{ + if (settings.isSet(settingsName)) + return settings.value(settingsName).toString(); + static constexpr QLatin1String propertyAliasCyclesKey = "Warnings/PropertyAliasCycles"_L1; + + // keep compatibility to deprecated settings + if (category.name() == qmlAliasCycle.name() || category.name() == qmlUnresolvedAlias.name()) { + if (settings.isSet(propertyAliasCyclesKey)) { + qWarning() + << "Detected deprecated setting name \"PropertyAliasCycles\". Use %1 or %2 instead."_L1 + .arg(qmlAliasCycle.name(), qmlUnresolvedAlias.name()); + return settings.value(propertyAliasCyclesKey).toString(); + } + } + return {}; +} + static QString levelValueForCategory(const LoggerCategory &category, const QQmlToolingSettings &settings, QCommandLineParser *parser) @@ -183,9 +202,9 @@ static QString levelValueForCategory(const LoggerCategory &category, const QStringList settingsName = settingsNamesForCategory(category); for (const QString &settingsName : settingsName) { - if (!settings.isSet(settingsName)) + const QString value = lookInSettings(category, settings, settingsName); + if (value.isEmpty()) continue; - const QString value = settings.value(settingsName).toString(); // Do not try to set the levels if it's due to a default config option. // This way we can tell which options have actually been overwritten by the user. |
