Complexity Profile Graph (CPG)

The Complexity Profile Graph, or CPG, is a statement-level complexity or comprehensibility metric. Each segment, which corresponds roughly to a program statement, is assigned a complexity that is a weighted sum of:

Reachability - the number of conditions that must be evaluated to reach the segment from outside of the enclosing method, function, or other top-level statement block. This is the traditional definition of reachability.

Content - the log of the number of significant tokens in the segment. Some punctuation, such as block-enclosing braces or a statement-ending semicolon, is not considered significant. A pair of parenthesis is counted as one token.

Breadth - the number of statements, methods, etc. in the innermost block containing the segment.

Inherent - value assigned based on the inherent complexity of the innermost enclosing structure. For example, segments in switch or case statements are assigned an inherent complexity of 3.0. This reflects the view that some structure types are inherently more complex than others.

The CPG window "Data Sets" menu allows any combination of these values and the total complexity to be viewed.

Currently, the CPG is implemented only for Java and Ada.


 
 

CPG Window

The main section of this window shows the complexity values for the currently selected data sets. If the source is unedited, selecting segments in the CPG window will select the corresponding text in the source CSD window, and vice versa. The selection in the CPG window is shown as a yellow background. If the source is unedited, a black rectangle shows the segments that are currently visible in the CSD window.

Each data set value is scaled in the display, by the weight used in computing the total complexity, unless there is only one data set, in which case it is shown unscaled.

The label at the top of the CPG window shows the complexity values of the segment under the mouse cursor. If the weight of a particular data set is not 1.0, the value and weight are displayed.

The scale button allows the graph to be scaled, from two-pixel wide bars to screen-width bars.

If "Scroll Lock" is on, the CPG window and the CSD window from which it was generated will scroll as one. This option is not available if the source has been edited.

A scrollbar at the bottom of the window allows the CPG to be scrolled if it does not fit in the window.


 
 

File Menu

New - opens an empty CSD window for the selected language. Recently opened and currently open file types will appear under the main menu; other file types will be under the "Other" submenu.

Open - brings up an open file dialog.

Sync All - checks file modification times for all files in jGRASP with those on disk. For each file that has been modified outside of jGRASP, the user is given the option of reloading the file from disk. If the user chooses not to reload, the next check will report a modified file only if there is an additional modification. A save operation, however, will give an external modification warning even if there is not an additional modification, when the file has been modified outside of jGRASP.

Close - closes the CPG window.

Close All - closes all CSD Windows. The user will be warned and given a chance to cancel if modified files exist.

Save Data As - allows CPG complexity values to be saved in a straightforward text format.

Save All - saves files in all CSD windows.

Recent Files - allows recently closed files to be re-opened.

Workspace - allows switching the workspace and editing workspaces. A workspace includes the currently open projects and windows, as well as workspace-level settings. Workspaces in jGRASP are named rather than being stored in a user-specified file (as is done on other common IDEs).

New Workspace - brings up a new workspace dialog.

Edit Workspaces - brings up a workspaces dialog.

Save Current Workspace - saves all the current workspace settings: the desktop, projects, and workspace settings. This happens at exit or when changing workspaces anyway, so this is provided only for protection against a crash.

Disconnect From Source Window - dissociates the CPG window from the source CSD window. A second CPG window can then be generated from the same source.

Escape Virtual Desktop / Enter Virtual Desktop - takes the CPG window in and out of the virtual desktop.

Raise/Lower - in the virtual desktop, move the CPG window to the front if it is not on top. If it is on top, move it to the back. Outside the virtual desktop, move the CPG window to the back.

Exit jGRASP - quits the application. If a compile process is active and there are modified files, this will not be allowed, since the old files are backed up before compiling, and restored afterward - this is not a concern if the "Auto Save" setting is checked (it is checked by default), in which case all files are saved before compiling.


 
 

View Menu

Vertical Orientation - if on, the segments axis is vertical, and the complexity horizontal.

Show Key - if on, a key that shows the color for each data set is shown (if there is more than one active data set).

Show Axis Labels - if on, the segment and complexity axes are labeled. If there is only one active data set, the complexity axis is labeled with the name of that data set, otherwise it is labeled with "complexity".

Show Number Labels - if on, segment and complexity axes have value labels. The labels are evenly spaced based on a minimum inter-label separation.

Toolbars - allows the jGRASP interface to be configured with a single toolbar, separate toolbars for each window, or no toolbars. Windows that are outside the virtual desktop will always have a separate toolbar, unless the mode is set to "None".

Toolbar Buttons - allows the jGRASP interface to be configured so that toolbar buttons show icons only, text only, or both icons and text.

Messagebars - allows the jGRASP interface to be configured with a single messagebar, separate messagebars for each window, or no messagebars. Windows that are outside the virtual desktop will always have a separate messagebar, unless the mode is set to "None".

Menus - allows the jGRASP interface to be configured with a single menu or separate menus for each window. Windows that are outside the virtual desktop will always have a separate menu.


 
 

Data Sets Menu

This menu allows each data set to be turned off or on.