QML dependency / reuse validation (static code)

To write reusable QML code, I am looking for a (static code) checker that can detect unwanted dependencies in 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
}

Since the B.qml text element is dependent on the identifier from A.qml, this code cannot be reused correctly.

Until the element identifier in A.qml changes, this code will be compiled / executed, and, therefore, the dependency will not be noticed. I tried QmlLint, but it gives no errors.

Can static code checks be installed for QML that can verify this?

+4
1

, qmlscene *.qml, "" .

derM qmlscene.

:

:. -name '*.qml' -exec qmlscene --quit {} \; 2 > & 1 | grep -rnis 'reference'

:% {sourceDir}

: enter image description here

(2 > & 1 stderr, )

+2

Source: https://habr.com/ru/post/1666468/


All Articles