Disable warning in IntelliJ for one line

Mostly in IntelliJ, you can click on the line and Alt+Enter, and it will have options for suppressing the warning, among other things.


Expanding upon Ryan Stewart's answer, in IntelliJ, use Alt+Enter, then select the first sub-menu, then the last item: Suppress for statement.

enter image description here

Update

Using IntelliJ IDEA 13, I noticed an additional menu item: "Suppress for statement with comment". This will use the IntelliJ style //noinspection unchecked. If you select "Suppress for statement", IntelliJ will insert this text: @SuppressWarnings("unchecked").


Depending on the warning you can use @SuppressWarnings. Eg:

@SuppressWarnings("deprecation")
yourLineWhichIsDeprecated;

Take a look at this answer for a pretty long list of warnings you can suppress. Check the other posts on that topic for more details.


In IntelliJ 15 the inline "yellow bulb" and alt-enter menus don't offer to suppress the inspection for 1 line.

There are more options when running the inspections via the Menu: Analyze -> Inspect Code....

Then on the Inspection panel the right side offers various options. Some of text in the right hand panel is clickable. Note that usually the problem resolution function (quick fix) is also available.

enter image description here

(Apparently @tino already noticed this in a comment, but I missed his comment the first time. I'm adding this as full answer to make the important bit I personally missed easier to find.)


Just one more note. If you are looking for a answer to suppress all warnings for a next line (or part of the code). It might be a reason for a several cases:

  • Idea doesn't provide error name, or suggestions

  • Number of warnings for next line is too large

You can use just:

    //noinspection ALL