idea警告:'xxx==false' can be simplified to '!xxx'

来源:互联网 发布:阿里云 百度云 知乎 编辑:程序博客网 时间:2024/06/01 10:41

1. 当程序中存在类似如下判断代码时

if ( label == true ){    ... ...}

2. idea或部分ide检测代码时会出现此警告

'label==false' can be simplified to '!label' less... (Ctrl+F1) Reports pointless or pointlessly complicated boolean expressions. Such expressions include anding with true, oring with false, equality comparison with a boolean literal, or negation of a boolean literal. Such expressions may be the result of automated refactorings not completely followed through to completion, and in any case are unlikely to be what the developer intended to do.

3. 修改:

if ( label ){    ... ...}

4. 参考地址:

http://www.itwendao.com/article/detail/66036.html

5. 其他参考:

https://github.com/eslint/eslint/issues/667


阅读全文
0 0
原创粉丝点击