Locating unreachable code in a file

Highlight lines of code in COBOL files in local projects that are unreachable during execution.

Before you begin

If you are using the COBOL Editor, you can customize the highlighting of unreachable code:
  1. On the main menu bar, click Window > Preferences.
  2. Expand General > Editors > Text Editors and click Annotations.
  3. In the Annotation types list, select Warnings.
  4. Choose the annotation options that you want, and click OK to save the changes.

About this task

The Identify Unreachable Code feature identifies potential dead code based on static analysis of the program source and therefore is not a reflection of the actual execution path. Before you delete any code, verify that the code is correctly identified as unreachable.

Restriction: This feature has several restrictions:
  • Copybooks that are associated with the open file are not included in the program analysis. The analysis works within the boundary of the file.
  • Quick fix is not available.
  • Not available for programs that contain the following statements:
    • EXEC CICS HANDLE
    • EXEC CICS IGNORE
    • EXEC CICS PUSH
    • EXEC CICS POP
    • EXEC SQL WHENEVER
  • CALL statements that do not return to the calling program can result in results that are not correct. Statements after a CALL statement are not marked as unreachable.
  • Unreachable code is reported on a per line basis. If a line contains both code that is reachable and code that is unreachable, the reported results might be incorrect. Use the COBOL formatting tool to enforce the one-verb-per-line rule to prevent reachable and unreachable code in the same line.

Procedure

  1. Open a COBOL file in the COBOL Editor or System z® LPEX Editor.
  2. Right-click in the file, and click Source > Identify Unreachable Code. If no code is identified as unreachable, a message is displayed. Otherwise, the code that is unreachable is highlighted.

Feedback