diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-05-10 13:37:20 +0200 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2021-05-11 10:33:16 +0200 |
commit | 44342fb446216576e3267af928e3789805cd4690 (patch) | |
tree | a15e24366761b6ba9161a5ac613f16819920df05 | |
parent | 0d7e9d95cbfda42e45a484046280f17d5b16df38 (diff) |
qmllint: Fix unknownBuiltins not being ignored in all cases
Previously we only skipped over them when they occurred in a property access chain (not covering the beginning, methods etc.) now we should always ignore them safely.
Change-Id: I405de6d97a15cba1db641b2c8310427cc9558d68
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | tests/auto/qml/qmllint/data/qvariant.qml | 5 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 1 | ||||
-rw-r--r-- | tools/qmllint/checkidentifiers.cpp | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/tests/auto/qml/qmllint/data/qvariant.qml b/tests/auto/qml/qmllint/data/qvariant.qml new file mode 100644 index 0000000000..a9a2978876 --- /dev/null +++ b/tests/auto/qml/qmllint/data/qvariant.qml @@ -0,0 +1,5 @@ +import QtQml + +QtObject { + property int len: Qt.color().length +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 742a6a3c7f..5fd45658f6 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -751,6 +751,7 @@ void TestQmllint::cleanQmlCode_data() QTest::newRow("attachedTypeIndirect") << QStringLiteral("attachedTypeIndirect.qml"); QTest::newRow("objectArray") << QStringLiteral("objectArray.qml"); QTest::newRow("aliasToList") << QStringLiteral("aliasToList.qml"); + QTest::newRow("QVariant") << QStringLiteral("qvariant.qml"); } void TestQmllint::cleanQmlCode() diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp index 4cfcaf91d3..66903c29a8 100644 --- a/tools/qmllint/checkidentifiers.cpp +++ b/tools/qmllint/checkidentifiers.cpp @@ -119,6 +119,9 @@ void CheckIdentifiers::checkMemberAccess(const QVector<FieldMember> &members, return; } + if (unknownBuiltins.contains(scope->internalName())) + return; + const auto property = scope->property(access.m_name); if (!property.propertyName().isEmpty()) { const auto binding = scope->propertyBinding(access.m_name); |