aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmllint/tst_qmllint.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QML: Warn about variables being used before their declarationUlf Hermann2021-02-111-0/+5
| | | | | | | | | | | | | | | | | | This collides with injected signal parameters. qmlcachegen cannot tell those cases apart. [ChangeLog][QML][Important Behavior Changes] QML warns about JavaScript variables being used before their declaration now. This is almost always a mistake. It is particularly dangerous in the presence of injected signal parameters because qmlcachegen cannot identify a name collision between an injected signal parameter and a variable being used before its declaration. It therefore miscompiles such code. You can turn off the deprecation warning using the "qt.qml.compiler" logging category. Pick-to: 6.1 Task-number: QTBUG-89943 Change-Id: I8a9424ca8c6edd562402fe5c560ba7e8344b5585 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use QLibraryInfo::QmlImportsPath rather than Qml2ImportsPathUlf Hermann2021-02-091-2/+2
| | | | | | | | | The "2" is meaningless and there is a better name available now. Task-number: QTBUG-85064 Change-Id: I65d26b06712ed7dcf2825f16dffaa6060dd86985 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* qmllint: Fix segmentation faultMaximilian Goldstein2021-02-031-0/+10
| | | | | | Pick-to: 6.0 Change-Id: Ie04ad4221b25628687c2575facf90488b83d21bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow for multiple extensions per objectUlf Hermann2021-02-011-0/+1
| | | | | | | | | | | | | | | | | | | Previously, the assumption was that each object could only have a single extension object. As proven by the new qqmllanguage test this is not the case. Each registered object in the type hierarchy can have its own extension. Therefore, adjust the algorithms that generate qmltypes and iterate the extension objects when analyzing them. This leads us to the realization that anonymous types can in fact meaningfully carry extensions and implement interfaces. Adapt qmltyperegistrar accordingly. For the test to compile, however, we need to realize that the class declaring interfaces needs to befriend all potential subclass's QmlInterface structs. Fix that, too. The rabbit hole went deep. Change-Id: Ia451897e927e03b95c3062e829edf1dfcd216613 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Return after importing a scriptUlf Hermann2021-01-261-0/+1
| | | | | | | | If we don't return there, the newly imported script is promptly overwritten by an invalid module. Change-Id: I788a7275e2c190a20c176da35f5c76ac9f6ad02b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Complain if member access check fails for namespaced typesUlf Hermann2021-01-261-0/+4
| | | | | | | | Before, we would prepend the namespace to the name, but then continue right away, never checking the new name. Change-Id: If90db7d33536fb4b549321c2d6b677040605b6f0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSTypeReader: Guard against empty JS filesUlf Hermann2021-01-261-0/+4
| | | | | Change-Id: Ie52ce15b7fa960ce84a6d17a21a0e307a38c726e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Fix auto-importing of qmltypes from same directoryUlf Hermann2021-01-211-0/+17
| | | | | | | Fixes: QTBUG-90513 Pick-to: 6.0 Change-Id: Ic39e72d6df20be30c61123a7f8091d70dbc2d924 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Support extended typesUlf Hermann2021-01-201-2/+0
| | | | | | | Fixes: QTBUG-90448 Change-Id: I5fb6b3d9223ae95ca7e039c5b9139ed086052c29 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Skip failing testsFabian Kosmale2021-01-201-0/+2
| | | | | | | | And do not choke completely on extended. Task-number: QTBUG-90448 Change-Id: I4ac5742ec70f5ba1ed1403be444d9cc7229830c2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Check qmltypes files in import path for validityUlf Hermann2020-11-221-1/+22
| | | | | | | | Now that we have a module describing the qmltypes format, we can run qmllint on qmltypes files. Change-Id: I23339e52b5081ecb6a2c3b127078389a2b8faab0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Don't crash when importing ES modulesUlf Hermann2020-11-201-0/+1
| | | | | Change-Id: Ica93a3e3fb0eb99be1498f1fcb94b09c113272d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qmllint: Be more verbose when qmllint crashesUlf Hermann2020-11-171-0/+8
| | | | | | | Output the command line, exit status, exit code, stderr and stdout. Change-Id: I81a813bc44b7caf4c25d9097e8fbcbc3295ac6ec Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Introduce grouped scopesUlf Hermann2020-10-271-5/+3
| | | | | | | | This way we can analyze the left hand part of things like "anchors.fill: parent" in qmllint. Change-Id: I0f58312566c3d5062e0fb301c2bad908ab8b8cbb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Resolve aliases in nested objectsUlf Hermann2020-10-221-0/+5
| | | | | | | So far we've just ignored them. Change-Id: I2ca522ef825a341a3f4bf1c2a42fb0376180cdda Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Drop the metaobject revision from exportsUlf Hermann2020-10-191-0/+4
| | | | | | | | | Instead, output a warning if the revision doesn't match the version. We want to get rid of generic version/revision matching. To this end, add a way to retrieve the version from an export. Change-Id: Ie887103eba910f14e49faa684ac559cc72cab199 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow optional imports in qmldir filesUlf Hermann2020-10-081-0/+1
| | | | | | | | | | This is useful for modules that select their imports at runtime using qmlRegisterModuleImport(). We can list all possible variants as optional imports so that tools can see what types might be available. Task-number: QTBUG-87130 Change-Id: I8a37bdde79aef3619fd1f05e5ea6781d521afa88 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Be more verbose when tests failUlf Hermann2020-10-081-1/+1
| | | | | Change-Id: I9394dd721eac3e0b76fbedb6b2fca6f45da48383 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Read deprecated dependency specifications from qmltypes filesUlf Hermann2020-10-071-0/+2
| | | | | | | | And produce a warning when doing so. Task-number: QTBUG-87164 Change-Id: I75eab97a37af1268a310e88e3ac6a625127a7f62 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Use the declared typeinfos rather than the defaultUlf Hermann2020-10-071-0/+7
| | | | | | | | | | ... and produce a warning when encountering the default. This shows us that the qmake build omits some typeinfo entries from common modules. Add those. Change-Id: I1c7e87e8a54ef24a6076090e6051eb1c03c09b2a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Capitalize importer warningsUlf Hermann2020-10-071-1/+1
| | | | | | | Refactor the "prefixed message" mechanism into ColorOutput. Change-Id: Ie982e641771f3367406f48a8bcfd2bd3da122b16 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Mark anchors3.qml as dirtyUlf Hermann2020-10-051-1/+5
| | | | | | | | | This is in fact invalid QML. The assignment shouldn't be accepted but qmllint cannot see that, yet. Change-Id: Ifcb2f01edaf10ada5ce4d762726c51af3b4f5087 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Fix updating of parent propertyUlf Hermann2020-10-021-0/+6
| | | | | | | | | | | We need to check for the baseTypeName, not for the internalName. Also, this is not really the scope's business but a property of how qmllint sets up its scopes. Task-number: QTBUG-87116 Change-Id: I8f0e558a4a5861164c6e85f90e3d88e469ea0769 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Evgeniy Dushistov <dushistov@mail.ru>
* qmllint: Ignore grouped properties againUlf Hermann2020-10-021-9/+39
| | | | | | | | | | We cannot handle those, yet. Add tests that prove correct grouped properties pass and incorrect ones are expected to fail at causing qmllint to fail for now. Task-number: QTBUG-87116 Change-Id: I0aeed15d262e2c6226e27d5d92890c5385a38936 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Consistently spell "Warning"Ulf Hermann2020-09-281-2/+2
| | | | | | | There was one place where it was written in lower case. Change-Id: Id953fa6c260502ab5bca8cfa061c817bb5a70581 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Don't dump imported enums into the current scopeUlf Hermann2020-09-241-1/+7
| | | | | | | | | This bit of code has never fulfilled any discernable function. Enum access is done elsewhere. Add a test case to prove that access to enums from QtQml's plugins.qmltypes still works. Change-Id: I62fd6c1ec748c88205aa20367ee06d7a33502fa1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix additional warnings from usage of deprecated APIsVolker Hilsheimer2020-09-161-2/+2
| | | | | | | | | | Replace more QLibaryInfo::location with QLibraryInfo::path Replace old event accessors APIs, including relevant comments. Change-Id: Ie205fc93b6e1c0dfb3dca9100fbde417ab68fc9f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* qmllint: fix import java scripts from moduleEvgeniy A. Dushistov2020-08-221-0/+5
| | | | | | Fixes: QTBUG-86183 Change-Id: I4809cb5a408eb4e668f802cf0d7b7a872d1ed4b7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: handle signals defined in qml fileEvgeniy A. Dushistov2020-08-191-0/+1
| | | | | | | | | FindWarningVisitor for signal add property "signal" + "Changed", so it was impossible find "singal" and "onSingal" names. Fixes: QTBUG-83793 Change-Id: I5a62211f413f543fdb6bf00e0ab921561d7a9643 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Resolve enums from parent typesUlf Hermann2020-06-261-0/+1
| | | | | | | | Fixes: QTBUG-85185 Fixes: QTBUG-84036 Change-Id: If0989a85df93903fee6cb146a515cd362160ff49 Reviewed-by: Evgeniy Dushistov <dushistov@mail.ru> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Properly process qmldir imports and dependenciesUlf Hermann2020-06-241-0/+5
| | | | | | | | | | | | | | | | | | We don't want to pick the dependencies from the qmltypes files. Rather, parse them directly from the qmldir. Do process versions, too. Also, import explicitly given qmltypes files only once, and don't expose QML types from dependencies as actual types. Hide them behind an inaccessible prefix. For the inaccessible prefix to work, we need to import the C++ class names without the prefix. The prefix doesn't make sense for C++ names anyway. In addition, properly process version-less imports. Change-Id: If582ad271db35351d219332c319571a814628fe0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: search methods and properties also in attached typeEvgeniy A. Dushistov2020-06-191-0/+1
| | | | | | | | | | | | | | I changed the strategy of traverse via related types. Before: traversal happens only via linked list type -> type->superClass After: traversal via binary tree formed by attachedType and superClass I use pre-order strategy, current type, then all attached types, then all super classes Fixes: QTBUG-84861 Change-Id: I4a8fce869bc541de6900514d29575174d2753f02 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: high level item can also be listEvgeniy A. Dushistov2020-06-181-0/+1
| | | | | | | Fixes: QTBUG-84300 Change-Id: I1a9db060cdeb7c4ec10deedab5141a06245a55b2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: fix wrong warning about enum usageEvgeniy A. Dushistov2020-06-171-0/+2
| | | | | | | Fixes: QTBUG-83796 Change-Id: I635bbfd98cf7be8418b454626ba7725e92b71c2c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix qmllint crashMaximilian Goldstein2020-05-061-0/+4
| | | | | | Fixes: QTBUG-83915 Change-Id: I26731ebcec6be46602b6acc7562c65b1c9f3e43a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: warn when passing a directory to -i optionMitch Curtis2020-05-061-4/+16
| | | | | | | | | It should be a file. Change-Id: I52f4ebcf8bdd8ddd1fedd66ceffe9a060139c1d9 Fixes: QTBUG-83861 Pick-to: 5.15 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Add flags for toggling warningsMaximilian Goldstein2020-04-301-1/+1
| | | | | | | | Enables all warnings by default and makes it possible to toggle individual ones using command line flags. Change-Id: Ie55f32f646fd9422313977969f9f00b59ee9ad99 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Show filename in addition to line and columnFabian Kosmale2020-04-241-12/+14
| | | | | | Fixes: QTBUG-83684 Change-Id: If15a9498ae223dccfbafe88b14453a4b180247d9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Move qmllint's metatype support to tools/sharedUlf Hermann2020-04-011-1/+1
| | | | | | | | | We want to read qmltypes files and analyze scopes also from other tools. Furthermore, restructure the shared directory, so that each tool only includes what it needs. Change-Id: I96a2dcc8b1c5fac613592fb1867bf51fa5ef3a6e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* qmllint: Break inheritance cyclesUlf Hermann2020-03-191-0/+4
| | | | | | | | | | | | Previously we would run into infinite loops on those. Mind that qmllint will reject a file called Window.qml that imports QtQuick.Window and then instantiates a Window {}. Such a thing is bad style. Task-number: QTBUG-82817 Change-Id: I6db82ca1794c3020dcb7d7e837fe44f72bca5029 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Check for unknown types in JavaScript accessUlf Hermann2020-03-171-0/+4
| | | | | | | | | There are many incomplete qmltypes files around. We should not just crash on those. Task-number: QTBUG-82817 Change-Id: Ie072b80473927570c80fb2f9ae329de711c35904 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Don't crash on IDs that aren't scopesUlf Hermann2020-03-171-0/+1
| | | | | | | | | In particular, those can be qualifiers for imports, in which case we have to combine them with the next segment in order to find the type. Task-number: QTBUG-82817 Change-Id: I217a79572cd1e160dcbbcb9541c53941c81ab76c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Use fully qualified QML type names as superClassUlf Hermann2020-03-161-0/+1
| | | | | | | | Otherwise we miss subtleties such as Label vs. T.Label. Task-number: QTBUG-82817 Change-Id: Idc2131426b2fd96f279dab83292a348b9295d5c0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Add QFont to the list of unknown builtinsUlf Hermann2020-03-161-0/+1
| | | | | | | | | And also check them when analyzing JavaScript access. Task-number: QTBUG-82817 Change-Id: I677e7883fb24ab80ff20d1998e2d7df440ef4112 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Consider failure to find imports an errorUlf Hermann2020-01-131-3/+3
| | | | | | | | There is no real reason to tolerate it. We can generate all qmltypes at build time, and if we can't find them, the results are likely to be off. Change-Id: Id935d76ac3ca6b601381b40a73d7fbacca342c4d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Consider attached propertiesUlf Hermann2020-01-131-0/+1
| | | | | | | | | We cannot figure out who attached properties to what, therefore we consider any uppercase property we cannot locate as a potential attached property. Change-Id: I60508b9e4e038a51b87c56edf0796ac492aa3fa0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: parse simple type assertionsUlf Hermann2020-01-131-0/+5
| | | | | Change-Id: Ic24018137d8f989686d4a8f927efb824453d114b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Assume "parent" property is always document parentUlf Hermann2020-01-131-0/+9
| | | | | | | | ... except if the document parent is Component. Then leave the type alone. Change-Id: Id7b2e6efdefe18a8d375967ddedcdf9e07a07946 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Resolve aliasesUlf Hermann2020-01-131-0/+9
| | | | | Change-Id: Ida53af9774dc72559395064169113d0ee1f47f24 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Analyze member accessUlf Hermann2020-01-131-1/+9
| | | | | | | | | We can analyze access to many field member expressions and figure out if the accessed members exist. There are limits to this, of course. Generic JavaScript values are out of scope here. Change-Id: Id2e7613e56f06555cc3a2ba1c51683d9ea0bb84b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>