简体   繁体   English

IntelliJ-等于之前不必要的“空”检查

[英]IntelliJ - Unnecessary 'null' check before equals

All of a sudden 突然间 is giving me warning / hints on code like this: 在这样的代码上给我警告/提示:

if (header != null && header.equals(PROXY_REQUEST_VALUE)) {
    // ...      
}

The hint says: 提示说:

Unnecessary 'null' check before equals() equals()之前的不必要的“ null”检查

And the little lamp solution changes the code to 小灯解决方案将代码更改为

if (PROXY_REQUEST_VALUE.equals(header) {
    // ...
}

I don't like Yoda conditions . 我不喜欢尤达的条件 How do I disable the 'feature'? 如何禁用“功能”?


Version is: Ultimate 2017.1.6 版本是: Ultimate 2017.1.6

In IntelliJ preferences, Editor > Inspections. 在IntelliJ首选项中,选择“编辑器”>“检查”。 You can use the search field in order to find the desired inspection more easily. 您可以使用搜索字段来更轻松地找到所需的检查。

在此处输入图片说明

I believe this is what you are looking for: 我相信这是您要寻找的:

在此处输入图片说明

preferences -> editor -> inspections -> java -> code style issues -> expression equals... 首选项->编辑器->检查-> Java->代码样式问题->表达式等于...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM