This topic describes how to modify a source code file to
fix a problem detected by code review.
This topic contains the following subtopics:
Fixing a problem in the
source code
Follow these steps:
In the right pane of the Software Analyzer Results
view:
- Expand the rule containing the results that you are interested
in.
- Below the rule right-click a result and click View
Result.
The source code file in which the result was
found is opened in
one of the supported editors. Note: Which
editor opens depends on the editor configuration and on which editor
was last used to open a file of the same type.
In the
editor:
- The source code file is positioned to display the lines of code
that are affected by the result.
- The affected lines of code are highlighted or are underlined with
a squiggly line.
- The severity icon for the rule is displayed in the left margin
at the first line of the problem. Floating the mouse over the icon
displays the text of the rule.
In the example in
Figure 1 the rule is
Avoid
IF without ELSE and the severity is Warning. The following
highlighting is shown:
- The entire IF statement is underlined with a squiggly line.
- Icons are displayed in the vertical ruler (left
margin) and the overview ruler (right margin) of the editor to mark
the first line of the problem source code.
- The icon in the vertical ruler is a severity icon
that matches the severity of the rule.
- Hovering the mouse over either icon displays
the rule text, Avoid IF without ELSE.
Figure 1. View of a rule
violation displayed in the COBOL language editor
In the editor:
- Modify the source code to fix the problem that caused the result
to be generated.
Note: You are not limited to fixing
one problem. You can make as many updates to the source code file
as you wish, as you would normally do in the editor.
- Save the file and close the editor.
At this point, you can rerun the code analysis to verify that
your change to the source code fixed the problem.
Working with the code review
highlighting
The highlighting of source code
text affected by a code review result is present in any
of the supported editors. See Editors that support COBOL and PL/I Code Review.
The highlighting remains with the source code file until
one of the following events occurs:
You can hide or show the code review icons
in the margins of the editor from within the editor itself:
- Right-click over the vertical ruler (left margin) or the overview
ruler (right margin) of the editor.
Note: In the Basic LPEX editor
or the System z LPEX editor,
you must click over the left margin.
- Click Show software analysis annotations to
hide or show the icons in the margins.
Note: When you open a source code file into a supported editor
from a result in the Software Analyzer Results view, the editor changes
the setting to show the code review icons in the margins.
You
can also use the workbench Preferences window to hide or show the
code review highlighting:
- Click .
- In the Annotation types list, click the
entry for one of the icons. The identifiers are:
- Code review recommendation
- Code review severe problem
- Code review warning
- To show or hide the highlighting:
- Select Vertical ruler or Overview
ruler to show the icon in the ruler, or clear the option
to hide the icon.
- Select Text to display the highlighting
or hide the highlighting.