scitools.com

← Metric catalog

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

API IDCountDeclClassRemoved
TargetsArchitectures Files Project
LanguagesBasic C# C++ Java Pascal Python Web
CategoriesCompare Contents
CostCached

Number of removed classes, compared to the comparison database.

Counts classes defined in the comparison database but not in the current database. See Classes for what counts as a class. Since changes come from a textual diff, a class 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 classes as new or removed.

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

--- classes.cpp (comparison database)
+++ classes.cpp (current)
@@ -1,32 +1,47 @@
 #define TAG_CLASS(Name) \
   class Name {          \
   public:               \
     int tag = 0;        \
   };
 
 TAG_CLASS(Marker)
+TAG_CLASS(Flag)
+
+struct Size {
+  int width;
+  int height;
+};
 
 struct Point {
   int x;
   int y;
-};
-
-union Value {
-  int asInt;
-  float asFloat;
+  int z;
 };
 
 class Shape {
 public:
   virtual double area() const = 0;
 };
 
 class Circle : public Shape {
 public:
   double area() const override;
   double r = 1;
 };
 
 double Circle::area() const {
-  return 3.14 * r * r;
+  return 3.14159 * r * r;
 }
+
+class Square : public Shape {
+public:
+  double area() const override { return side * side; }
+  double side = 1;
+};
+
+union Number {
+  int asInt;
+  double asDouble;
+};
+
+enum class Color { Red, Green };

The union Value was removed, so CountDeclClassRemoved = 1.

See New Classes for the reverse of this metric, Changed Classes for classes in both versions that differ, and Classes 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 class changed.