CMS Assessment Model - Information - Definition and details - How to compute number of LOC for an application


The page provides definition & details on how the following metrics are computed for an application :

  • Number of LOC.
  • Number of Commented out LOC.
  • Number of Lines of Comments.
Applicable in CAST Version
Applicable RDBMS
Oracle Server?
Microsoft SQL Server?

Number of line of codes and line of comments

  1. Full lines of comments are skipped from the number of line of code (for a comment not starting at the begin of a line, the line is counted).
  2. A line containing code and comment is counted twice (one as Line of code, one as Line of Comment).
  3. Blank lines (i.e., only LF + CR or LF or CR) are skipped.
  4. Preprocessed code is not used to count the LOC (impact on C, C++, Cobol).
  5. A comment starting right before or right after the end of an object are attached to the object.
  6. A comment on a line of code with multiple languages (e.g., embedded SQL) is counted on both languages.
  7. A line of code is considered the actual number of lines independent of code statements.  Therefore CAST considers the following all as one line of code:
    1. set x=1;
    2. set x=1; set y=2; set z=3;
  8. A line of code does not have to be a complete statement as well.  CAST considers the following example as 4 lines of code:



Number of commented out LOC
counted after the corresponding natural metric ==> statistical result

Additional Explanation :
There are 2 contexts of LOC measurement.

First context is Technical Sizing. In this context, source files are taken into account. More specifically, objects that are analyzed by CAST AIP whose type inherit from the APM Sources category.

Second context is Quality Measurement. In this context, Source Files, Artifacts, and specifically targeted object types are taken into account.

Interpretation difficulties arise when:

  • an Artifact is defined by multiple Source files. In this case, the Artifact does not “belong to” a specific Source file and it leads to a parallel organization of objects. One can mistakenly create Modules and therefore Applications with Artifacts but without the Source files so that Technical Sizing indicates no or far less number of LOC than the results of LOC quality rules.
  • sources files contain source code from multiple technologies. This leads to counting multiple times LOC.

Enlighten for viewing LOC

Enlighten is a CAST tool which can be used to view LOC for items in the CAST knowledge base which has an associated LOC value.  If you add an item to the graphical view in Enlighten and then examine the properties (F12), you can then see the LOC value in the properties window.


Reference Webcall:28494

Zendesk 3274