I am using CheckStyle
and the rule for EmptyBlock
seems to be not working. I got an empty else if{//ignore}
block and based on the documentation the following rule should work but it is not.
<module name="EmptyBlock">
<property name="tokens" value="LITERAL_DEFAULT"/>
</module>
Am I doing anything wrong?
<property name="tokens" value="LITERAL_DEFAULT"/>
You are disabling if
blocks by specifying the LITERAL_DEFAULT
with no other tokens. LITERAL_IF
is an optional token as defined in the Properties
section at http://checkstyle.sourceforge.net/config_blocks.html#EmptyBlock . When you specify a list of tokens, you are disabling all other optional tokens you don't write in.
Use something like <property name="tokens" value="LITERAL_IF, LITERAL_DEFAULT"/>
to produce a violation on if (condition) {}
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.