Disabling an IntelliJ inspection : warning "if (a == false) change to if (!a)". I see no link or code to jump to it's configuration

huangapple go评论136阅读模式
英文:

Disabling an IntelliJ inspection : warning "if (a == false) change to if (!a)". I see no link or code to jump to it's configuration

问题

在一行Java代码中,我写道:

if (row.isNullAt(row.fieldIndex(codeCompetence)) == false)

IntelliJ发出警告:
row.isNullAt(row.fieldIndex(codeCompetence)) == false
可以简化为
!row.isNullAt(row.fieldIndex(codeCompetence))

这绝对是正确的。但我不想这样做。
对我来说,视力不好,在表达式的左边少一个**!**,比在中间少一个== false要不容易看到,而在相同的位置,你通常会找到==>=<!=.equals和其他大多数比较运算符。


问题窗口中,我看不到直接跳转到配置的代码或链接,该配置导致出现警告:
'row.isNullAt(row.fieldIndex(codeCompetence)) == false'可以简化为'!row.isNullAt(row.fieldIndex(codeCompetence))'

而在IntelliJ上的所有可用检查中,我还没有找到它。

我的问题

  1. 我在哪里点击可以直接跳转到我在问题窗口中看到的任何警告/错误消息的定义?
    右键单击鼠标时出现的上下文菜单没有提供这个选项。

  2. 如果这个功能不可用,你知道我应该禁用哪个检查?

英文:

On a Java line code I've wrote :

if (row.isNullAt(row.fieldIndex(codeCompetence)) == false)

IntelliJ warns :
row.isNullAt(row.fieldIndex(codeCompetence)) == false
can be simplified to
!row.isNullAt(row.fieldIndex(codeCompetence))

which is absolutely true. Except that I don't want to.
For me, not having a good sight, a little ! on the left of an expression is far less visible than an
== false on the middle, at the same place you usually find ==, &gt;=, &lt;, !=, .equals,
and most of others comparisons.


On the Problems Windows, I don't see a code or a link to jump directly to the configuration the inspection leading to the apparition of the warning :
'row.isNullAt(row.fieldIndex(codeCompetence)) == false' can be simplified to '!row.isNullAt(row.fieldIndex(codeCompetence))'

And I still haven't found it among all the inspections available on IntelliJ.

My questions

  1. Where do I click to jump directly on the definition of any warning / error message I see on my Problems windows ?
    The context menu coming when right-clicking with the mouse doesn't offer this choice.

  2. If the feature isn't available, do you know what is the inspection I should disable ?

答案1

得分: 4

这个检查被称为“无意义的布尔表达式”。以下是其描述:

报告无意义或无意义复杂的布尔表达式。这些表达式包括与 true 进行与操作,与 false 进行或操作,与布尔字面值进行等式比较,或对布尔字面值进行取反。这些表达式可能是自动重构的结果,但并未完全完成,无论如何都不太可能是开发人员的本意。

您可以通过点击小箭头来禁用它:

Disabling an IntelliJ inspection : warning "if (a == false) change to if (!a)". I see no link or code to jump to it's configuration

或者通过在检查列表中搜索其描述中的关键词来禁用它。

英文:

The inspection is called "Pointless Boolean Expressions". Here is its description:

> 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.

You can disable it by pressing on the little arrow:

Disabling an IntelliJ inspection : warning "if (a == false) change to if (!a)". I see no link or code to jump to it's configuration

Or by searching for words in its description in the inspections list.

答案2

得分: 0

我更倾向于使用较短的变体,每个人在查看该语句时都应看到「!」,但这可能会对您有所帮助:https://stackoverflow.com/questions/11703601/disable-intellij-warnings

英文:

I would prefer the shorter variant, everyone should see the „!“ when he is looking at the Statement, but this could help you https://stackoverflow.com/questions/11703601/disable-intellij-warnings

huangapple
  • 本文由 发表于 2020年10月3日 14:01:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/64181215.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定