scitools.com

← Metric catalog

Unique Sets 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.

Unique Sets

API IDCountSetsUnique
TargetsObjects
LanguagesAny
CategoriesCoupling
CostQuery

The number of unique entities that set this object

Example:

    int a_global = 0;      // + 1 set reference (by file)
    void function1() {
      a_global += 1;
      if (a_global > 1)
        a_global = 0;      // + 1 set reference (by function1)
    }
    void function2() {
      a_global -= 1;
      a_global -= 1;
      if (a_global < 0)
        a_global = 0;      // + 1 set reference (by function2)
      if (a_global > 10)
        a_global = 10;     //     duplicate reference does not count
    }
                           // CountSetsUnique = 3
    

Compare to CountSets which counts all sets.