Global Metrics
path: .metrics.loc.cloc
old: 108.0
new: 27.0
path: .metrics.loc.blank
old: 88.0
new: 24.0
path: .metrics.loc.ploc
old: 746.0
new: 113.0
path: .metrics.loc.lloc
old: 163.0
new: 42.0
path: .metrics.loc.sloc
old: 942.0
new: 164.0
path: .metrics.cognitive.average
old: 5.25
new: 3.5
path: .metrics.cognitive.sum
old: 105.0
new: 14.0
path: .metrics.nom.functions
old: 20.0
new: 4.0
path: .metrics.nom.total
old: 20.0
new: 4.0
path: .metrics.halstead.bugs
old: 23.10923456423668
new: 0.7224453812545265
path: .metrics.halstead.length
old: 9973.0
new: 448.0
path: .metrics.halstead.level
old: 0.004648176323613573
new: 0.03016759776536313
path: .metrics.halstead.purity_ratio
old: 0.29518831664060197
new: 1.4748539466560493
path: .metrics.halstead.difficulty
old: 215.13813813813815
new: 33.148148148148145
path: .metrics.halstead.effort
old: 18254091.505878825
new: 100899.59206561992
path: .metrics.halstead.n2
old: 333.0
new: 81.0
path: .metrics.halstead.time
old: 1014116.1947710458
new: 5605.53289253444
path: .metrics.halstead.N1
old: 5351.0
new: 269.0
path: .metrics.halstead.volume
old: 84848.23594670159
new: 3043.8983081248475
path: .metrics.halstead.n1
old: 31.0
new: 30.0
path: .metrics.halstead.N2
old: 4622.0
new: 179.0
path: .metrics.halstead.vocabulary
old: 364.0
new: 111.0
path: .metrics.halstead.estimated_program_length
old: 2943.9130818567232
new: 660.7345681019101
path: .metrics.nargs.sum
old: 207.0
new: 2.0
path: .metrics.nargs.average
old: 10.35
new: 0.5
path: .metrics.cyclomatic.average
old: 3.5714285714285716
new: 3.8
path: .metrics.cyclomatic.sum
old: 75.0
new: 19.0
path: .metrics.mi.mi_sei
old: -66.39530586531004
new: 16.664926536891855
path: .metrics.mi.mi_original
old: -16.200506745121686
new: 42.303513451497736
path: .metrics.mi.mi_visual_studio
old: 0.0
new: 24.73889675526183
path: .metrics.nexits.sum
old: 0.0
new: 8.0
path: .metrics.nexits.average
old: 0.0
new: 2.0
Spaces Data
Minimal test - lines (27, 27)
path: .spaces[0].metrics.loc.cloc
old: 13.0
new: 0.0
path: .spaces[0].metrics.loc.sloc
old: 41.0
new: 1.0
path: .spaces[0].metrics.loc.ploc
old: 26.0
new: 1.0
path: .spaces[0].metrics.loc.blank
old: 2.0
new: 0.0
path: .spaces[0].metrics.loc.lloc
old: 1.0
new: 0.0
path: .spaces[0].metrics.nargs.average
old: 6.0
new: 0.0
path: .spaces[0].metrics.nargs.sum
old: 6.0
new: 0.0
path: .spaces[0].metrics.mi.mi_sei
old: 68.88515497410243
new: 147.42610035996177
path: .spaces[0].metrics.mi.mi_original
old: 73.6069815524406
new: 154.58924178123317
path: .spaces[0].metrics.mi.mi_visual_studio
old: 43.04501845171965
new: 90.4030653691422
path: .spaces[0].metrics.halstead.n2
old: 42.0
new: 3.0
path: .spaces[0].metrics.halstead.N1
old: 103.0
new: 5.0
path: .spaces[0].metrics.halstead.bugs
old: 0.22946862774480312
new: 0.00421201861424495
path: .spaces[0].metrics.halstead.difficulty
old: 14.666666666666666
new: 2.0
path: .spaces[0].metrics.halstead.time
old: 1003.4468055586642
new: 2.495426597384537
path: .spaces[0].metrics.halstead.volume
old: 1231.5028977310878
new: 22.458839376460833
path: .spaces[0].metrics.halstead.N2
old: 112.0
new: 3.0
path: .spaces[0].metrics.halstead.length
old: 215.0
new: 8.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 264.53107956171823
new: 12.754887502163468
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.23037711424055
new: 1.5943609377704335
path: .spaces[0].metrics.halstead.n1
old: 11.0
new: 4.0
path: .spaces[0].metrics.halstead.vocabulary
old: 53.0
new: 7.0
path: .spaces[0].metrics.halstead.level
old: 0.06818181818181819
new: 0.5
path: .spaces[0].metrics.halstead.effort
old: 18062.042500055955
new: 44.91767875292167
Code
nsUUIDGenerator::nsUUIDGenerator() : mLock("nsUUIDGenerator.mLock") {}
Minimal test - lines (92, 164)
path: .spaces[3].metrics.nexits.average
old: 0.0
new: 3.0
path: .spaces[3].metrics.nexits.sum
old: 0.0
new: 3.0
path: .spaces[3].metrics.loc.lloc
old: 2.0
new: 19.0
path: .spaces[3].metrics.loc.ploc
old: 8.0
new: 52.0
path: .spaces[3].metrics.loc.cloc
old: 0.0
new: 14.0
path: .spaces[3].metrics.loc.sloc
old: 8.0
new: 73.0
path: .spaces[3].metrics.loc.blank
old: 0.0
new: 7.0
path: .spaces[3].metrics.cyclomatic.sum
old: 1.0
new: 6.0
path: .spaces[3].metrics.cyclomatic.average
old: 1.0
new: 6.0
path: .spaces[3].metrics.mi.mi_original
old: 108.66341821996988
new: 62.47841867424482
path: .spaces[3].metrics.mi.mi_visual_studio
old: 63.54585860816952
new: 36.53708694400282
path: .spaces[3].metrics.mi.mi_sei
old: 81.16914245938571
new: 46.426137409220665
path: .spaces[3].metrics.cognitive.sum
old: 0.0
new: 5.0
path: .spaces[3].metrics.cognitive.average
old: 0.0
new: 5.0
path: .spaces[3].metrics.nargs.average
old: 7.0
new: 1.0
path: .spaces[3].metrics.nargs.sum
old: 7.0
new: 1.0
path: .spaces[3].metrics.halstead.vocabulary
old: 22.0
new: 74.0
path: .spaces[3].metrics.halstead.volume
old: 236.34987578777677
new: 1390.9175539008847
path: .spaces[3].metrics.halstead.difficulty
old: 6.066666666666666
new: 26.71276595744681
path: .spaces[3].metrics.halstead.length
old: 53.0
new: 224.0
path: .spaces[3].metrics.halstead.n2
old: 15.0
new: 47.0
path: .spaces[3].metrics.halstead.purity_ratio
old: 1.476506479028887
new: 1.7386055294074223
path: .spaces[3].metrics.halstead.n1
old: 7.0
new: 27.0
path: .spaces[3].metrics.halstead.estimated_program_length
old: 78.25484338853101
new: 389.4476385872626
path: .spaces[3].metrics.halstead.time
old: 79.65866183958401
new: 2064.18083796993
path: .spaces[3].metrics.halstead.N2
old: 26.0
new: 93.0
path: .spaces[3].metrics.halstead.bugs
old: 0.04238534798277174
new: 0.3711580720083247
path: .spaces[3].metrics.halstead.level
old: 0.16483516483516483
new: 0.037435284747112704
path: .spaces[3].metrics.halstead.effort
old: 1433.8559131125123
new: 37155.25508345874
path: .spaces[3].metrics.halstead.N1
old: 27.0
new: 131.0
Code
nsUUIDGenerator::GenerateUUIDInPlace(nsID* aId) {
// The various code in this method is probably not threadsafe, so lock
// across the whole method.
MutexAutoLock lock(mLock);
#if defined(XP_WIN)
HRESULT hr = CoCreateGuid((GUID*)aId);
if (FAILED(hr)) {
return NS_ERROR_FAILURE;
}
#elif defined(XP_MACOSX)
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
if (!uuid) {
return NS_ERROR_FAILURE;
}
CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuid);
memcpy(aId, &bytes, sizeof(nsID));
CFRelease(uuid);
#else /* not windows or OS X; generate randomness using random(). */
/* XXX we should be saving the return of setstate here and switching
* back to it; instead, we use the value returned when we called
* initstate, since older glibc's have broken setstate() return values
*/
# ifndef HAVE_ARC4RANDOM
setstate(mState);
# endif
# ifdef HAVE_ARC4RANDOM_BUF
arc4random_buf(aId, sizeof(nsID));
# else /* HAVE_ARC4RANDOM_BUF */
size_t bytesLeft = sizeof(nsID);
while (bytesLeft > 0) {
# ifdef HAVE_ARC4RANDOM
long rval = arc4random();
const size_t mRBytes = 4;
# else
long rval = random();
# endif
uint8_t* src = (uint8_t*)&rval;
// We want to grab the mRBytes least significant bytes of rval, since
// mRBytes less than sizeof(rval) means the high bytes are 0.
# ifdef IS_BIG_ENDIAN
src += sizeof(rval) - mRBytes;
# endif
uint8_t* dst = ((uint8_t*)aId) + (sizeof(nsID) - bytesLeft);
size_t toWrite = (bytesLeft < mRBytes ? bytesLeft : mRBytes);
for (size_t i = 0; i < toWrite; i++) {
dst[i] = src[i];
}
bytesLeft -= toWrite;
}
# endif /* HAVE_ARC4RANDOM_BUF */
/* Put in the version */
aId->m2 &= 0x0fff;
aId->m2 |= 0x4000;
/* Put in the variant */
aId->m3[0] &= 0x3f;
aId->m3[0] |= 0x80;
# ifndef HAVE_ARC4RANDOM
/* Restore the previous RNG state */
setstate(mSavedState);
# endif
#endif
return NS_OK;
}
Minimal test - lines (31, 75)
path: .spaces[1].metrics.nexits.sum
old: 0.0
new: 3.0
path: .spaces[1].metrics.nexits.average
old: 0.0
new: 3.0
path: .spaces[1].metrics.mi.mi_sei
old: 61.74955004761341
new: 60.89644601781448
path: .spaces[1].metrics.mi.mi_visual_studio
old: 40.928362665490795
new: 42.68104000646974
path: .spaces[1].metrics.mi.mi_original
old: 69.98750015798926
new: 72.98457841106325
path: .spaces[1].metrics.cognitive.sum
old: 0.0
new: 8.0
path: .spaces[1].metrics.cognitive.average
old: 0.0
new: 8.0
path: .spaces[1].metrics.loc.blank
old: 3.0
new: 5.0
path: .spaces[1].metrics.loc.cloc
old: 13.0
new: 8.0
path: .spaces[1].metrics.loc.ploc
old: 31.0
new: 32.0
path: .spaces[1].metrics.loc.lloc
old: 4.0
new: 16.0
path: .spaces[1].metrics.loc.sloc
old: 47.0
new: 45.0
path: .spaces[1].metrics.halstead.vocabulary
old: 50.0
new: 46.0
path: .spaces[1].metrics.halstead.n2
old: 39.0
new: 26.0
path: .spaces[1].metrics.halstead.level
old: 0.05101373446697187
new: 0.055319148936170216
path: .spaces[1].metrics.halstead.volume
old: 1614.142870275571
new: 729.1101781995258
path: .spaces[1].metrics.halstead.effort
old: 31641.339085273696
new: 13180.068605914505
path: .spaces[1].metrics.halstead.time
old: 1757.8521714040942
new: 732.226033661917
path: .spaces[1].metrics.halstead.estimated_program_length
old: 244.18443434063795
new: 208.64999456941564
path: .spaces[1].metrics.halstead.N2
old: 139.0
new: 47.0
path: .spaces[1].metrics.halstead.n1
old: 11.0
new: 20.0
path: .spaces[1].metrics.halstead.bugs
old: 0.33346376441312875
new: 0.18599039889997843
path: .spaces[1].metrics.halstead.difficulty
old: 19.602564102564106
new: 18.076923076923077
path: .spaces[1].metrics.halstead.N1
old: 147.0
new: 85.0
path: .spaces[1].metrics.halstead.purity_ratio
old: 0.853791728463769
new: 1.5806817770410275
path: .spaces[1].metrics.halstead.length
old: 286.0
new: 132.0
path: .spaces[1].metrics.nargs.average
old: 3.0
new: 0.0
path: .spaces[1].metrics.nargs.sum
old: 3.0
new: 0.0
path: .spaces[1].metrics.cyclomatic.sum
old: 1.0
new: 9.0
path: .spaces[1].metrics.cyclomatic.average
old: 1.0
new: 9.0
Code
nsresult nsUUIDGenerator::Init() {
// We're a service, so we're guaranteed that Init() is not going
// to be reentered while we're inside Init().
#if !defined(XP_WIN) && !defined(XP_MACOSX) && !defined(HAVE_ARC4RANDOM)
/* initialize random number generator using NSPR random noise */
unsigned int seed;
size_t bytes = 0;
while (bytes < sizeof(seed)) {
size_t nbytes = PR_GetRandomNoise(((unsigned char*)&seed) + bytes,
sizeof(seed) - bytes);
if (nbytes == 0) {
return NS_ERROR_FAILURE;
}
bytes += nbytes;
}
/* Initialize a new RNG state, and immediately switch
* back to the previous one -- we want to use mState
* only for our own calls to random().
*/
mSavedState = initstate(seed, mState, sizeof(mState));
setstate(mSavedState);
mRBytes = 4;
# ifdef RAND_MAX
if ((unsigned long)RAND_MAX < 0xffffffffUL) {
mRBytes = 3;
}
if ((unsigned long)RAND_MAX < 0x00ffffffUL) {
mRBytes = 2;
}
if ((unsigned long)RAND_MAX < 0x0000ffffUL) {
mRBytes = 1;
}
if ((unsigned long)RAND_MAX < 0x000000ffUL) {
return NS_ERROR_FAILURE;
}
# endif
#endif /* non XP_WIN and non XP_MACOSX and non ARC4RANDOM */
return NS_OK;
}
Minimal test - lines (78, 89)
path: .spaces[2].metrics.cyclomatic.average
old: 1.0
new: 2.0
path: .spaces[2].metrics.cyclomatic.sum
old: 1.0
new: 2.0
path: .spaces[2].metrics.nargs.average
old: 2.0
new: 1.0
path: .spaces[2].metrics.nargs.sum
old: 2.0
new: 1.0
path: .spaces[2].metrics.halstead.estimated_program_length
old: 119.65784284662088
new: 76.10749561002054
path: .spaces[2].metrics.halstead.vocabulary
old: 30.0
new: 22.0
path: .spaces[2].metrics.halstead.length
old: 86.0
new: 52.0
path: .spaces[2].metrics.halstead.n2
old: 20.0
new: 11.0
path: .spaces[2].metrics.halstead.N1
old: 45.0
new: 31.0
path: .spaces[2].metrics.halstead.n1
old: 10.0
new: 11.0
path: .spaces[2].metrics.halstead.time
old: 240.3013366682727
new: 135.26942576533136
path: .spaces[2].metrics.halstead.volume
old: 421.99259122233263
new: 231.89044416913947
path: .spaces[2].metrics.halstead.N2
old: 41.0
new: 21.0
path: .spaces[2].metrics.halstead.effort
old: 4325.4240600289095
new: 2434.8496637759645
path: .spaces[2].metrics.halstead.level
old: 0.0975609756097561
new: 0.09523809523809525
path: .spaces[2].metrics.halstead.difficulty
old: 10.25
new: 10.5
path: .spaces[2].metrics.halstead.purity_ratio
old: 1.3913702656583822
new: 1.4636056848080872
path: .spaces[2].metrics.halstead.bugs
old: 0.08849074940728989
new: 0.060329099971885056
path: .spaces[2].metrics.nexits.average
old: 0.0
new: 2.0
path: .spaces[2].metrics.nexits.sum
old: 0.0
new: 2.0
path: .spaces[2].metrics.loc.lloc
old: 4.0
new: 5.0
path: .spaces[2].metrics.loc.sloc
old: 19.0
new: 12.0
path: .spaces[2].metrics.loc.blank
old: 1.0
new: 2.0
path: .spaces[2].metrics.loc.cloc
old: 5.0
new: 0.0
path: .spaces[2].metrics.loc.ploc
old: 13.0
new: 10.0
path: .spaces[2].metrics.mi.mi_visual_studio
old: 53.58839309842851
new: 59.628031627172646
path: .spaces[2].metrics.mi.mi_sei
old: 92.28734455519276
new: 71.60564977709792
path: .spaces[2].metrics.mi.mi_original
old: 91.63615219831276
new: 101.96393408246522
path: .spaces[2].metrics.cognitive.average
old: 0.0
new: 1.0
path: .spaces[2].metrics.cognitive.sum
old: 0.0
new: 1.0
Code
nsUUIDGenerator::GenerateUUID(nsID** aRet) {
nsID* id = static_cast(moz_xmalloc(sizeof(nsID)));
nsresult rv = GenerateUUIDInPlace(id);
if (NS_FAILED(rv)) {
free(id);
return rv;
}
*aRet = id;
return rv;
}