Reputation: 8573
How can I suppress the inspection in Kotlin for an unused variable
val xyz = abc
I get the squiggly line but ALT-ENTER
is useless for this, I tried also to create in another method several variables unused and they also lack the ALT-ENTER
ability to ignore the warning. Although I have definitely used ALT-ENTER
for this in the past, although maybe it was only in java, can't remember.
So I must manually construct it by hand. I've been trying several variations but I can't get anything to work. Please tell me the correct //noinspection
or @SupressWarnings
to use, thanks
Upvotes: 11
Views: 5327
Reputation: 5368
In IntelliJ IDEA, a right-side arrow on an ALT+ENTER context menu (like this: ) means that you can use your arrow keys to navigate further along the menu. In this case, it leads to your answer:
@Suppress("UNUSED_VARIABLE")
val unused = ""
If you do not get the initial context menu (Remove variable '...'
), you may have disabled the "Unused assignment" inspection in your current project. You can fix this by going to Settings -> Editor -> Inspections.
Upvotes: 19