CORPORATE RESOURCES…

Avoid duplicated code with clone detector

Reusing code is usual in software development, but this practice makes the code less maintainable, besides introducing defects. That’s why we have the Kiuwan Clone detector.
As we write an application and this development extends over time, very similar or identical code fragments begin to appear. These fragments are known as ‘clones’.

The existence of these clones makes the evolution and maintenance of the application more difficult since a single change should be done in different places.

Kiuwan’s clone detector searches for fragments of tokens that are very similar.
The term ‘token’ refers to each of the atomic elements identified by the analyzer. There are three types of tokens:

Operators and reserved words (specific for each language)

Identifiers: variable names, function names, etc.

Literals: numbers and string constants used in the code.

Kiuwan also generates defects of ‘duplicated code’ according to the size of the fragments found:

You can configure the minimum tokens that Kiuwan uses to detect a clone. This is done at two levels:

a) In Kiuwan’s Local Analyzer go to ‘advanced’ options, then configure the number of tokens to detect a clone. This is configured independently for each language , so you can configure a different number for different languages: