Is it possible to disable duplicate code detection

2019-01-30 17:32发布

问题:

Is it possible to disable duplicate code detection in Intellij?

I haven't found this feature to be useful and it continues to distract me.

回答1:

To toggle it, go to Other Settings → Editor → Inspections → General → Duplicated Code.

You can use search field there to find the specific item.



回答2:

Add a hint to your code so that others will know your intent:

@SuppressWarnings("Duplicates")


回答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



回答4:

Java has this annotation You should use that instead of turning off the highlight function of IntelliJ Add this line above your class or pieces of code

@SuppressWarnings("Duplicates")