Function: The command scans the program code of the open CODESYS project for copied code, and opens the “Clone detection results” view to display the detected cloned code blocks. In the process, only code blocks larger than a specific size are considered to be clones. Very small chunks of code are not displayed as clones.
Call:
-
Menu bar: “Build Static Analysis”
-
Context menu: “Static Analysis”
Requirement: The CODESYS project is open.
Two code positions are considered clones if they have the following properties:
-
Same structural composition
-
Variables have the same data type.
-
Variable names may be different (exception: component access). However, an identifier that is contained multiple times in the code has to be in the same place in both code positions.
-
Literals have the same data type.
-
Literals may be different. A literal that occurs multiple times in the code has to occur at the same place in both code positions.
|
Tab to display the search results
|
|
The tab displays the code clones in a tree view and provides commands and filter options. The first occurrence of a duplicate from the set of duplicates is taken as the root node. The background color of the child nodes indicates whether the code is different or completely identical. Same colors mean the "same code". The contents of the tree view are sorted in descending order by the number of statements of the duplicated code. |
Commands and filters on the |
|
“Subnodes/Clone” |
Number of subnodes (statements) in the code block If the number of subnodes is less than 20, then the code clone is not considered. |
“Filter on Object” |
Input field for an “Object”, by which the clone list is filtered |
“Show selected clones” |
Requirement: Two child nodes of the same parent node are selected. Both programming objects are displayed in the upper part of the view for comparison. In the process, the code duplicates are highlighted and differences (for example, different variable names) are highlighted in a different color. |
List of code clones |
Columns
Double-clicking a child node opens the corresponding programming object, and the duplicated code block is selected there. |