Reviewing a fix
Last updated
Last updated
Once you have filtered for the set of fixes for review, you may begin processing them. That typically begins with clicking on the Unresolved tab to see what fixes need to be reviewed. In our example, we will be looking at a set of fixes within the Object Visibility category. There were 15 fixes identified. To show how to process a fix, we will look at Fix OV-LFA-1-2.
In this example, it has detected an encapsulation problem where a variable that should be declared private
to the class was declared as public
. To learn more about this issue, you can click on the link CERT Secure coding standard OBJ01-J to learn more about encapsulation problems.
To correct this Encapsulation Problem, the variable is made private
and a pair of accessor methods to set and get the value is created. Any other files that reference the variable are updated to use the accessor methods instead of modifying the variable directly. As a result, the summary of the fix shows that there are offered changes to a total of 4 files.
To see the diffs for all of the 4 files, click on the Show Diff button. Doing that reveals an expanded display.
Since there were 4 files affected, there are 4 Diff: tabs shown where each tab corresponds to the changes suggested for each affected file. In this example, Diff: 3 is selected and displayed. This is the diff for the file containing the improperly declared public variable.
The lines that were changed are identified by the red highlighted statements. In this example, that is Line 53. The text below shows the corrected code with green highlights. The class variable double combinedCost
was declared public
but should be private
. The iCR generated code corrects the issue by making the variable private
, shown as the replacement for line 53. In addition, the accessor methods getCombinedCost
and setCombinedCost
are added to allow controlled access to the now private
variable as shown in added lines 107 through 114.
If you want to browse the original source file associated with this fix, you can click on the Show Source button. A scrollable window will appear below the diff window with tabs for each of the files that have a diff for this fix. You can click on any tab to browse the source for any of the affected files. In this case Source of Diff: 3.
You can scroll through the original source file independently of the diff window.
Once you are satisfied with reviewing a particular correction, you can select other Diff: tabs to review all the suggested changes for this fix.
To view other fixes, scroll through the list of fixes or select new filters.