Segni meno che creano confusione
Questa categoria di avviso viene indicata da qmllint come " [confusing-minuses] " (doppio segno di più).
Segni meno ambigui
Cosa è successo?
Il codice JavaScript utilizza una combinazione di operatori scritti con il segno '-' in modo che possa creare confusione. Gli operatori '-' adiacenti potrebbero essere difficili da distinguere. La situazione può essere aggravata da una spaziatura non convenzionale.
Perché è un problema?
Rende il codice più difficile da leggere e può causare confusione.
Esempio
import QtQuick
Item {
function f(a: int, b: int) {
let x = a-- - b
let y = a - -b
let z = a - --b
return x + y + z
}
}Per risolvere questo avviso, riscrivi il codice in modo che non contenga operatori "-" simili uno accanto all'altro. Semplifica le espressioni dove possibile. Rimuovi gli operatori unari ridondanti e gli spazi superflui, e usa le parentesi per isolare le sottoespressioni.
Tieni presente che questi operatori potrebbero eseguire delle conversioni. Un'espressione come a - -b potrebbe non essere equivalente a a + b a seconda del tipo di b.
import QtQuick
Item {
function f(a: int, b: int) {
let x = (a--) - b
let y = a + b
let z = a - b + 1
return x + y + z
}
}© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.