Suppress duplicate warnings in IntelliJ IDEA by annotation

This works for me. You have to set it on both classes/methods if you want to suppress the warning both places.

@SuppressWarnings("Duplicates")
private void myDuplicatedMethod() {
    ...
}

Just saw this and thought I would throw this in for posterity. To suppress for just one block rather than the whole method, you can use a line comment:

//noinspection Duplicates

(I also find it handy to do this for unchecked) (I'm using version 2016-2, but I think this has been around awhile)


Thank you for all the answers. There is also another more generic approach to suppress warnings:

  1. Place the cursor within the code that gives you a warning
  2. Hit Alt+Enter
  3. Go to the warning entry (in this case "Navigate to duplicate")
  4. Don't hit Enter but (right arrow)
  5. Now you can select some suppressing options (for class/method/statement)

enter image description here