Finding renaming errors

When you copy some code into your project, you often make a bunch of edits to adapt the code to your environment. Some of these edits can only be made by hands.

Once in a while one forgets to change a few identifier occurrences in a file; this results in obscure and hard to find errors, which might not even show up every time.

SimilarCode helps

While searching for similar code fragments, SimilarCode applies a simple statistical criteria to catch the identifiers which have been renamed in most places except a few. This occurs every time you execute analysis, no matter what options you choose.

Matches which are suspected to contain renaming errors are displayed with a warning overlay icon in both the view and the editor trees. Editor also shows a red panel telling you to pay attention to the usage of specific identifiers in the opened files:

(In the example above, you can notice that z has been renamed to zz in all but one of the visible occurrences. Unfortunately the erroneous occurrence is inside a green-colored area because the corresponding lines are in fact identical.) 

Additional notes

To make the Similar Code view show only those matches that have possible renaming errors (i.e. only those decorated with a warning icon), you can enable Only matches with possible errors filter in the view menu. (See the Using filters topic.)

A dedicated parsing mode (Search for code that… Contains possible renaming errors) helps in finding renaming errors by choosing more optimal algotithm options, but renaming errors will generally be found in any mode you choose.