Defining Potential Code Anomalies

You can view and modify existing definitions of potential code anomalies (other than range overlaps and range jumps) in the Coding Standards folder in the Interactive Analysis Search dialog box. In Interactive Analysis, click Advanced Search to open the Search dialog box and expand Criteria to view Coding Standards folder.

To define a new code anomaly, you must define an advanced search criterion for the anomaly and a matching entry in the file <EA Home>\Data\CodeDefects.xml. The entry has the form:

<DEFECT Id="name"
Internal="True|False"
Enabled="True|False"
Caption="display name"
ListName="list name"
Criterion="path of criterion"
Model="Model Type"/>

where:

Id
This is a unique name identifying the code anomaly in the product.
Internal
This specifies whether the anomaly is implemented internally in program code (True), or externally in an advanced search criterion (False).
Note: You must specify False. Code anomalies with an Internal value of True cannot be modified.
Enabled
This specifies whether the code anomaly is displayed in the Executive Report.
Caption
This is the display name for the anomaly in the Executive Report.
ListName
This is the name of the list of anomalous code constructs displayed in the Executive Report category of the Interactive Analysis Code Search tool.
Criterion
This is the full path name of the criterion in the Interactive Analysis Advanced Search tool, including the tab name (General) and any folder names. For example, General:Coding Standards\MOVE Statements\Possible Data Padding.
Model
This is the Interactive Analysis model for the source files to be searched, for exmple, COBOL.
Some of the commonly used model types are:
COBOL
COBOL source files
JAVAFILE
Java source files
JCL
JCL source files
NATURAL
NATURAL source files
PLI
PL/I source files
Note: Not all possible model types are listed above. Some model types like PL/SQL files do not have level 2 support, so cannot have Code Search queries run against them. See Supported Features by Language for more information.

For some languages, such as C and C++, there are no pre-defined Code Search queries, so they have not been listed.

You can find the full list of models in the Enterprise Analyzer installation directory, under \Model\HyperCode. You can find the exact name of the model to use in the CodeDefects.xml in the model file itself. For example, you can find the model name for COBOL in the NAME attribute in the following line in the Cobol.xml file:

<HYPERCODEMODEL NAME="COBOL" DESCRIPTION="COBOL Programs" VERSION="1.1">
Note: To get the code anomalies to appear on the report, you not only need to enable the Code defect entry, but you also need to check Code Defects on the Executive Reports tab:
  1. Click Options > Project Options.

    This opens the Options - Project properties dialog box.

  2. Click Reports > Executive Report.
  3. Check Code Defects.
  4. Click OK.

The following are examples of different defect entries:

<DEFECT Criterion="General:Coding Standards\MOVE Statements\Possible Sign Loss" 
ListName="Possible Sign Loss" 
Caption="Possible Sign Loss" 
Group="Cobol Coding Standards" 
Enabled="True" 
Internal="False" 
Id="Sign" 
Model="COBOL"/>
<DEFECT Criterion="General:Coding Standards\Unaligned Assignments" 
ListName="Unaligned Assignment" 
Caption="Unaligned Assignment" 
Group="Pli Coding Standards" 
Enabled="True" 
Internal="False" 
Id="Unaligned" 
Model="PLI"/>
<DEFECT Criterion="General:Java Best Practices\Basic\Empty If Statements" 
ListName="Empty If Stats" 
Caption="Empty If Statements" 
Group="Java Results" Enabled="True" 
Internal="False" 
Id="EmpIfStnts" 
Model="JAVAFILE"/>

You can display the anomaly caption in Japanese or Korean in the Executive Report by creating an entry for the anomaly in the file <EA Home>\Language\[Jpn|Kor]\CodeDefects.xrc. The entry has the form:

<String name="name"
listname="list name"
caption="translated display name"
description="description"/>

where:

name
This is the unique name of the code anomaly in the product. The Id attribute of CodeDefects.xml entry.
listname
This is the name of the list of anomalous code constructs displayed in the Executive Report category of the Interactive Analysis Code Search tool. The ListName attribute of CodeDefects.xml entry.
caption
This is the translated display name for the anomaly in the Executive Report.
description
this contains a description of the entry.