Is it possible to disable duplicate code detection in Intellij?
Solution 1:
Only available in IntelliJ Ultimate:
To disable duplicate code detection, go to
File → Settings → Editor → Inspections → General → Duplicated code fragment
and uncheck box "Duplicate code fragment".
Solution 2:
Add a hint to your code so that others will know your intent:
@SuppressWarnings("Duplicates")
Solution 3:
Yes, it's possible, but I would strongly advise against it!
Duplicate code is a form of technical debt. Any duplicated code that contains a bug means you now have a duplicated bug - you then run the risk that when you fix it, you'll only fix it in one place and the duplicate will remain...
If duplicate code warnings are distracting you, then the best strategy for getting rid of them is to remove the code duplication... Your codebase and future maintainers will thank you for it
Solution 4:
This answer may be little irrelevant, but I found this helpful, From this answer if you want to disable it for a specific code block, not the entire method or class or ide, then just add the following line just before that code block
//noinspection Duplicates
Note: You can not put any other comment after this line.