Wasting more time scouring through the COUNTLESS number of inspections (which I know how to enable and disable), I cannot find ANY way to disable the particular inspection of 'Condition is always true'
for my Kotlin (not Java) file in Android Studio. I know what I'm doing and don't need this inspection AT ALL, but more appropriately, I'd like to suppress it for the file or class or function or ANYTHING.
Incredibly frustrating, as always.
//I'm well aware the condition below is ALWAYS true
if(ANDROID_IS_AWESOME) {
fml()
}
In Kotlin, use ConstantConditionIf
to ignore this warning :
@Suppress("ConstantConditionIf")
if(ANDROID_IS_AWESOME) {
fml()
}
This is how you would do it in Java :
@SuppressWarnings("ConstantConditions") // Add this line
public int foo() {
boolean ok = true;
if (ok) // No more warning here
...
}
In Kotlin I think you have to use @Suppress("SENSELESS_COMPARISON")
instead.
In Android Studio,
💡 Simplify expression ⯈
select any of the options you like, for example:
In Kotlin, We can use @Suppress("SENSELESS_COMPARISON")
for a class or if statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With