COBOL CloneDR

The COBOL CloneDR identifies and displays code segments within a system that are identical or nearly identical (clones), supporting the consolidation of clones to reduce the size and increase the clarity and reliability of the source code. It is a member of Semantic Designs family of Clone Detection and Removal tools, described more completely here.

COBOL CloneDR Features

  • Dialects: ANSI COBOL85, IBM VS COBOL II, IBM Enterprise, AS400. Other dialects can be accommodated.
  • Runs under Windows, not requiring mainframe execution platform
  • Works with arbitrary subsets of source code base
  • Can handles thousands of source files
  • Handles COPY and REPLACE preprocessor directives
  • Analysis can be parameterized by clone similarity threshold, clone size, maximum number of clone parameters, and other limits, allowing tailored use
  • Report characterizes each clone tuple by mass, number of instances, number of parameters, similarity ratio, language syntax category, length, and location, with each instance pictured
  • Produces a summary report in HTML including statistics sorted by various attributes and with links to HTML pages describing individual clones like this.

You can see a complete Clone Detection Report for a COBOL source code base of 77,000 lines that has 58% redundancy.

Download an evaluation version

Eclipse/RDz COBOL CloneDR User Interface

For installations using the Rational Development for System Z (RDz) Environment, the CloneDR tool has an RDz-based, interactive GUI that supports:

  • Browsing of diagnostic results in an expandable tree view
  • Tree view diagnostics linked and integrated with an LPEX COBOL editor
  • Visual display of selected clone tuples in source code with parameter fragments (differences) listed in tree view and highlighted in editor
  • Direct access to statistical summaries

Sample Snapshots from the Eclipse/RDz COBOL CloneDR UI

To illustrate CloneDRs RDz-based graphical user interface (GUI), we show an example where the results of a clone analysis have been loaded into RDz. The discussion of these examples not only illustrates the GUI itself, but also offers some insight into the nature of parameterized clones and their possible treatment.

Example 1

The first image below shows an RDz window with a tree view of the clone results in the bottom frame and an editor in the upper frame. Clone Set 22 has been selected and expanded, revealing each of the clone instances for the clone set. Notice that the entity description for each instance gives the total number of lines of code in the instance as well as the line range in the source file in which it was found. The source file name and the fully elaborated path to the file are given in the details. The selection of this line in the tree view causes the editor to position the display at the first of the clone instances and to highlight all of the instances in the file. The display shows all of the first clone instance and the first seven lines of the second instance. The parameterized portions of the clone instances are highlighted in gray. The six parameters, then, are the data item name at the 05 level and the values of the first five subsidiaries. The other data item names, then, are identical among all the clone instances, as well as all the PIC strings and the VALUE settings for BEGIN-DATE and END-DATE. If the editor were scrolled, all the other clone instances encountered would be similarly highlighted.



Example 2

The next image shows the display after the second clone instance from the set has been selected in the tree view. This causes the second clone instance in the source file to be highlighted differently from the others. The clone instance was also expanded in the tree view to reveal its parameters. Notice that for each parameter, the entity description gives the number of lines it spans and the line (or line range) in which it appears. The specific parameter value of each parameter in the selected clone instance is shown in the detail. These are the same parameter instances that are highlighted in the highlighted clone in the editor.



Example 3

In the next image, a particular clone parameter, the first from clone instance 2, has been selected in the tree view. This causes it to be uniquely highlighted in the editor.



Example 4

In this image, the editor shows that we have selected another clone set, and a part of the first clone instance is displayed and highlighted. But this image primarily illustrates the options available in the context menu brought up by right clicking on a clone set entity. In first level menu, we have navigated to the second item, Expand Collapse, which triggers a secondary context menu for manipulating the tree view. In this menu, "Expand below" and "Collapse below" either fully expand or fully collapse the selected item. "Expand everything" and "Collapse everything" would fully expand or fully collapse every item in the tree view. As for the other items in the primary context menu, the first allows one to view the HTML page the CloneDR has generated to describe the selected clone set. This is one of the same pages described above in the general discussion of the CloneDR.



Example 5

In this image, we have selected "View CloneDR HTML page for the clone set" from the context menu for Clone Set 22. The editor frame is replaced by an HTML browser frame that contains the CloneDR HTML report for CloneSet 22. This is a browsable document with links in the clone index to descriptions of each individual clone instance, as well as links for navigating through the entire nest of HTML documents generated by the CloneDR in its analysis. Much of the information is the same as can be seen in the RDz CloneDR presentation.



Example 6

Our final image shows a subtle detail that can arise in clone parameters. In Clone Set 23, there are only three parameters (two that are shown in the editor display, the other being in a subsequent line), but seven parameter instances. Consider Parameter P1, whose value is TOTAL-COLLEGE-ENTRY. This parameter occurs at the same position in each clone instance, and in each clone instance the same value appears in both positions. (The specific value may vary from clone instance to clone instance.) If different values appeared in the two positions in any of the clone instances, then separate parameters for the two positions would have been created. Since the clone instance is open, all of its parameters are highlighted in the display. Since the second instance of Parameter P1 is selected, it is most brightly highlighted in the display. Its "sibling" instance, the first instance of Parameter P1, is highlighted in a different color. The "cousin" parameter instances are all highlighted in yet another color, to distinguish them from the P1 instances.

Suppose you wished to consolidate this clone into a copylib. A single copylib parameter could be used for both instances of P1, and another parameter for all the instances of P2. That is because no matter how the copylib were instantiated, the same value would need to be supplied for all the positions of each parameter. Thus only three parameters would be required, even though the clones differed at seven positions.

Semantic Designs also offers other COBOL tools.

For more information: info@semanticdesigns.com    Follow us at Twitter: @SemanticDesigns

COBOL Clone DR