20 passMan->registerPropertyPass(std::make_unique<QQmlJSLiteralBindingCheck>(passMan), QString(),
21 QString(), QString());
23 QQmlSA::PropertyPassBuilder(passMan)
24 .withOnCall([](QQmlSA::PropertyPass *self,
const QQmlSA::Element &,
const QString &,
25 const QQmlSA::Element &, QQmlSA::SourceLocation location) {
26 self->emitWarning(
"Do not use 'eval'", qmlEval, location);
28 .registerOnBuiltin(
"GlobalObject",
"eval");
30 QQmlSA::PropertyPassBuilder(passMan)
31 .withOnRead([](QQmlSA::PropertyPass *self,
const QQmlSA::Element &element,
32 const QString &propName,
const QQmlSA::Element &readScope_,
33 QQmlSA::SourceLocation location) {
34 const auto &elementScope = QQmlJSScope::scope(element);
35 const auto &owner = QQmlJSScope::ownerOfProperty(elementScope, propName).scope;
36 if (!owner || owner->isComposite() || owner->isValueType())
38 const auto &prop = QQmlSA::PropertyPrivate::property(element.property(propName));
39 if (prop.index() != -1 && !prop.isPropertyConstant() && prop.notify().isEmpty()
40 && prop.bindable().isEmpty()) {
41 const QQmlJSScope::ConstPtr &readScope = QQmlJSScope::scope(readScope_);
44 Q_ASSERT(readScope->scopeType() == QQmlJSScope::ScopeType::QMLScope);
45 for (
auto it = readScope->childScopesBegin(); it != readScope->childScopesEnd();
47 QQmlJS::SourceLocation childLocation = (*it)->sourceLocation();
48 if (childLocation.offset <= location.offset()
49 && (childLocation.offset + childLocation.length
50 <= location.offset() + location.length())) {
51 if ((*it)->scopeType() != QQmlSA::ScopeType::BindingFunctionScope)
56 "Reading non-constant and non-notifiable property %1. "_L1
57 "Binding might not update when the property changes."_L1.arg(propName);
58 self->emitWarning(msg, qmlStalePropertyRead, location);
61 .registerOn({}, {}, {});