Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to disable duplicate code detection in Intellij?

People also ask

How do I remove duplicates in IntelliJ?

From the main or context menu, select Refactor | Find and Replace Code Duplicates. In the dialog that opens, select the scope where IntelliJ IDEA shall look for code duplicates. For each found code duplicate, IntelliJ IDEA will prompt you to confirm the replacement.

How do I stop code duplication?

Don't Repeat Yourself (DRY): Using DRY or Do not Repeat Yourself principle, you make sure that you stay away from duplicate code as often as you can. Rather you replace the duplicate code with abstractions or use data normalization. To reduce duplicity in a function, one can use loops and trees.

How do I ignore duplicated code report in Sonar?

Go to sonar dashboard. Click on Issues. Select your class and issue and further check see rule. Rule id is mentioned in the top right corner of rule description.

What is duplicated code fragment?

Code Inspection: Duplicated code fragmentReports duplicated blocks of code from the selected scope: the same file or the entire project. The inspection features quick-fixes that help you to set the size of detected duplicates, navigate to repetitive code fragments, and compare them in a tool window.


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". intellij code duplication


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

@SuppressWarnings("Duplicates")

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


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.