New Subprograms is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.
New Subprograms
| API ID | CountDeclSubprogramNew |
| Targets | Architectures Files Functions Modules Packages Project Subprograms |
| Languages | Ada Basic Fortran Jovial Pascal |
| Categories | Compare Contents |
| Cost | Cached |
Number of new subprograms, compared to the comparison database.
Counts subprograms defined in the current database but not in the comparison database. See Subprograms for what counts as a subprogram. Since changes come from a textual diff, a subprogram must have Lines to count. For an architecture or the project, the counts from its files are added together. A file added to or removed from an architecture counts all of its subprograms as new or removed.
For example, diffing a file's current version against the comparison database's version:
--- subprograms.adb (comparison database)
+++ subprograms.adb (current)
@@ -1,25 +1,34 @@
with Ada.Text_IO;
package body Subprograms is
function Circle_Area (R : Float) return Float is
begin
- return 3.14 * R * R;
+ return 3.14159 * R * R;
end Circle_Area;
function Square_Area (S : Float) return Float is
begin
return S * S;
end Square_Area;
- procedure Old_Report (X : Float) is
- begin
- Ada.Text_IO.Put_Line ("Value:" & Float'Image (X));
- end Old_Report;
-
procedure Log_Value (X : Float) is
begin
- Ada.Text_IO.Put_Line (Float'Image (X));
+ Ada.Text_IO.Put_Line ("Logged:" & Float'Image (X));
end Log_Value;
+ function Triangle_Area (B, H : Float) return Float is
+ begin
+ return B * H / 2.0;
+ end Triangle_Area;
+
+ procedure New_Report (X : Float) is
+ function Format (V : Float) return String is
+ begin
+ return "Report:" & Float'Image (V);
+ end Format;
+ begin
+ Ada.Text_IO.Put_Line (Format (X));
+ end New_Report;
+
end Subprograms;
Triangle_Area, New_Report, and the function Format nested inside New_Report are new, so CountDeclSubprogramNew = 3.
In Ada, a subprogram declared in a spec file and defined in a body file counts once, in the body file. Its declaration in subprograms.ads doesn't add to these counts, even though Subprograms counts it in both files.
See Removed Subprograms for the reverse of this metric, Changed Subprograms for subprograms in both versions that differ, and Subprograms for the total count. See Compare two versions of a project ↗ for how entities are compared, and New Lines, Removed Lines, and Changed Lines for how much a subprogram changed.