scitools.com

← Metric catalog

Changed Executable Units 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.

Changed Executable Units

API IDCountDeclExecutableUnitChanged
TargetsArchitectures Files Project
LanguagesAda Basic C# Fortran Java Pascal Python Web
CategoriesCompare Contents
CostCached

Number of changed executable units, compared to the comparison database.

Counts executable units defined in both databases whose text differs. An executable unit counts once, however many of its lines changed. See Executable Units for what counts as an executable unit. Since changes come from a textual diff, an executable unit 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 executable units as new or removed.

For example, diffing a file's current version against the comparison database's version:

--- executableunits.java (comparison database)
+++ executableunits.java (current)
@@ -1,23 +1,41 @@
 abstract class Shape {
   abstract double area();
 
+  abstract double scale(double factor);
+
   String describe() {
-    return "shape";
+    return "a shape with area " + area();
   }
 }
 
 class Circle extends Shape {
   double r = 1;
 
-  double perimeter() {
-    return 2 * 3.14 * r;
-  }
-
   String name() {
     return "circle";
   }
 
+  Circle(double r) {
+    this.r = r;
+  }
+
   double area() {
-    return 3.14 * r * r;
+    return 3.14159 * r * r;
+  }
+
+  double scale(double factor) {
+    return area() * factor * factor;
   }
 }
+
+class Square extends Shape {
+  double side = 1;
+
+  double area() {
+    return side * side;
+  }
+
+  double scale(double factor) {
+    return area() * factor * factor;
+  }
+}

Shape.describe() and Circle.area() have changed lines, so CountDeclExecutableUnitChanged = 2. Circle.name() is the same in both versions, so it doesn't count.

In Web, a file with top-level code also counts as an executable unit. It's new or removed when that code appears or disappears, and otherwise it has the status of the whole file, so any change to the file counts it as changed.

See New Executable Units and Removed Executable Units for executable units that exist in only one version, and Executable Units 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 an executable unit changed.