scitools.com

← Metric catalog

Removed 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.

Removed Functions

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

Number of removed functions, compared to the comparison database.

Counts functions defined in the comparison database but not in the current database. 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::perimeter() was removed, so CountDeclFunctionRemoved = 1.

See New Functions for the reverse of this metric, Changed Functions for functions in both versions that differ, 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.