scitools.com

← Metric catalog

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

Changed Classes

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

Number of changed classes, compared to the comparison database.

Counts classes defined in both databases whose text differs. A class counts once, however many of its lines changed. 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 struct Point has a new member, and Circle::area() has a changed line. A class's lines include the bodies of its member functions, even ones defined outside the class, so Circle counts as changed too. That gives CountDeclClassChanged = 2. Shape and Marker are the same in both versions, so neither counts.

See New Classes and Removed Classes for classes that exist in only one version, 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.