Unterminated non-empty case block

This warning category is spelled [unterminated-case] by qmllint.

Unterminated non-empty case block

What happened?

A case block in a switch statement was non-empty but was not terminated by a break, return, or throw statement. There was also no opt-in fallthrough comment.

Why is that bad?

Fallthrough logic in switch statements can be confusing or overlooked. If it is intentional, it should be marked explicitly with a comment such as "// fallthrough". If it isn't intentional, the warning indicates that a terminating statement was forgotten.

Example

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")
}

To fix this warning, add missing terminating statements or add explicit opt-in comments allowing fallthrough logic:

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")
}

© 2025 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.