Klitos Kyriacou
Klitos Kyriacou

Reputation: 11631

Intellij inspection for switch case fall-through

Does Intellij IDEA have an inspection for a possibly unintentional fall-through in a switch statement due to a forgotten break?

Upvotes: 2

Views: 1178

Answers (1)

CrazyCoder
CrazyCoder

Reputation: 402065

Yes, it does:

switch

Reports 'fall-through' in a switch statement. Fall-through is defined to occur when a series of executable statements after a switch label is not guaranteed to transfer control before the next switch label. In that case, control falls through to the statements after that switch label, even though the switch expression does not equal the value of the fallen-through label. While occasionally intended, this construction is confusing, and is often the result of a typo.

Note that this inspection is disabled by default, so tick a checkbox on the right if you want to use it.

Upvotes: 5

Related Questions