終了文のない非空のcaseブロック
この警告カテゴリは、qmllint では「[unterminated-case] 」と表記されます。
終了されていない非空のcaseブロック
何が起きたのか?
switch文内のcaseブロックが空ではなかったにもかかわらず、break、return、またはthrow文によって終了されていませんでした。また、fallthroughを明示的に許可するコメントもありませんでした。
なぜ問題なのか?
switch文におけるフォールスルー処理は、混乱を招いたり見落とされたりしやすいものです。意図的なものである場合は、「// fallthrough」などのコメントで明示的に示すべきです。意図的でない場合、この警告は終了文の記述が忘れられていることを示しています。
例
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")
}この警告を修正するには、欠落している終了文を追加するか、フォールスルーロジックを許可する明示的なコメントを追加してください:
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.