Search code examples
javaintellij-ideacompiler-warningslomboksuppress-warnings

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


IntelliJ wrongly tells me that a field initializer is redundant, but it is in fact used by Lombok's @Builder.Default.

I would like to suppress this warning using @SuppressWarnings but I don't know what the warning is called (alt-enter also gives me no option to suppress). How can I find a warning's name in IntelliJ?


Solution

  • 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").