For the sake of writing re-useable QML code I am looking for a (static code) checker which can detect unwanted dependencies across different qml files.
To give an example where B.qml depends on identifiers from A.qml:
A.qml
Item {
id: dependencyId
...
delegate: B {}
}
B.qml
Item {
id: delegateB
...
text: dependencyId.text
}
As the text element of B.qml depends on a identifier from A.qml, this code cannot be reused properly.
As long as the id of Item in A.qml won't change, this code would compile/run, and thus the dependency will not be noticed. I tried QmlLint, but this gives no errors.
Are there static code checkers for QML available which can check this?
Added a custom build step in the sourceDirectory running qmlscene for each *.qml file, filtering results only on "reference" errors.
Thanks derM for the tip on using qmlscene.
Command: find
Arguments: . -name '*.qml' -exec qmlscene --quit {} \; 2>&1 | grep -rnis 'reference'
Working directory: %{sourceDir}
(2>&1 is needed to parse stderr, which is where the error messages are being displayed)