Bloc « case » non vide non terminé
Cette catégorie d'avertissement est désignée par qmllint sous le nom « [unterminated-case] ».
Bloc « case » non vide non terminé
Que s'est-il passé ?
Un bloc « case » dans une instruction « switch » n'était pas vide mais n'était pas terminé par une instruction « break », « return » ou « throw ». Il n'y avait pas non plus de commentaire « fallthrough » explicite.
Pourquoi est-ce un problème ?
La logique de passage automatique dans les instructions switch peut prêter à confusion ou passer inaperçue. Si elle est intentionnelle, elle doit être explicitement signalée par un commentaire tel que « // fallthrough ». Si elle n'est pas intentionnelle, l'avertissement indique qu'une instruction de fin a été oubliée.
Exemple
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")
}Pour corriger cet avertissement, ajoutez les instructions de fin manquantes ou ajoutez des commentaires explicites autorisant la logique de 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.