New Modules 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 Modules
| API ID | CountDeclModuleNew |
| Targets | Architectures Files Functions Modules Project Subprograms |
| Languages | Fortran Jovial Pascal |
| Categories | Compare Contents |
| Cost | Cached |
Number of new modules, compared to the comparison database.
Counts modules defined in the current database but not in the comparison database. See Modules for what counts as a module. Since changes come from a textual diff, a module 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 modules as new or removed.
For example, diffing a file's current version against the comparison database's version:
--- modules.f90 (comparison database)
+++ modules.f90 (current)
@@ -1,28 +1,44 @@
MODULE counters
IMPLICIT NONE
INTEGER :: total = 0
END MODULE counters
-MODULE legacy_io
- IMPLICIT NONE
-CONTAINS
- SUBROUTINE print_value(x)
- REAL, INTENT(IN) :: x
- PRINT *, x
- END SUBROUTINE print_value
-END MODULE legacy_io
-
MODULE constants
IMPLICIT NONE
- REAL, PARAMETER :: pi = 3.14
+ REAL, PARAMETER :: pi = 3.14159
END MODULE constants
MODULE geometry
USE constants
IMPLICIT NONE
CONTAINS
REAL FUNCTION circle_area(r)
REAL, INTENT(IN) :: r
circle_area = pi * r * r
END FUNCTION circle_area
+
+ REAL FUNCTION square_area(side)
+ REAL, INTENT(IN) :: side
+ square_area = side * side
+ END FUNCTION square_area
END MODULE geometry
+
+MODULE units
+ IMPLICIT NONE
+ REAL, PARAMETER :: cm_per_inch = 2.54
+END MODULE units
+
+MODULE reporting
+ USE, INTRINSIC :: iso_fortran_env, ONLY: output_unit
+ IMPLICIT NONE
+CONTAINS
+ SUBROUTINE report(x)
+ REAL, INTENT(IN) :: x
+ WRITE (output_unit, *) x
+ END SUBROUTINE report
+END MODULE reporting
+
+MODULE settings
+ IMPLICIT NONE
+ LOGICAL :: verbose = .FALSE.
+END MODULE settings
units, reporting, and settings are new, so CountDeclModuleNew = 3. reporting also uses the intrinsic module iso_fortran_env, but it isn't defined in the project, so it doesn't count.
See Removed Modules for the reverse of this metric, Changed Modules for modules in both versions that differ, and Modules 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 module changed.