Statement counts

Statement counts are an alternative way to line counts to measure the system size. Project Metrics displays statement counts by procedure, class, file and project.

Statement counts
Statements
STMT
Declarative
STMTd
Executable
STMTx
Control
STMTc
Non-control
STMTnc

STMT Number of statements

There can be one or more statements on a (logical) line of code. Statements on a line are delimited by a colon (:). A statement can continue on the next line with the line continuation character (_).

The following rules apply:

STMTd Number of declarative statements
STMTx Number of executable statements

Statements fall into two groups: declarative and executable.

STMT = STMTd + STMTx

Declarative statements have no instant run-time effect. They define data structures, procedures and constant values.

Executable statements are found within procedures. All statements ouside procedures are declarative.

The minimum STMTd for a regular procedure is 2 (Sub, End Sub).

STMTc Number of control statements

A control statement is an executable statement that can alter the order in which statements are executed.

The following statements do not count as executable control statements:

A control statement adds to the complexity of the program.

STMTnc Number of non-control statements

A non-control statement is an executable statement that is neither a control statement nor a declarative statement. A non-control statement does not normally alter the control flow.

STMTnc = STMTx − STMTc

XQT Executability

Executability measures the amount of executable statements. It equals the number of executable statements divided by the number of all statements.

XQT = STMTx / STMT

A project with a low XQT contains relatively many declarative statements such as class declarations, user-defined types, variables, procedures, events, enumerations and constants. An extremely low XQT could indicate missing implementation, where only the declarative code is in place and the executable code is missing. Alternatively, the program could be bloated with too many declarations that are of little use.

When XQT is high, the amount of declarations is relatively low and the amount of executable code is thus high. A high XQT could be an indication of a bad design. The addition of temporary variables, the use of constants and shorter procedures could add legibility to the application.

XQT varies from 0% to 100%. If there are no statements, XQT=0%.

CTRL Control density

Control density measures the amount of control statements. It equals the number of control statements divided by the number of all executable statements.

CTRL = STMTc / STMTx

A low CTRL indicates a program with relatively few jumps, loops, conditionals or error handling relative to other executable code. The control flow is relatively straight and clear, and the continuous blocks of code are long. A high CTRL indicates a high amount of jumps, loops, conditionals and error handling. The amount of actual data processing may be low as most of the code is devoted to logic and jumps. The code may be inherently complex, or it may be badly designed.

CTRL varies from 0% to 100%. If there are no executable statements, CTRL=0%.

See also Cyclomatic complexity

SDENS Statement density

Statement density measures the number of statements per logical line of code.

SDENS = STMT / LLOC

SDENS equals 1 when there is exactly one statement per line. Typically the actual value is close to 1.

SDENS can grow over 1 when multiple statements are put on a line using either the colon (:) or the single-line If..Then statement. A high SDENS indicates code that doesn't follow a "one statement per line" coding style.

SDENS can fall below 1. Certain lines don't count as statements, even if they are included in LLOC. These lines are compiler directives (# lines) and lines with just a line label or line number. A low SDENS is not a problem.

The use of line continuation doesn't affect SDENS.

Project Analyzer Help