【发布时间】:2017-09-13 21:40:30
【问题描述】:
在无数次检查(我知道如何启用和禁用)中浪费更多时间,我找不到任何方法来禁用对 Android Studio 中我的 Kotlin(不是 Java)文件的 'Condition is always true' 的特定检查。我知道我在做什么,根本不需要这种检查,但更恰当地说,我想为文件、类或函数或任何东西禁止它。
一如既往的令人沮丧。
//I'm well aware the condition below is ALWAYS true
if(ANDROID_IS_AWESOME) {
fml()
}
【问题讨论】:
-
不确定 Android Studio,但在 IntelliJ 中这称为
Condition of 'if' expression is constant,我可以在“检查”下将其关闭或提高其级别。 -
我认为关键是阻止这种行为并促进在代码之外使用标志(假设这是用于什么 - 否则,为什么要在
if中包装块?) -
查看首选项 -> 编辑器 -> 检查 -> "常量 'if' 语句"
标签: android-studio kotlin code-inspection