TutorialAuditing for Quality




Prev | Up | Next | Back | Forward | Online Documentation Home Page

Auditing for Quality

This chapter illustrates how Ada-ASSURED enforces project-wide standards for code appearance and quality, and assists in finding and correcting code.

We begin by opening a sample file that contains numerous intentional style violations. When an Ada file is opened, it is automatically formatted according to Ada-ASSURED's built-in style guidelines. Opening the file in syntactic mode TEXT instead of compilation enables us to see the file in its original form for comparison:

Next, do the following to duplicate the buffer and change the syntactic mode of the copy to compilation, which formats and analyzes it as if it had been opened as an Ada compilation unit in the first place:
  1. Invoke command duplicate-buffer from the menu.

    X View/Buffers/Duplicate Buffer
    MS Window/Duplicate Buffer

  2. Invoke command coerce-buffer from the menu.

    X View/Buffers/Coerce Buffer...
    MS Window/Coerce Buffer...

    Then verify that the target syntactic mode is compilation, and click on OK.

Resize and reposition the two windows side-by-side so you can compare the two versions of the file. Use the scrollbar in the copy to find generated inline violation and error messages. Each message added by Ada-ASSURED is formatted as a comment so it will not prevent compiling otherwise correct Ada code.

Ada-ASSURED provides two levels of enforcement: Violations and Indicators. Indicators are considered less severe than violations. By default, indicators do not appear in-line, but only in the MESSAGES view. To open a new window that contains the MESSAGES view:

  1. Iconify the original window containing the TEXT-mode version to get it out of the way.

  2. Invoke command change-view from the View menu of the formatted version. In the dialog box, verify that the specified new view is MESSAGES and that New Window is selected. Then click on OK.

The MESSAGES view can be used to generate style reports, or as an aid for interactively removing violations. The following instructions demonstrate how the MESSAGES view can be used to correct style problems.

  1. Resize and reposition the two windows so that they overlap as little as possible.

  2. Click on the text of the first violation in the MESSAGES view—anywhere but the hot link [V13]. Now click on the text of the last error message—anywhere but the hot link [E2]. Notice that the corresponding code is selected in the Ada code, and that the window scrolls to display it.

  3. Message codes of the form [Vnum] or [Inum] are hot links to the SPC Quality and Style Quidelines for Professional Programmers. Message codes of the form [Enum] are hot links to the Ada RM. Try clicking on a few message codes.

  4. Click on the text of violation [V1]. This guideline requires lengthy association lists to use the named format. In the window containing the Ada code, click Select on this message to enable the convert-list-to-named transformation. Next, choose this transformation from the Transforms menu to automatically do the conversion.

  5. In the MESSAGES view, click on the text of violation [V10]. This will set the structural selection to the corresponding unnamed block. Move to the source code window and strike Enter. This will insert an <identifier> placeholder and cause the violation message to disappear. Enter a block name at the placeholder and strike Enter. Note that it is automatically echoed after the matching end.

When an Ada program is edited in a TEXT buffer, a MESSAGES view of the buffer is refreshed, on demand, by the format command. However, for TEXT buffers, clicking in the MESSAGES buffer does not navigate to the corresponding point in the Ada program.

The enforcement of the quality and style guidelines is highly customizable. See Chapter Initial Customization for a brief introduction on how to customize Ada-ASSURED.


Forward