Number of line of codes and line of comments
- 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).
- A line containing code and comment is counted twice (one as Line of code, one as Line of Comment).
- Blank lines (i.e., only LF + CR or LF or CR) are skipped.
- Preprocessed code is not used to count the LOC (impact on C, C++, Cobol).
- A comment starting right before or right after the end of an object are attached to the object.
- A comment on a line of code with multiple languages (e.g., embedded SQL) is counted on both languages.
- 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:
- set x=1;
- set x=1; set y=2; set z=3;
- A line of code does not have to be a complete statement as well. CAST considers the following example as 4 lines of code:
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.