Suppress NOTHING_TO_INLINE warning globally
Asked Answered
B

1

6

I have a function in Kotlin that I want to inline despite not being high-order.

I find that through out the project I have numerous occurrences of such scenario.

Therefore, to ignore compiler warnings about using inline functions, I have to use lots of Suppress("NOTHING_TO_INLINE") annotations through out my project and it's starting to bother me.

Is there any way to block this warning for the whole project by, for instance, a compiler option? I'd like to know how to do this in IntelliJ IDEA.

Balbur answered 12/5, 2018 at 6:58 Comment(0)
A
10

It doesn't look like it's possible to disable the inspection globally. I can't find a setting in IntelliJ at least. You can, however, disable the inspection for an entire file:

@file:Suppress("NOTHING_TO_INLINE")

If you press ALT+Enter on the warning, you'll get an option to suppress it which just contains suppressing for the function, class (if it's in one), or for the entire file. Any inspections you can disable usually has a "Disable inspection" option on this list (which NOTHING_TO_INLINE does not have).

You can, however, disable the warnings when compiling (but it does not affect the inspection; you'll still see warnings while editing) by adding suppressWarnings to the compileKotlin task. Note that this disables ALL warnings, not just specific ones.

compileKotlin {
    kotlinOptions.suppressWarnings = true
}
Amora answered 12/5, 2018 at 9:31 Comment(1)
Such an annoyance. All warnings and inspections should be easy to disable. People have different code styles and requirements.Ingrown

© 2022 - 2024 — McMap. All rights reserved.