Objective
Understand how to explore and correct violations identified during coding standard analysis that may result in construction defects.
- Select Parasoft > Show View> Quality Tasks (if not displayed already).
- Open the Quality Tasks menu and select Configure Contents
- Select Details from the Configuration list and click OK.
- Expand the the Fix Static Analysis Violations folder to review coding standards violations reported for the ATM project.
The initionalization error (INIT-06-1) is a very common defect that occurs when developers forget to initialize a member variable in a constructor, which may result in a program crash. - Right-click the violation and select View Rule Documentation from the shortcut menu. The documentation contains the following information for each rule violation:
- A description of the rule
- Notes on the rule
- Benefits of fixing the code
- Example of the violation
- How to repair the code
- Reference
- Close the rule description help window.
- Double-click the reported violation to view the code. The source editor will open and the cursor will be placed at the line with the reported violation.
Fix the defect by adding the following line:myCurrentAccount = 0;
to the body of the constructorATM::ATM(Bank* bank, BaseDisplay* display)
- Select File > Save from the main menu or click the save button in the main toolbar to update the code.
- Rerun coding standards analysis (see steps 2 and 3 in Exercise 1). The violation is no longer reported.