scitools.com

← Metric catalog

Changed Functions 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 Functions

API IDCountDeclFunctionChanged
TargetsArchitectures Files Project
LanguagesAssembly C# C++ Java Python Rust Web
CategoriesCompare Contents
CostCached

Number of changed functions, compared to the comparison database.

Counts functions defined in both databases whose text differs. A function counts once, however many of its lines changed. See Functions for what counts as a function. Since changes come from a textual diff, a function 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 functions as new or removed.

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

--- functions.cpp (comparison database)
+++ functions.cpp (current)
@@ -1,24 +1,35 @@
 #include <iostream>
 
 #define GETTER(name, value) int name() const { return value; }
 
 class Rect {
 public:
   GETTER(width, 10)
-
-  int perimeter() const {
-    return 2 * (width() + 5);
-  }
+  GETTER(height, 5)
 
   int area() const {
-    return width() * 5;
+    return width() * height();
   }
 };
 
 int squared(int x) {
   return x * x;
 }
 
+int cubed(int x) {
+  return squared(x) * x;
+}
+
+int volume(const Rect &r, int depth) {
+  return r.area() * depth;
+}
+
 void report(const Rect &r) {
   std::cout << r.area() << std::endl;
+  std::cout << volume(r, 2) << std::endl;
 }
+
+int main() {
+  report(Rect());
+  return cubed(3);
+}

Rect::area() has a changed line and report() has a new line, so CountDeclFunctionChanged = 2. squared() and Rect::width() are the same in both versions, so neither counts.

See New Functions and Removed Functions for functions that exist in only one version, and Functions 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 function changed.