Exercise 1.2: Running a structural analysis code review

This exercise assumes you have completed Exercise 1.1: Importing the required resources. In Exercise 1.2 you read a user scenario first. Then you assume the role of the software architect described in the user scenario and use the project you imported in Exercise 1.1 to complete the exercise.



User scenario

To review newly written code to assess its quality, the architect wants to look for general anti-patterns. Anti-patterns are known problems that occur in code and do not follow best practices. While design patterns are good models to follow, anti-patterns are bad models that you should avoid. Some specific anti-patterns include the following types:

In the first exercise, the architect runs a code review to look for the anti-patterns described above.



Exercise

In this exercise you perform the following tasks:

  1. Select a code review to run.
  2. View the rules applied in the code review.
  3. Choose what code to run the review on.
  4. Run the code review.
  5. View the findings of the code review.
  6. Select a finding to see the following information for it:


Selecting a code review

To select a structural analysis code review:

  1. On the toolbar in the Code Review view click the Manage Rules icon, .
  2. Code Review view

  3. In the Select Code Review list, click Structural Analysis Code Review.
  4. Expand the Structural Analysis folder and subfolders to see the rules applied in the code review, as shown below. Click OK.
  5. Preferences window



Selecting a code base to review

To select the workspace as the code base to review:



Running the code review

Once you select the code base to review, the code review runs. You can track its status by checking the progress bar in the lower-right corner of the view.



Viewing the code review findings

When the code review is finished, the findings are shown in the Code Review view, as shown in the following screen capture:

Code Review findings, 1 collapsed folder

The following information is provided in the Code Review view.



Getting more information on a code review finding

To get more information on a finding in the code review:

  1. Expand the Structural Analysis: Cyclic Dependency folder. It contains four findings, as shown in the following screen capture:


  2. Code Review findings, 1 expandeded folder

    Each finding is preceeded by an icon that indicates its severity level.

    If an icon has a lightbulb next to it (), that means that a quick fix exists for the finding. A quick fix is an automated, supplied solution for a specific finding. The quick fix icons are shown in the following illustration:

  3. Double-click the finding that begins with Event.java. Details about it appear in two places, as outlined in the following points and screen capture:
  4. Source code & detailed information for selected finding

You have completed Exercise 1.2: Running a structural analysis code review.



Leveraging the power of a code review

By proactively running a code review you are able to spot problems early so you can also correct them early, before they cause the following problems:

In Exercise 1.4, you build on the work you did in Exercise 1.2 by fixing a code review finding.



Wrapping up Exercise 1.2

You have completed Exercise 1.2: Running a structural analysis code review. In it you performed the following tasks:

  1. Selected a code review to run.
  2. Viewed rules applied in the code review.
  3. Chose a body of code to run the review on.
  4. Ran the code review.
  5. Viewed the findings of the code review.
  6. Selected a finding to see the following information for it:


Now you are ready to begin Exercise 1.3: Defining an architectural control rule.

Terms of use | Feedback
(C) Copyright IBM Corporation 2000, 2004. All Rights Reserved.