我浪费了更多的时间在无数的检查中(我知道如何启用和禁用它们),我找不到任何方法来禁用Android Studio中我的Kotlin (不是Java)文件的'Condition is always true'特定检查。我知道我在做什么,根本不需要这种检查,但更恰当的是,我想在文件、类或函数或任何东西中抑制它。
令人难以置信的沮丧,一如既往。
//I'm well aware the condition below is ALWAYS true
if(ANDROID_SUCKS) {
fml()
}发布于 2019-04-08 16:47:38
在Kotlin中,使用ConstantConditionIf忽略此警告:
@Suppress("ConstantConditionIf")
if(ANDROID_IS_AWESOME) {
fml()
}发布于 2018-09-19 19:12:42
这就是在Java中用实现的方法:
@SuppressWarnings("ConstantConditions") // Add this line
public int foo() {
boolean ok = true;
if (ok) // No more warning here
...
}In Kotlin我认为你必须用@Suppress("SENSELESS_COMPARISON")来代替。
发布于 2017-09-15 20:15:42
在Android Studio中,
简化表达式⯈
- Disable inspection
- Suppress 'ConstantConditionIf' for statement/fun/class/file
https://stackoverflow.com/questions/46207235
复制相似问题