I just clicked "Show all duplicates like this" in the "Duplicated code fragment" context menu:
Now the duplicated code is permanently highlighted with a purple background, even if I close the "Duplicates" toolbar at the bottom of the IDE.
How do I remove this highlighting?
Press Ctrl+Alt+S to open the IDE settings and select Editor | Duplicates. Select file types to which the analysis should apply and select the checkboxes next to the constructs that you want to anonymize.
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.
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.
Simply hit the ESC
key to remove that highlighting.
If the IDE is finding "Duplicate code fragments" between your source code and a copy of it in an output directory (like Python setup.py
creates in a build/
directory; I don't know how this goes in PHP), then mark the output directory as excluded from source directories.
Right-click the output directory in the Project View, then Mark Directory As
> Excluded
.
BTW, this works in PyCharm and IntelliJ as well, and presumably in all the JetBrains IDEs.
Just re-open the file/project - it will remove the highlighting. If you don't like the "Duplicate code fragment" violation to be reported for your code fragment, try suppressing inspection for statement by adding // noinspection DuplicatedCode
before it.
There is a request for making the duplicates highlighting less aggressive, IDEA-210614, please feel fre to vote for it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With