# Global Metrics

path: .metrics.nexits.average
old: 0.9333333333333332
new: 1.4
path: .metrics.nexits.sum
old: 28.0
new: 7.0
path: .metrics.loc.lloc
old: 111.0
new: 57.0
path: .metrics.loc.cloc
old: 51.0
new: 8.0
path: .metrics.loc.blank
old: 43.0
new: 8.0
path: .metrics.loc.ploc
old: 304.0
new: 103.0
path: .metrics.loc.sloc
old: 398.0
new: 119.0
path: .metrics.cognitive.average
old: 1.8333333333333333
new: 6.0
path: .metrics.cognitive.sum
old: 55.0
new: 30.0
path: .metrics.mi.mi_sei
old: -27.88553584291433
new: 14.016892949531336
path: .metrics.mi.mi_original
old: 9.81204407420502
new: 47.15577312815512
path: .metrics.mi.mi_visual_studio
old: 5.738037470295333
new: 27.576475513541
path: .metrics.cyclomatic.average
old: 2.25
new: 3.5
path: .metrics.cyclomatic.sum
old: 72.0
new: 21.0
path: .metrics.nom.total
old: 30.0
new: 5.0
path: .metrics.nom.functions
old: 30.0
new: 5.0
path: .metrics.nargs.sum
old: 43.0
new: 9.0
path: .metrics.nargs.average
old: 1.4333333333333331
new: 1.8
path: .metrics.halstead.difficulty
old: 84.94
new: 38.2
path: .metrics.halstead.n1
old: 31.0
new: 28.0
path: .metrics.halstead.length
old: 1356.0
new: 450.0
path: .metrics.halstead.volume
old: 9537.321590084784
new: 2976.619429851844
path: .metrics.halstead.effort
old: 810100.0958618014
new: 113706.86222034044
path: .metrics.halstead.estimated_program_length
old: 817.9657045994655
new: 563.6557490037605
path: .metrics.halstead.vocabulary
old: 131.0
new: 98.0
path: .metrics.halstead.level
old: 0.01177301624676242
new: 0.026178010471204185
path: .metrics.halstead.N1
old: 808.0
new: 259.0
path: .metrics.halstead.N2
old: 548.0
new: 191.0
path: .metrics.halstead.bugs
old: 2.896706769870486
new: 0.78235379833623
path: .metrics.halstead.time
old: 45005.56088121119
new: 6317.047901130025
path: .metrics.halstead.n2
old: 100.0
new: 70.0
path: .metrics.halstead.purity_ratio
old: 0.6032195461647976
new: 1.252568331119468

# Spaces Data

## Minimal test - lines (55, 96)

path: .spaces[3].metrics.nexits.average
old: 2.0
new: 1.0
path: .spaces[3].metrics.nexits.sum
old: 2.0
new: 1.0
path: .spaces[3].metrics.halstead.volume
old: 442.6092671887795
new: 1094.9081008162966
path: .spaces[3].metrics.halstead.estimated_program_length
old: 139.3139816895559
new: 232.42388754772497
path: .spaces[3].metrics.halstead.purity_ratio
old: 1.6013101343627114
new: 1.1980612760192006
path: .spaces[3].metrics.halstead.n2
old: 19.0
new: 27.0
path: .spaces[3].metrics.halstead.N1
old: 52.0
new: 117.0
path: .spaces[3].metrics.halstead.difficulty
old: 13.81578947368421
new: 32.7962962962963
path: .spaces[3].metrics.halstead.effort
old: 6114.996454581822
new: 35908.930491586325
path: .spaces[3].metrics.halstead.level
old: 0.07238095238095238
new: 0.03049124788255223
path: .spaces[3].metrics.halstead.vocabulary
old: 34.0
new: 50.0
path: .spaces[3].metrics.halstead.n1
old: 15.0
new: 23.0
path: .spaces[3].metrics.halstead.time
old: 339.72202525454566
new: 1994.940582865907
path: .spaces[3].metrics.halstead.bugs
old: 0.11146612022235804
new: 0.3628109551262621
path: .spaces[3].metrics.halstead.length
old: 87.0
new: 194.0
path: .spaces[3].metrics.halstead.N2
old: 35.0
new: 77.0
path: .spaces[3].metrics.mi.mi_visual_studio
old: 53.959046506356
new: 42.23271256060558
path: .spaces[3].metrics.mi.mi_original
old: 92.26996952586876
new: 72.21793847863555
path: .spaces[3].metrics.mi.mi_sei
old: 57.92567476295622
new: 29.302168589574705
path: .spaces[3].metrics.cognitive.average
old: 7.0
new: 25.0
path: .spaces[3].metrics.cognitive.sum
old: 7.0
new: 25.0
path: .spaces[3].metrics.nargs.average
old: 0.0
new: 3.0
path: .spaces[3].metrics.nargs.sum
old: 0.0
new: 3.0
path: .spaces[3].metrics.cyclomatic.sum
old: 5.0
new: 8.0
path: .spaces[3].metrics.cyclomatic.average
old: 5.0
new: 8.0
path: .spaces[3].metrics.loc.sloc
old: 17.0
new: 42.0
path: .spaces[3].metrics.loc.lloc
old: 9.0
new: 25.0
path: .spaces[3].metrics.loc.ploc
old: 16.0
new: 41.0

### Code

    int ProcessArgs(nsIComponentRegistrar* registrar, int argc, char* argv[]) {
      int i = 1;
      nsresult res;

      while (i < argc) {
        if (argv[i][0] == '-') {
          int j;
          for (j = 1; argv[i][j] != '\0'; j++) {
            switch (argv[i][j]) {
              case 'u':
                gUnreg = true;
                break;
              default:
                cerr << "Unknown option '" << argv[i][j] << "'\n";
            }
          }
          i++;
        } else {
          if (gUnreg) {
            res = Unregister(argv[i]);
            if (NS_SUCCEEDED(res)) {
              cout << "Successfully unregistered: " << argv[i] << "\n";
            } else {
              cerr << "Unregister failed (";
              print_err(res);
              cerr << "): " << argv[i] << "\n";
            }
          } else {
            res = Register(registrar, argv[i]);
            if (NS_SUCCEEDED(res)) {
              cout << "Successfully registered: " << argv[i] << "\n";
            } else {
              cerr << "Register failed (";
              print_err(res);
              cerr << "): " << argv[i] << "\n";
            }
          }
          i++;
        }
      }
      return 0;
    }

## Minimal test - lines (17, 34)

path: .spaces[0].metrics.halstead.bugs
old: 0.010405072229378904
new: 0.0499431501086805
path: .spaces[0].metrics.halstead.length
old: 14.0
new: 56.0
path: .spaces[0].metrics.halstead.n2
old: 4.0
new: 14.0
path: .spaces[0].metrics.halstead.level
old: 0.26666666666666666
new: 0.14
path: .spaces[0].metrics.halstead.vocabulary
old: 10.0
new: 24.0
path: .spaces[0].metrics.halstead.N1
old: 9.0
new: 36.0
path: .spaces[0].metrics.halstead.N2
old: 5.0
new: 20.0
path: .spaces[0].metrics.halstead.n1
old: 6.0
new: 10.0
path: .spaces[0].metrics.halstead.volume
old: 46.50699332842307
new: 256.75790004038475
path: .spaces[0].metrics.halstead.time
old: 9.688956943421474
new: 101.88805557158126
path: .spaces[0].metrics.halstead.difficulty
old: 3.75
new: 7.142857142857143
path: .spaces[0].metrics.halstead.effort
old: 174.40122498158652
new: 1833.9850002884627
path: .spaces[0].metrics.halstead.estimated_program_length
old: 23.509775004326936
new: 86.52224985768008
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.6792696431662095
new: 1.5450401760300014
path: .spaces[0].metrics.loc.ploc
old: 3.0
new: 18.0
path: .spaces[0].metrics.loc.lloc
old: 0.0
new: 15.0
path: .spaces[0].metrics.loc.sloc
old: 3.0
new: 18.0
path: .spaces[0].metrics.nargs.average
old: 0.0
new: 1.0
path: .spaces[0].metrics.nargs.sum
old: 0.0
new: 1.0
path: .spaces[0].metrics.cognitive.average
old: 0.0
new: 1.0
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 1.0
path: .spaces[0].metrics.mi.mi_original
old: 133.00654690726324
new: 94.17568270992064
path: .spaces[0].metrics.mi.mi_sei
old: 116.28885349626572
new: 60.67503772294458
path: .spaces[0].metrics.mi.mi_visual_studio
old: 77.78160637851651
new: 55.07349866077232
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 5.0
path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 5.0

### Code

    void print_err(nsresult err) {
      switch (err) {
        case NS_ERROR_FACTORY_NOT_LOADED:
          cerr << "Factory not loaded";
          break;
        case NS_NOINTERFACE:
          cerr << "No Interface";
          break;
        case NS_ERROR_NULL_POINTER:
          cerr << "Null pointer";
          break;
        case NS_ERROR_OUT_OF_MEMORY:
          cerr << "Out of memory";
          break;
        default:
          cerr << hex << err << dec;
      }
    }

## Minimal test - lines (98, 119)

path: .spaces[4].metrics.mi.mi_sei
old: 67.8461944269225
new: 76.62186928561928
path: .spaces[4].metrics.mi.mi_visual_studio
old: 58.0215940988934
new: 50.60640932920641
path: .spaces[4].metrics.mi.mi_original
old: 99.21692590910772
new: 86.53695995294296
path: .spaces[4].metrics.nargs.average
old: 0.0
new: 2.0
path: .spaces[4].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[4].metrics.cognitive.average
old: 4.0
new: 3.0
path: .spaces[4].metrics.cognitive.sum
old: 4.0
new: 3.0
path: .spaces[4].metrics.loc.lloc
old: 6.0
new: 11.0
path: .spaces[4].metrics.loc.blank
old: 1.0
new: 0.0
path: .spaces[4].metrics.loc.ploc
old: 12.0
new: 19.0
path: .spaces[4].metrics.loc.sloc
old: 13.0
new: 22.0
path: .spaces[4].metrics.loc.cloc
old: 0.0
new: 3.0
path: .spaces[4].metrics.halstead.n2
old: 13.0
new: 26.0
path: .spaces[4].metrics.halstead.purity_ratio
old: 1.7187912753328924
new: 1.666941747590645
path: .spaces[4].metrics.halstead.effort
old: 3474.3597217731376
new: 10404.34091091486
path: .spaces[4].metrics.halstead.estimated_program_length
old: 101.40868524464064
new: 191.69830097292416
path: .spaces[4].metrics.halstead.N1
old: 36.0
new: 64.0
path: .spaces[4].metrics.halstead.vocabulary
old: 27.0
new: 43.0
path: .spaces[4].metrics.halstead.n1
old: 14.0
new: 17.0
path: .spaces[4].metrics.halstead.volume
old: 280.53836262764463
new: 624.0204467907413
path: .spaces[4].metrics.halstead.time
old: 193.0199845429521
new: 578.0189394952699
path: .spaces[4].metrics.halstead.difficulty
old: 12.384615384615383
new: 16.673076923076923
path: .spaces[4].metrics.halstead.bugs
old: 0.07646486621658721
new: 0.1588626470019057
path: .spaces[4].metrics.halstead.length
old: 59.0
new: 115.0
path: .spaces[4].metrics.halstead.N2
old: 23.0
new: 51.0
path: .spaces[4].metrics.halstead.level
old: 0.08074534161490683
new: 0.05997693194925029

### Code

    int main(int argc, char* argv[]) {
      int ret = 0;
      nsresult rv;
      {
        nsCOMPtr servMan;
        rv = NS_InitXPCOM(getter_AddRefs(servMan), nullptr, nullptr);
        if (NS_FAILED(rv)) return -1;
        nsCOMPtr registrar = do_QueryInterface(servMan);
        NS_ASSERTION(registrar, "Null nsIComponentRegistrar");

        /* With no arguments, RegFactory will autoregister */
        if (argc <= 1) {
          rv = registrar->AutoRegister(nullptr);
          ret = (NS_FAILED(rv)) ? -1 : 0;
        } else
          ret = ProcessArgs(registrar, argc, argv);
      }  // this scopes the nsCOMPtrs
      // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
      rv = NS_ShutdownXPCOM(nullptr);
      NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
      return ret;
    }

## Minimal test - lines (45, 53)

path: .spaces[2].metrics.loc.sloc
old: 4.0
new: 9.0
path: .spaces[2].metrics.loc.ploc
old: 4.0
new: 8.0
path: .spaces[2].metrics.loc.cloc
old: 0.0
new: 1.0
path: .spaces[2].metrics.loc.lloc
old: 1.0
new: 2.0
path: .spaces[2].metrics.nargs.sum
old: 0.0
new: 1.0
path: .spaces[2].metrics.nargs.average
old: 0.0
new: 1.0
path: .spaces[2].metrics.nexits.average
old: 1.0
new: 2.0
path: .spaces[2].metrics.nexits.sum
old: 1.0
new: 2.0
path: .spaces[2].metrics.halstead.estimated_program_length
old: 20.264662506490403
new: 43.65148445440323
path: .spaces[2].metrics.halstead.N1
old: 6.0
new: 12.0
path: .spaces[2].metrics.halstead.N2
old: 3.0
new: 10.0
path: .spaces[2].metrics.halstead.time
old: 4.754887502163468
new: 27.2862200328214
path: .spaces[2].metrics.halstead.vocabulary
old: 9.0
new: 15.0
path: .spaces[2].metrics.halstead.difficulty
old: 3.0
new: 5.714285714285714
path: .spaces[2].metrics.halstead.volume
old: 28.52932501298081
new: 85.95159310338741
path: .spaces[2].metrics.halstead.level
old: 0.3333333333333333
new: 0.175
path: .spaces[2].metrics.halstead.n2
old: 3.0
new: 7.0
path: .spaces[2].metrics.halstead.bugs
old: 0.006473720020679235
new: 0.02075021813804995
path: .spaces[2].metrics.halstead.effort
old: 85.58797503894243
new: 491.1519605907852
path: .spaces[2].metrics.halstead.n1
old: 6.0
new: 8.0
path: .spaces[2].metrics.halstead.purity_ratio
old: 2.2516291673878226
new: 1.984158384291056
path: .spaces[2].metrics.halstead.length
old: 9.0
new: 22.0
path: .spaces[2].metrics.mi.mi_sei
old: 113.23125671373975
new: 110.69240434681704
path: .spaces[2].metrics.mi.mi_original
old: 130.88718231816625
new: 112.01528365931811
path: .spaces[2].metrics.mi.mi_visual_studio
old: 76.54221188196857
new: 65.50601383585855

### Code

    nsresult Unregister(const char* path) {
      /* NEEDS IMPLEMENTATION */
    #if 0
        nsresult res = nsComponentManager::AutoUnregisterComponent(path);
      return res;
    #else
      return NS_ERROR_FAILURE;
    #endif
    }

## Minimal test - lines (36, 43)

path: .spaces[1].metrics.mi.mi_visual_studio
old: 71.41641784747793
new: 63.333247919833035
path: .spaces[1].metrics.mi.mi_original
old: 122.12207451918728
new: 108.2998539429145
path: .spaces[1].metrics.mi.mi_sei
old: 100.78951887810452
new: 80.74644993923798
path: .spaces[1].metrics.nargs.average
old: 0.0
new: 2.0
path: .spaces[1].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[1].metrics.cyclomatic.average
old: 3.0
new: 2.0
path: .spaces[1].metrics.cyclomatic.sum
old: 3.0
new: 2.0
path: .spaces[1].metrics.loc.ploc
old: 5.0
new: 8.0
path: .spaces[1].metrics.loc.sloc
old: 5.0
new: 8.0
path: .spaces[1].metrics.loc.lloc
old: 2.0
new: 4.0
path: .spaces[1].metrics.cognitive.average
old: 2.0
new: 1.0
path: .spaces[1].metrics.cognitive.sum
old: 2.0
new: 1.0
path: .spaces[1].metrics.halstead.vocabulary
old: 13.0
new: 27.0
path: .spaces[1].metrics.halstead.effort
old: 393.72678601021215
new: 2327.992921059234
path: .spaces[1].metrics.halstead.level
old: 0.17857142857142858
new: 0.10416666666666669
path: .spaces[1].metrics.halstead.volume
old: 70.30835464468075
new: 242.49926261033687
path: .spaces[1].metrics.halstead.purity_ratio
old: 1.8741916039177269
new: 1.9926060577016012
path: .spaces[1].metrics.halstead.estimated_program_length
old: 35.60964047443681
new: 101.62290894278166
path: .spaces[1].metrics.halstead.length
old: 19.0
new: 51.0
path: .spaces[1].metrics.halstead.n1
old: 8.0
new: 12.0
path: .spaces[1].metrics.halstead.time
old: 21.873710333900675
new: 129.33294005884633
path: .spaces[1].metrics.halstead.difficulty
old: 5.6
new: 9.6
path: .spaces[1].metrics.halstead.N1
old: 12.0
new: 27.0
path: .spaces[1].metrics.halstead.n2
old: 5.0
new: 15.0
path: .spaces[1].metrics.halstead.N2
old: 7.0
new: 24.0
path: .spaces[1].metrics.halstead.bugs
old: 0.01790641806124263
new: 0.05855084702933662
path: .spaces[1].metrics.nexits.sum
old: 0.0
new: 2.0
path: .spaces[1].metrics.nexits.average
old: 0.0
new: 2.0

### Code

    nsresult Register(nsIComponentRegistrar* registrar, const char* path) {
      nsCOMPtr file;
      nsresult rv =
          NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), true, getter_AddRefs(file));
      if (NS_FAILED(rv)) return rv;
      rv = registrar->AutoRegister(file);
      return rv;
    }