종료되지 않은 비어 있지 않은 케이스 블록
이 경고 카테고리의 철자는 [unterminated-case]
입니다.
종료되지 않은 비어 있지 않은 대소문자 블록
무슨 일이 일어났나요?
스위치 문의 대/소문자 블록이 비어 있지 않지만 break, return 또는 throw 문으로 종료되지 않았습니다. 또한 옵트인 폴스루 주석도 없습니다.
이것이 왜 나쁜 걸까요?
스위치 문의 폴스루 논리는 혼란스럽거나 간과될 수 있습니다. 의도적인 경우 "// 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") }
© 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.