Blocco case non vuoto non terminato
Questa categoria di avviso viene indicata da qmllint come " [unterminated-case] ".
Blocco "case" non vuoto non terminato
Cosa è successo?
Un blocco "case" in un'istruzione "switch" non era vuoto ma non è stato terminato da un'istruzione "break", "return" o "throw". Inoltre, non era presente alcun commento di fallthrough esplicito.
Perché è un problema?
La logica di fallthrough nelle istruzioni switch può creare confusione o passare inosservata. Se è intenzionale, dovrebbe essere contrassegnata esplicitamente con un commento del tipo "// fallthrough". Se non è intenzionale, l'avviso indica che è stata omessa un'istruzione di terminazione.
Esempio
switch (state) {
case Main.State.Reset:
clearState() // <--- "Unterminated non-empty case block"
case Main.State.Invalid:
asyncInitState()
return false
case Main.State.Initializing:
// wait for initialization to complete
return false
case Main.State.Ready:
res = lookup(query)
log(res.stats)
saveToDisk(res.data) // <--- "Unterminated non-empty case block"
default:
throw new InvalidStateException("Unknown state")
}Per risolvere questo avviso, aggiungere le istruzioni di terminazione mancanti oppure aggiungere commenti espliciti che consentano la logica di fallthrough:
switch (state) {
case Main.State.Reset:
clearState()
// fallthrough // <--- add fallthrough comment
case Main.State.Invalid:
asyncInitState()
return false
case Main.State.Initializing:
// wait for initialization to complete
return false
case Main.State.Ready:
res = lookup(query)
log(res.stats)
saveToDisk(res.data)
return true // <--- add forgotten terminating statement
default:
throw new InvalidStateException("Unknown state")
}© 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.