How to get the @SuppressWarnings warning name for an IntelliJ warning?

Looks like there is another answer here for how to suppress unused methods or members, which is to add the annotation @SuppressWarnings("unused"). Or, if you want to suppress a local variable, then you'd have to insert a line comment // noinspection unused, like

// noinspection unused
long int i = 0;

To answer your question of, "How can I find a warning's name in Intellij?", I found a web page from a James Roper who lists out all the Intellij warning keywords paired with a brief definition. https://jazzy.id.au/2008/10/30/list_of_suppresswarnings_arguments.html

For example, the one I was after was

Redundant local variable = UnnecessaryLocalVariable

That list in Roper's page only covers the special warnings invented by JetBrains. The warning you need, "unused", has been around for a long time and pre-dates IntelliJ. Some are a part of the java compiler. For a list of the javac warnings, I found from https://javarevisited.blogspot.com/2015/09/what-is-suppresswarnings-annotation-in-java-unchecked-raw-serial.html that you can run javac -X. For Java 1.8, I found

all,auxiliaryclass,cast,classfile,deprecation,dep-ann,divzero,empty,fallthrough,finally,options,overloads,overrides,path,processing,rawtypes,serial,static,try,unchecked,varargs

That still doesn't lead us to unused. The unused warning came from Eclipse and is also supported by Intellij. For a list of Eclipse warnings, see https://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-suppress_warnings.htm

That pages contains

  • all = to suppress all warnings
  • boxing = to suppress warnings relative to boxing/unboxing operations
  • cast = to suppress warnings relative to cast operations
  • dep-ann = to suppress warnings relative to deprecated annotation
  • deprecation = to suppress warnings relative to deprecation
  • fallthrough = to suppress warnings relative to missing breaks in switch statements
  • finally = to suppress warnings relative to finally block that don't return
  • hiding = to suppress warnings relative to locals that hide variable
  • incomplete-switch = to suppress warnings relative to missing entries in a switch statement (enum case)
  • javadoc = to suppress warnings relative to javadoc warnings
  • nls = to suppress warnings relative to non-nls string literals
  • null = to suppress warnings relative to null analysis
  • rawtypes = to suppress warnings relative to usage of raw types
  • resource = to suppress warnings relative to usage of resources of type Closeable
  • restriction = to suppress warnings relative to usage of discouraged or forbidden references
  • serial = to suppress warnings relative to missing serialVersionUID field for a serializable class
  • static-access = to suppress warnings relative to incorrect static access
  • static-method = to suppress warnings relative to methods that could be declared as static
  • super = to suppress warnings relative to overriding a method without super invocations
  • synthetic-access = to suppress warnings relative to unoptimized access from inner classes
  • sync-override = to suppress warnings because of missing synchronize when overriding a synchronized method
  • unchecked = to suppress warnings relative to unchecked operations
  • unqualified-field-access = to suppress warnings relative to field access unqualified
  • unused = to suppress warnings relative to unused code and dead code

By putting your cursor on the warning and pressing Alt+Enter, it should open up a menu. In this menu, there should be an option to remove the field. Navigate to this option and press . This opens up a sub-menu which contains the options to suppress the warning. By doing so, IntelliJ will generate the appropriate annotation.

In your case, the annotation should probably be along the lines of @SuppressWarnings("unused") or @SuppressWarnings("UnusedAssignment").