scitools.com

← Metric catalog

Use to Sets/Modify Ratio 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.

Use to Sets/Modify Ratio

API ID: RatioUseToSetModify
Languages: Any
Targets: Objects

The ratio of object uses to object sets and modifications

Example:

    void ratio(int x, int y)
    {
      x += 1;       // + 1 modify
      if (x == 1);  // + 1 use
      if (x == 2);  // + 1 use
      if (x == 3);  // + 1 use
                    // for x: 3 uses to 1 set/modify, RatioUseToSetModify = 3 / 1 = 3

      y = 1;        // + 1 set
      y += 2;       // + 1 modify
      if (y == 10); // + 1 use
                    // for y: 1 use to 2 set/modify,  RatioUseToSetModify = 1 / 2 = 0.5
    }
    

Compare to RatioSetModifyToUse for the opposite direction.