# Global Metrics

path: .metrics.nom.total
old: 0.0
new: 13.0
path: .metrics.nom.functions
old: 0.0
new: 7.0
path: .metrics.nom.closures
old: 0.0
new: 6.0
path: .metrics.cyclomatic.sum
old: 11.0
new: 15.0
path: .metrics.cyclomatic.average
old: 1.0
new: 1.875
path: .metrics.loc.lloc
old: 0.0
new: 30.0
path: .metrics.loc.sloc
old: 45.0
new: 177.0
path: .metrics.loc.cloc
old: 13.0
new: 58.0
path: .metrics.loc.blank
old: 13.0
new: 25.0
path: .metrics.loc.ploc
old: 19.0
new: 94.0
path: .metrics.nexits.average
old: null
new: 1.0769230769230769
path: .metrics.nexits.sum
old: 0.0
new: 14.0
path: .metrics.halstead.n2
old: 16.0
new: 53.0
path: .metrics.halstead.estimated_program_length
old: 68.75488750216347
new: 390.0183459895968
path: .metrics.halstead.purity_ratio
old: 1.8093391447937752
new: 1.1111633788877402
path: .metrics.halstead.length
old: 38.0
new: 351.0
path: .metrics.halstead.volume
old: 161.42124551085624
new: 2172.6284201668864
path: .metrics.halstead.level
old: 0.41025641025641024
new: 0.04015151515151515
path: .metrics.halstead.N1
old: 12.0
new: 219.0
path: .metrics.halstead.difficulty
old: 2.4375
new: 24.90566037735849
path: .metrics.halstead.N2
old: 26.0
new: 132.0
path: .metrics.halstead.time
old: 21.859126996261782
new: 3006.1525310485217
path: .metrics.halstead.bugs
old: 0.01789845829700626
new: 0.4768711955254816
path: .metrics.halstead.vocabulary
old: 19.0
new: 73.0
path: .metrics.halstead.effort
old: 393.4642859327121
new: 54110.745558873394
path: .metrics.halstead.n1
old: 3.0
new: 20.0
path: .metrics.nargs.sum
old: 0.0
new: 14.0
path: .metrics.nargs.average
old: null
new: 1.0769230769230769
path: .metrics.cognitive.average
old: null
new: 0.6923076923076923
path: .metrics.cognitive.sum
old: 0.0
new: 9.0
path: .metrics.mi.mi_sei
old: 78.34802091529889
new: 27.6847698934604
path: .metrics.mi.mi_original
old: 80.36517729060414
new: 43.74117090342614
path: .metrics.mi.mi_visual_studio
old: 46.99717970210768
new: 25.579632107266747

# Spaces Data

## Minimal test - lines (114, 117)

path: .spaces[1].metrics.loc.sloc
old: 1.0
new: 4.0
path: .spaces[1].metrics.loc.ploc
old: 1.0
new: 4.0
path: .spaces[1].metrics.loc.lloc
old: 0.0
new: 2.0
path: .spaces[1].metrics.mi.mi_original
old: null
new: 127.25548032168658
path: .spaces[1].metrics.mi.mi_visual_studio
old: null
new: 74.41840954484594
path: .spaces[1].metrics.mi.mi_sei
old: null
new: 107.991818253432
path: .spaces[1].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[1].metrics.nom.total
old: 0.0
new: 2.0
path: .spaces[1].metrics.nom.closures
old: 0.0
new: 1.0
path: .spaces[1].metrics.nexits.average
old: null
new: 0.5
path: .spaces[1].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[1].metrics.halstead.time
old: 0.0
new: 9.559900001923085
path: .spaces[1].metrics.halstead.difficulty
old: 0.0
new: 3.0
path: .spaces[1].metrics.halstead.estimated_program_length
old: null
new: 31.019550008653873
path: .spaces[1].metrics.halstead.n2
old: 1.0
new: 6.0
path: .spaces[1].metrics.halstead.N1
old: 0.0
new: 10.0
path: .spaces[1].metrics.halstead.n1
old: 0.0
new: 6.0
path: .spaces[1].metrics.halstead.purity_ratio
old: null
new: 1.938721875540867
path: .spaces[1].metrics.halstead.vocabulary
old: 1.0
new: 12.0
path: .spaces[1].metrics.halstead.N2
old: 1.0
new: 6.0
path: .spaces[1].metrics.halstead.bugs
old: 0.0
new: 0.010312468817532576
path: .spaces[1].metrics.halstead.effort
old: 0.0
new: 172.0782000346155
path: .spaces[1].metrics.halstead.volume
old: 0.0
new: 57.3594000115385
path: .spaces[1].metrics.halstead.length
old: 1.0
new: 16.0
path: .spaces[1].metrics.halstead.level
old: null
new: 0.3333333333333333
path: .spaces[1].metrics.cognitive.average
old: null
new: 0.0
path: .spaces[1].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[1].metrics.nargs.average
old: null
new: 1.0

### Code

    TEST(AllocReplacementDeathTest, malloc_check)
    {
      ASSERT_ALLOCATION_HAPPENED([] { return malloc(kAllocAmount); });
    }

## Minimal test - lines (120, 123)

path: .spaces[2].metrics.halstead.bugs
old: 0.0
new: 0.011393141056223216
path: .spaces[2].metrics.halstead.estimated_program_length
old: null
new: 35.161259458730164
path: .spaces[2].metrics.halstead.purity_ratio
old: null
new: 1.9534033032627869
path: .spaces[2].metrics.halstead.time
old: 0.0
new: 11.101319154423278
path: .spaces[2].metrics.halstead.effort
old: 0.0
new: 199.823744779619
path: .spaces[2].metrics.halstead.length
old: 1.0
new: 18.0
path: .spaces[2].metrics.halstead.level
old: null
new: 0.3333333333333333
path: .spaces[2].metrics.halstead.n1
old: 0.0
new: 6.0
path: .spaces[2].metrics.halstead.n2
old: 1.0
new: 7.0
path: .spaces[2].metrics.halstead.N1
old: 0.0
new: 11.0
path: .spaces[2].metrics.halstead.difficulty
old: 0.0
new: 3.0
path: .spaces[2].metrics.halstead.N2
old: 1.0
new: 7.0
path: .spaces[2].metrics.halstead.vocabulary
old: 1.0
new: 13.0
path: .spaces[2].metrics.halstead.volume
old: 0.0
new: 66.60791492653966
path: .spaces[2].metrics.nexits.average
old: null
new: 0.5
path: .spaces[2].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[2].metrics.nargs.average
old: null
new: 1.0
path: .spaces[2].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[2].metrics.cognitive.average
old: null
new: 0.0
path: .spaces[2].metrics.nom.closures
old: 0.0
new: 1.0
path: .spaces[2].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[2].metrics.nom.total
old: 0.0
new: 2.0
path: .spaces[2].metrics.mi.mi_original
old: null
new: 126.47814960108288
path: .spaces[2].metrics.mi.mi_sei
old: null
new: 106.8703670776864
path: .spaces[2].metrics.mi.mi_visual_studio
old: null
new: 73.96383017607187
path: .spaces[2].metrics.loc.ploc
old: 1.0
new: 4.0
path: .spaces[2].metrics.loc.lloc
old: 0.0
new: 2.0
path: .spaces[2].metrics.loc.sloc
old: 1.0
new: 4.0

### Code

    TEST(AllocReplacementDeathTest, calloc_check)
    {
      ASSERT_ALLOCATION_HAPPENED([] { return calloc(1, kAllocAmount); });
    }

## Minimal test - lines (155, 161)

path: .spaces[5].metrics.cyclomatic.sum
old: 5.0
new: 1.0
path: .spaces[5].metrics.nom.total
old: 0.0
new: 2.0
path: .spaces[5].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[5].metrics.nom.closures
old: 0.0
new: 1.0
path: .spaces[5].metrics.halstead.estimated_program_length
old: 17.509775004326936
new: 52.529325012980806
path: .spaces[5].metrics.halstead.effort
old: 63.0
new: 472.32903943337254
path: .spaces[5].metrics.halstead.level
old: 0.6666666666666666
new: 0.225
path: .spaces[5].metrics.halstead.n2
old: 6.0
new: 9.0
path: .spaces[5].metrics.halstead.N2
old: 9.0
new: 10.0
path: .spaces[5].metrics.halstead.purity_ratio
old: 1.2506982145947811
new: 2.0203586543454155
path: .spaces[5].metrics.halstead.volume
old: 42.0
new: 106.27403387250882
path: .spaces[5].metrics.halstead.n1
old: 2.0
new: 8.0
path: .spaces[5].metrics.halstead.N1
old: 5.0
new: 16.0
path: .spaces[5].metrics.halstead.vocabulary
old: 8.0
new: 17.0
path: .spaces[5].metrics.halstead.difficulty
old: 1.5
new: 4.444444444444445
path: .spaces[5].metrics.halstead.length
old: 14.0
new: 26.0
path: .spaces[5].metrics.halstead.bugs
old: 0.0052776320879040755
new: 0.020216618242020028
path: .spaces[5].metrics.halstead.time
old: 3.5
new: 26.24050219074292
path: .spaces[5].metrics.cognitive.average
old: null
new: 0.0
path: .spaces[5].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[5].metrics.nargs.average
old: null
new: 1.0
path: .spaces[5].metrics.mi.mi_sei
old: 99.9335568898677
new: 90.2862945289703
path: .spaces[5].metrics.mi.mi_visual_studio
old: 70.98690911311813
new: 67.24148916475949
path: .spaces[5].metrics.mi.mi_original
old: 121.387614583432
new: 114.98294647173871
path: .spaces[5].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[5].metrics.nexits.average
old: null
new: 0.5
path: .spaces[5].metrics.loc.ploc
old: 6.0
new: 7.0
path: .spaces[5].metrics.loc.sloc
old: 6.0
new: 7.0
path: .spaces[5].metrics.loc.lloc
old: 0.0
new: 2.0

### Code

    TEST(AllocReplacementDeathTest, HeapAlloc_check)
    {
      ASSERT_ALLOCATION_HAPPENED([] {
        HANDLE h = GetProcessHeap();
        return HeapAlloc(h, 0, kAllocAmount);
      });
    }

## Minimal test - lines (126, 129)

path: .spaces[3].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[3].metrics.nargs.average
old: null
new: 1.0
path: .spaces[3].metrics.cognitive.average
old: null
new: 0.0
path: .spaces[3].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[3].metrics.nexits.average
old: null
new: 0.5
path: .spaces[3].metrics.nom.closures
old: 0.0
new: 1.0
path: .spaces[3].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[3].metrics.nom.total
old: 0.0
new: 2.0
path: .spaces[3].metrics.mi.mi_sei
old: null
new: 106.8703670776864
path: .spaces[3].metrics.mi.mi_original
old: null
new: 126.47814960108288
path: .spaces[3].metrics.mi.mi_visual_studio
old: null
new: 73.96383017607187
path: .spaces[3].metrics.halstead.n1
old: 0.0
new: 6.0
path: .spaces[3].metrics.halstead.estimated_program_length
old: null
new: 35.161259458730164
path: .spaces[3].metrics.halstead.level
old: null
new: 0.3333333333333333
path: .spaces[3].metrics.halstead.time
old: 0.0
new: 11.101319154423278
path: .spaces[3].metrics.halstead.difficulty
old: 0.0
new: 3.0
path: .spaces[3].metrics.halstead.purity_ratio
old: null
new: 1.9534033032627869
path: .spaces[3].metrics.halstead.N1
old: 0.0
new: 11.0
path: .spaces[3].metrics.halstead.N2
old: 1.0
new: 7.0
path: .spaces[3].metrics.halstead.bugs
old: 0.0
new: 0.011393141056223216
path: .spaces[3].metrics.halstead.length
old: 1.0
new: 18.0
path: .spaces[3].metrics.halstead.effort
old: 0.0
new: 199.823744779619
path: .spaces[3].metrics.halstead.n2
old: 1.0
new: 7.0
path: .spaces[3].metrics.halstead.vocabulary
old: 1.0
new: 13.0
path: .spaces[3].metrics.halstead.volume
old: 0.0
new: 66.60791492653966
path: .spaces[3].metrics.loc.sloc
old: 1.0
new: 4.0
path: .spaces[3].metrics.loc.ploc
old: 1.0
new: 4.0
path: .spaces[3].metrics.loc.lloc
old: 0.0
new: 2.0

### Code

    TEST(AllocReplacementDeathTest, realloc_check)
    {
      ASSERT_ALLOCATION_HAPPENED([] { return realloc(nullptr, kAllocAmount); });
    }

## Minimal test - lines (133, 143)

path: .spaces[4].metrics.mi.mi_original
old: null
new: 103.3037654332062
path: .spaces[4].metrics.mi.mi_sei
old: null
new: 73.53861782243949
path: .spaces[4].metrics.mi.mi_visual_studio
old: null
new: 60.41155873286912
path: .spaces[4].metrics.nexits.sum
old: 0.0
new: 2.0
path: .spaces[4].metrics.nexits.average
old: null
new: 1.0
path: .spaces[4].metrics.nom.total
old: 0.0
new: 2.0
path: .spaces[4].metrics.nom.closures
old: 0.0
new: 1.0
path: .spaces[4].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[4].metrics.halstead.difficulty
old: 0.0
new: 10.227272727272728
path: .spaces[4].metrics.halstead.n1
old: 0.0
new: 15.0
path: .spaces[4].metrics.halstead.effort
old: 0.0
new: 2403.6339467766943
path: .spaces[4].metrics.halstead.level
old: null
new: 0.09777777777777778
path: .spaces[4].metrics.halstead.purity_ratio
old: null
new: 1.9331421347827609
path: .spaces[4].metrics.halstead.estimated_program_length
old: null
new: 96.65710673913804
path: .spaces[4].metrics.halstead.length
old: 1.0
new: 50.0
path: .spaces[4].metrics.halstead.time
old: 0.0
new: 133.5352192653719
path: .spaces[4].metrics.halstead.vocabulary
old: 1.0
new: 26.0
path: .spaces[4].metrics.halstead.N2
old: 1.0
new: 15.0
path: .spaces[4].metrics.halstead.bugs
old: 0.0
new: 0.059812363581538006
path: .spaces[4].metrics.halstead.volume
old: 0.0
new: 235.0219859070546
path: .spaces[4].metrics.halstead.n2
old: 1.0
new: 11.0
path: .spaces[4].metrics.halstead.N1
old: 0.0
new: 35.0
path: .spaces[4].metrics.nargs.average
old: null
new: 1.0
path: .spaces[4].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[4].metrics.cognitive.average
old: null
new: 1.0
path: .spaces[4].metrics.cognitive.sum
old: 0.0
new: 2.0
path: .spaces[4].metrics.loc.sloc
old: 1.0
new: 11.0
path: .spaces[4].metrics.loc.ploc
old: 1.0
new: 11.0
path: .spaces[4].metrics.loc.lloc
old: 0.0
new: 4.0
path: .spaces[4].metrics.cyclomatic.sum
old: 1.0
new: 2.0
path: .spaces[4].metrics.cyclomatic.average
old: 1.0
new: 2.0

### Code

    TEST(AllocReplacementDeathTest, posix_memalign_check)
    {
      ASSERT_ALLOCATION_HAPPENED([] {
        void* p = nullptr;
        int result = posix_memalign(&p, sizeof(void*), kAllocAmount);
        if (result != 0) {
          return static_cast(nullptr);
        }
        return p;
      });
    }

## Minimal test - lines (60, 104)

path: .spaces[0].metrics.halstead.level
old: null
new: 0.044117647058823525
path: .spaces[0].metrics.halstead.n2
old: 1.0
new: 18.0
path: .spaces[0].metrics.halstead.effort
old: 0.0
new: 16044.397277003854
path: .spaces[0].metrics.halstead.difficulty
old: 0.0
new: 22.666666666666668
path: .spaces[0].metrics.halstead.purity_ratio
old: null
new: 1.047431292226213
path: .spaces[0].metrics.halstead.time
old: 0.0
new: 891.355404277992
path: .spaces[0].metrics.halstead.N1
old: 0.0
new: 90.0
path: .spaces[0].metrics.halstead.volume
old: 0.0
new: 707.8410563384053
path: .spaces[0].metrics.halstead.bugs
old: 0.0
new: 0.21204482765725424
path: .spaces[0].metrics.halstead.N2
old: 1.0
new: 48.0
path: .spaces[0].metrics.halstead.n1
old: 0.0
new: 17.0
path: .spaces[0].metrics.halstead.length
old: 1.0
new: 138.0
path: .spaces[0].metrics.halstead.vocabulary
old: 1.0
new: 35.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: null
new: 144.5455183272174
path: .spaces[0].metrics.nom.total
old: 0.0
new: 1.0
path: .spaces[0].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 6.0
path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 6.0
path: .spaces[0].metrics.loc.sloc
old: 1.0
new: 45.0
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 9.0
path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 5.0
path: .spaces[0].metrics.loc.lloc
old: 0.0
new: 14.0
path: .spaces[0].metrics.loc.ploc
old: 1.0
new: 31.0
path: .spaces[0].metrics.mi.mi_sei
old: null
new: 56.10965758587149
path: .spaces[0].metrics.mi.mi_original
old: null
new: 73.82852589239518
path: .spaces[0].metrics.mi.mi_visual_studio
old: null
new: 43.17457654526034
path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 6.0
path: .spaces[0].metrics.nexits.average
old: null
new: 6.0
path: .spaces[0].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[0].metrics.nargs.average
old: null
new: 2.0
path: .spaces[0].metrics.cognitive.average
old: null
new: 5.0
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 5.0

### Code

    static MOZ_NEVER_INLINE bool ValidateHookedAllocation(
        void* (*aAllocator)(void), void (*aFreeFunction)(void*)) {
      nsCOMPtr manager =
          do_GetService("@mozilla.org/memory-reporter-manager;1");

      int64_t before = 0;
      nsresult rv = manager->GetHeapAllocated(&before);
      if (NS_FAILED(rv)) {
        return false;
      }

      {
        void* p = aAllocator();

        if (!p) {
          return false;
        }

        int64_t after = 0;
        rv = manager->GetHeapAllocated(&after);

        // Regardless of whether that call succeeded or failed, we are done with
        // the allocated buffer now.
        aFreeFunction(p);

        if (NS_FAILED(rv)) {
          return false;
        }

        // Verify that our heap stats have changed.
        if ((before + int64_t(kAllocAmount)) != after) {
          return false;
        }
      }

      // Verify that freeing the allocated pointer resets our heap to what it
      // was before.
      int64_t after = 0;
      rv = manager->GetHeapAllocated(&after);
      if (NS_FAILED(rv)) {
        return false;
      }

      return before == after;
    }