beta.blog

IntelliJ: Suppress duplicate code warnings

by on Feb.07, 2019, under Programming

IntelliJ IDEA has a feature do detect duplicate code through static code analysis. Once a piece of duplicate code was detected it will be highlighted as shown below:

Bildschirmfoto 2019-02-07 um 10.48.30
 

 

The idea is to ask the programmer to refactor the code accordingly since having bugs in duplicate code automatically means having duplicate bugs. We may however ignore these hints by adding the @SuppressWarnings annotation to our class:

@SuppressWarnings("Duplicates")
public class HelloWorld {
  ...
}

Even though it’s possible, one should prefer to refactor the code instead.

:,

Leave a Reply

*

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!