Coupled Classes (Batch) 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.
Coupled Classes (Batch)
API ID: CountClassCoupledBatchLanguages: C, C++
Targets: Classes
A version of C++ Coupled Classes for batch export
Is your metrics export taking a long time? If you're using a C++ project with lots of classes, then CountClassCoupled is likely the problem. All built-in class metrics are calculated on demand, and CountClassCoupled is the slowest of them.
This plugin calculates the value for every class in the project and then returns the cached values. So, it's a longer wait for the first value, but substantially faster for subsequent values. It's designed to improve batch export speed.
Note that the optimizations for batch speed can result in different values from the built-in metric for these cases:
- If there is more than one member function with the exact same long
name. For example:
In this case, the CountClassCoupled metric for the class A entities may be 2 and 0 instead of 1 and 1 because both of the definitions of A::foo() may get attributed to the same class A entity.
// file1.h class A { void foo(); }; // file1.cpp void A::foo() {...} // coupled to class B // file2.h class A { void foo(); }; // file2.cpp void A::foo() {...} // coupled to class C
- If there are same-named type aliases with different definitions.
For example:
using same_name = ...
See also the Coupled Classes Metric interactive report to see which classes were coupled.