Global Metrics
path: .metrics.cyclomatic.sum
old: 244.0
new: 69.0
path: .metrics.cyclomatic.average
old: 4.206896551724138
new: 4.6
path: .metrics.halstead.N2
old: 2865.0
new: 487.0
path: .metrics.halstead.volume
old: 50825.103433972625
new: 8900.68478491864
path: .metrics.halstead.time
old: 671409.218946423
new: 46657.51326316552
path: .metrics.halstead.N1
old: 3356.0
new: 823.0
path: .metrics.halstead.estimated_program_length
old: 2182.906338390757
new: 659.3343332129821
path: .metrics.halstead.vocabulary
old: 288.0
new: 111.0
path: .metrics.halstead.n2
old: 247.0
new: 80.0
path: .metrics.halstead.purity_ratio
old: 0.3508931583974854
new: 0.5033086513076199
path: .metrics.halstead.effort
old: 12085365.941035615
new: 839835.2387369794
path: .metrics.halstead.bugs
old: 17.5543713825519
new: 2.9671634739032093
path: .metrics.halstead.n1
old: 41.0
new: 31.0
path: .metrics.halstead.difficulty
old: 237.7834008097166
new: 94.35625
path: .metrics.halstead.length
old: 6221.0
new: 1310.0
path: .metrics.halstead.level
old: 0.004205508023666624
new: 0.010598132079221036
path: .metrics.mi.mi_sei
old: -115.79271643215212
new: -29.953524258640225
path: .metrics.mi.mi_visual_studio
old: 0.0
new: 6.280485791945171
path: .metrics.mi.mi_original
old: -59.099803992637945
new: 10.739630704226244
path: .metrics.nargs.sum
old: 133.0
new: 20.0
path: .metrics.nargs.average
old: 2.418181818181818
new: 1.818181818181818
path: .metrics.cognitive.average
old: 3.9454545454545458
new: 7.181818181818182
path: .metrics.cognitive.sum
old: 217.0
new: 79.0
path: .metrics.nexits.sum
old: 94.0
new: 37.0
path: .metrics.nexits.average
old: 1.709090909090909
new: 3.363636363636364
path: .metrics.nom.functions
old: 55.0
new: 11.0
path: .metrics.nom.total
old: 55.0
new: 11.0
path: .metrics.loc.ploc
old: 1100.0
new: 284.0
path: .metrics.loc.sloc
old: 1424.0
new: 401.0
path: .metrics.loc.cloc
old: 104.0
new: 39.0
path: .metrics.loc.lloc
old: 512.0
new: 144.0
path: .metrics.loc.blank
old: 220.0
new: 78.0
Spaces Data
Minimal test - lines (327, 401)
path: .spaces[11].metrics.cyclomatic.sum
old: 1.0
new: 13.0
path: .spaces[11].metrics.cyclomatic.average
old: 1.0
new: 4.333333333333333
path: .spaces[11].metrics.cognitive.average
old: 0.0
new: 6.0
path: .spaces[11].metrics.cognitive.sum
old: 0.0
new: 12.0
path: .spaces[11].metrics.loc.sloc
old: 5.0
new: 75.0
path: .spaces[11].metrics.loc.ploc
old: 5.0
new: 56.0
path: .spaces[11].metrics.loc.blank
old: 0.0
new: 19.0
path: .spaces[11].metrics.loc.lloc
old: 1.0
new: 26.0
path: .spaces[11].metrics.mi.mi_visual_studio
old: 72.9358359574522
new: 35.723543555648966
path: .spaces[11].metrics.mi.mi_original
old: 124.72027948724326
new: 61.08725948015973
path: .spaces[11].metrics.mi.mi_sei
old: 104.33429658192304
new: 13.753092493769016
path: .spaces[11].metrics.nom.functions
old: 1.0
new: 2.0
path: .spaces[11].metrics.nom.total
old: 1.0
new: 2.0
path: .spaces[11].metrics.nexits.sum
old: 0.0
new: 6.0
path: .spaces[11].metrics.nexits.average
old: 0.0
new: 3.0
path: .spaces[11].metrics.halstead.length
old: 13.0
new: 239.0
path: .spaces[11].metrics.halstead.n1
old: 7.0
new: 14.0
path: .spaces[11].metrics.halstead.N2
old: 6.0
new: 90.0
path: .spaces[11].metrics.halstead.level
old: 0.23809523809523808
new: 0.03333333333333333
path: .spaces[11].metrics.halstead.estimated_program_length
old: 31.26112492884004
new: 145.54163478716043
path: .spaces[11].metrics.halstead.vocabulary
old: 12.0
new: 35.0
path: .spaces[11].metrics.halstead.volume
old: 46.60451250937503
new: 1225.898641049847
path: .spaces[11].metrics.halstead.bugs
old: 0.011237341657241998
new: 0.3686344827603722
path: .spaces[11].metrics.halstead.N1
old: 7.0
new: 149.0
path: .spaces[11].metrics.halstead.n2
old: 5.0
new: 21.0
path: .spaces[11].metrics.halstead.effort
old: 195.73895253937513
new: 36776.959231495406
path: .spaces[11].metrics.halstead.time
old: 10.874386252187508
new: 2043.164401749745
path: .spaces[11].metrics.halstead.purity_ratio
old: 2.40470191760308
new: 0.6089608150090394
path: .spaces[11].metrics.halstead.difficulty
old: 4.2
new: 30.0
path: .spaces[11].metrics.nargs.sum
old: 1.0
new: 4.0
path: .spaces[11].metrics.nargs.average
old: 1.0
new: 2.0
Code
namespace mozilla {
#ifdef XP_WIN
int32_t CompareVersions(const char16_t* aStrA, const char16_t* aStrB) {
wchar_t* A2 = wcsdup(char16ptr_t(aStrA));
if (!A2) {
return 1;
}
wchar_t* B2 = wcsdup(char16ptr_t(aStrB));
if (!B2) {
free(A2);
return 1;
}
int32_t result;
wchar_t* a = A2;
wchar_t* b = B2;
do {
VersionPartW va, vb;
a = ParseVP(a, va);
b = ParseVP(b, vb);
result = CompareVP(va, vb);
if (result) {
break;
}
} while (a || b);
free(A2);
free(B2);
return result;
}
#endif
int32_t CompareVersions(const char* aStrA, const char* aStrB) {
char* A2 = strdup(aStrA);
if (!A2) {
return 1;
}
char* B2 = strdup(aStrB);
if (!B2) {
free(A2);
return 1;
}
int32_t result;
char* a = A2;
char* b = B2;
do {
VersionPart va, vb;
a = ParseVP(a, va);
b = ParseVP(b, vb);
result = CompareVP(va, vb);
if (result) {
break;
}
} while (a || b);
free(A2);
free(B2);
return result;
}
} // namespace mozilla
Minimal test - lines (276, 293)
path: .spaces[9].metrics.nexits.average
old: 0.0
new: 4.0
path: .spaces[9].metrics.nexits.sum
old: 0.0
new: 4.0
path: .spaces[9].metrics.loc.lloc
old: 8.0
new: 9.0
path: .spaces[9].metrics.loc.sloc
old: 14.0
new: 18.0
path: .spaces[9].metrics.loc.ploc
old: 13.0
new: 15.0
path: .spaces[9].metrics.loc.blank
old: 1.0
new: 3.0
path: .spaces[9].metrics.cognitive.average
old: 4.0
new: 3.0
path: .spaces[9].metrics.cognitive.sum
old: 4.0
new: 3.0
path: .spaces[9].metrics.cyclomatic.average
old: 5.0
new: 4.0
path: .spaces[9].metrics.cyclomatic.sum
old: 5.0
new: 4.0
path: .spaces[9].metrics.mi.mi_visual_studio
old: 55.45824757839937
new: 53.874542401776615
path: .spaces[9].metrics.mi.mi_original
old: 94.83360335906292
new: 92.125467507038
path: .spaces[9].metrics.mi.mi_sei
old: 61.62421658076058
new: 57.615382557586145
path: .spaces[9].metrics.halstead.n2
old: 10.0
new: 13.0
path: .spaces[9].metrics.halstead.level
old: 0.031446540880503145
new: 0.06842105263157895
path: .spaces[9].metrics.halstead.estimated_program_length
old: 76.2388309575275
new: 81.32499728470782
path: .spaces[9].metrics.halstead.n1
old: 12.0
new: 10.0
path: .spaces[9].metrics.halstead.vocabulary
old: 22.0
new: 23.0
path: .spaces[9].metrics.halstead.length
old: 111.0
new: 88.0
path: .spaces[9].metrics.halstead.N1
old: 58.0
new: 50.0
path: .spaces[9].metrics.halstead.bugs
old: 0.20936230142434528
new: 0.10782704935943677
path: .spaces[9].metrics.halstead.difficulty
old: 31.8
new: 14.615384615384617
path: .spaces[9].metrics.halstead.effort
old: 15740.901727465933
new: 5817.996608097943
path: .spaces[9].metrics.halstead.time
old: 874.4945404147741
new: 323.22203378321905
path: .spaces[9].metrics.halstead.volume
old: 494.99690966874
new: 398.0734521330171
path: .spaces[9].metrics.halstead.N2
old: 53.0
new: 38.0
path: .spaces[9].metrics.halstead.purity_ratio
old: 0.6868363149326802
new: 0.9241476964171343
Code
static int32_t CompareVP(VersionPart& aVer1, VersionPart& aVer2) {
int32_t r = ns_cmp(aVer1.numA, aVer2.numA);
if (r) {
return r;
}
r = ns_strnncmp(aVer1.strB, aVer1.strBlen, aVer2.strB, aVer2.strBlen);
if (r) {
return r;
}
r = ns_cmp(aVer1.numC, aVer2.numC);
if (r) {
return r;
}
return ns_strcmp(aVer1.extraD, aVer2.extraD);
}
Minimal test - lines (156, 218)
path: .spaces[5].metrics.mi.mi_original
old: 101.58542825248946
new: 63.276032022030776
path: .spaces[5].metrics.mi.mi_sei
old: 71.05958129324432
new: 16.707184066751353
path: .spaces[5].metrics.mi.mi_visual_studio
old: 59.406683188590335
new: 37.003527498263615
path: .spaces[5].metrics.cyclomatic.average
old: 2.0
new: 11.0
path: .spaces[5].metrics.cyclomatic.sum
old: 2.0
new: 11.0
path: .spaces[5].metrics.loc.blank
old: 2.0
new: 11.0
path: .spaces[5].metrics.loc.ploc
old: 12.0
new: 52.0
path: .spaces[5].metrics.loc.lloc
old: 6.0
new: 32.0
path: .spaces[5].metrics.loc.sloc
old: 14.0
new: 63.0
path: .spaces[5].metrics.halstead.N1
old: 23.0
new: 172.0
path: .spaces[5].metrics.halstead.bugs
old: 0.040716530044603606
new: 0.5379702360814241
path: .spaces[5].metrics.halstead.vocabulary
old: 18.0
new: 46.0
path: .spaces[5].metrics.halstead.purity_ratio
old: 1.54646705267226
new: 0.760346973075628
path: .spaces[5].metrics.halstead.time
old: 75.00073440094158
new: 3602.0252227838996
path: .spaces[5].metrics.halstead.effort
old: 1350.0132192169483
new: 64836.45401011019
path: .spaces[5].metrics.halstead.difficulty
old: 8.75
new: 42.84
path: .spaces[5].metrics.halstead.estimated_program_length
old: 57.219280948873624
new: 208.33507062272207
path: .spaces[5].metrics.halstead.volume
old: 154.28722505336555
new: 1513.4559759596216
path: .spaces[5].metrics.halstead.N2
old: 14.0
new: 102.0
path: .spaces[5].metrics.halstead.level
old: 0.11428571428571428
new: 0.023342670401493928
path: .spaces[5].metrics.halstead.n2
old: 8.0
new: 25.0
path: .spaces[5].metrics.halstead.length
old: 37.0
new: 274.0
path: .spaces[5].metrics.halstead.n1
old: 10.0
new: 21.0
path: .spaces[5].metrics.cognitive.sum
old: 1.0
new: 21.0
path: .spaces[5].metrics.cognitive.average
old: 1.0
new: 21.0
Code
static wchar_t* ParseVP(wchar_t* aPart, VersionPartW& aResult) {
wchar_t* dot;
aResult.numA = 0;
aResult.strB = nullptr;
aResult.strBlen = 0;
aResult.numC = 0;
aResult.extraD = nullptr;
if (!aPart) {
return aPart;
}
dot = wcschr(aPart, '.');
if (dot) {
*dot = '\0';
}
if (aPart[0] == '*' && aPart[1] == '\0') {
static wchar_t kEmpty[] = L"";
aResult.numA = INT32_MAX;
aResult.strB = kEmpty;
} else {
aResult.numA = ns_wcstol(aPart, const_cast(&aResult.strB));
}
if (!*aResult.strB) {
aResult.strB = nullptr;
aResult.strBlen = 0;
} else {
if (aResult.strB[0] == '+') {
static wchar_t kPre[] = L"pre";
++aResult.numA;
aResult.strB = kPre;
aResult.strBlen = sizeof(kPre) - 1;
} else {
const wchar_t* numstart = wcspbrk(aResult.strB, L"0123456789+-");
if (!numstart) {
aResult.strBlen = wcslen(aResult.strB);
} else {
aResult.strBlen = numstart - aResult.strB;
aResult.numC =
ns_wcstol(numstart, const_cast(&aResult.extraD));
if (!*aResult.extraD) {
aResult.extraD = nullptr;
}
}
}
}
if (dot) {
++dot;
if (!*dot) {
dot = nullptr;
}
}
return dot;
}
Minimal test - lines (31, 40)
path: .spaces[1].metrics.nexits.sum
old: 2.0
new: 0.0
path: .spaces[1].metrics.nexits.average
old: 2.0
new: null
path: .spaces[1].metrics.mi.mi_visual_studio
old: 35.428854994671234
new: 65.44690228041927
path: .spaces[1].metrics.mi.mi_original
old: 60.583342040887814
new: 111.91420289951697
path: .spaces[1].metrics.mi.mi_sei
old: 12.211534427878291
new: 117.79452392841635
path: .spaces[1].metrics.cognitive.sum
old: 6.0
new: 0.0
path: .spaces[1].metrics.cognitive.average
old: 6.0
new: null
path: .spaces[1].metrics.cyclomatic.average
old: 5.0
new: 1.0
path: .spaces[1].metrics.cyclomatic.sum
old: 5.0
new: 1.0
path: .spaces[1].metrics.nom.total
old: 1.0
new: 0.0
path: .spaces[1].metrics.nom.functions
old: 1.0
new: 0.0
path: .spaces[1].metrics.loc.sloc
old: 68.0
new: 10.0
path: .spaces[1].metrics.loc.cloc
old: 0.0
new: 2.0
path: .spaces[1].metrics.loc.lloc
old: 35.0
new: 0.0
path: .spaces[1].metrics.loc.blank
old: 12.0
new: 1.0
path: .spaces[1].metrics.loc.ploc
old: 56.0
new: 7.0
path: .spaces[1].metrics.halstead.difficulty
old: 48.65853658536585
new: 2.0
path: .spaces[1].metrics.halstead.N2
old: 210.0
new: 6.0
path: .spaces[1].metrics.halstead.bugs
old: 0.8423751986917077
new: 0.008388055489567838
path: .spaces[1].metrics.halstead.n1
old: 19.0
new: 4.0
path: .spaces[1].metrics.halstead.n2
old: 41.0
new: 6.0
path: .spaces[1].metrics.halstead.length
old: 442.0
new: 19.0
path: .spaces[1].metrics.halstead.estimated_program_length
old: 300.37025494476956
new: 23.509775004326936
path: .spaces[1].metrics.halstead.purity_ratio
old: 0.6795707125447275
new: 1.237356579175102
path: .spaces[1].metrics.halstead.time
old: 7057.773791736633
new: 7.012959311428876
path: .spaces[1].metrics.halstead.vocabulary
old: 60.0
new: 10.0
path: .spaces[1].metrics.halstead.N1
old: 232.0
new: 13.0
path: .spaces[1].metrics.halstead.effort
old: 127039.9282512594
new: 126.23326760571976
path: .spaces[1].metrics.halstead.volume
old: 2610.845643258965
new: 63.11663380285988
path: .spaces[1].metrics.halstead.level
old: 0.02055137844611529
new: 0.5
path: .spaces[1].metrics.nargs.sum
old: 2.0
new: 0.0
path: .spaces[1].metrics.nargs.average
old: 2.0
new: null
Code
struct VersionPartW {
int32_t numA;
wchar_t* strB; // NOT null-terminated, can be a null pointer
uint32_t strBlen;
int32_t numC;
wchar_t* extraD; // null-terminated
};
Minimal test - lines (236, 262)
path: .spaces[7].metrics.cyclomatic.average
old: 1.0
new: 9.0
path: .spaces[7].metrics.cyclomatic.sum
old: 1.0
new: 9.0
path: .spaces[7].metrics.nargs.average
old: 1.0
new: 4.0
path: .spaces[7].metrics.nargs.sum
old: 1.0
new: 4.0
path: .spaces[7].metrics.cognitive.average
old: 0.0
new: 9.0
path: .spaces[7].metrics.cognitive.sum
old: 0.0
new: 9.0
path: .spaces[7].metrics.nexits.sum
old: 0.0
new: 6.0
path: .spaces[7].metrics.nexits.average
old: 0.0
new: 6.0
path: .spaces[7].metrics.halstead.estimated_program_length
old: 23.21928094887362
new: 104.71062275542812
path: .spaces[7].metrics.halstead.N2
old: 7.0
new: 29.0
path: .spaces[7].metrics.halstead.length
old: 15.0
new: 94.0
path: .spaces[7].metrics.halstead.volume
old: 49.82892142331043
new: 446.9594252033661
path: .spaces[7].metrics.halstead.effort
old: 174.40122498158652
new: 15392.16520544092
path: .spaces[7].metrics.halstead.difficulty
old: 3.5
new: 34.4375
path: .spaces[7].metrics.halstead.vocabulary
old: 10.0
new: 27.0
path: .spaces[7].metrics.halstead.level
old: 0.2857142857142857
new: 0.029038112522686024
path: .spaces[7].metrics.halstead.bugs
old: 0.010405072229378904
new: 0.206258516269291
path: .spaces[7].metrics.halstead.purity_ratio
old: 1.5479520632582413
new: 1.113942795270512
path: .spaces[7].metrics.halstead.time
old: 9.688956943421474
new: 855.1202891911621
path: .spaces[7].metrics.halstead.N1
old: 8.0
new: 65.0
path: .spaces[7].metrics.halstead.n2
old: 5.0
new: 8.0
path: .spaces[7].metrics.halstead.n1
old: 5.0
new: 19.0
path: .spaces[7].metrics.loc.lloc
old: 2.0
new: 12.0
path: .spaces[7].metrics.loc.ploc
old: 6.0
new: 21.0
path: .spaces[7].metrics.loc.sloc
old: 6.0
new: 27.0
path: .spaces[7].metrics.loc.blank
old: 0.0
new: 5.0
path: .spaces[7].metrics.loc.cloc
old: 0.0
new: 1.0
path: .spaces[7].metrics.mi.mi_visual_studio
old: 71.00514599442104
new: 49.00854392469018
path: .spaces[7].metrics.mi.mi_original
old: 121.41879965046
new: 83.8046101112202
path: .spaces[7].metrics.mi.mi_sei
old: 99.57126799380096
new: 60.80727524770389
Code
static int32_t ns_strnncmp(const char* aStr1, uint32_t aLen1, const char* aStr2,
uint32_t aLen2) {
// any string is *before* no string
if (!aStr1) {
return aStr2 != 0;
}
if (!aStr2) {
return -1;
}
for (; aLen1 && aLen2; --aLen1, --aLen2, ++aStr1, ++aStr2) {
if (*aStr1 < *aStr2) {
return -1;
}
if (*aStr1 > *aStr2) {
return 1;
}
}
if (aLen1 == 0) {
return aLen2 == 0 ? 0 : -1;
}
return 1;
}
Minimal test - lines (222, 233)
path: .spaces[6].metrics.cognitive.sum
old: 1.0
new: 2.0
path: .spaces[6].metrics.cognitive.average
old: 1.0
new: 2.0
path: .spaces[6].metrics.cyclomatic.average
old: 2.0
new: 3.0
path: .spaces[6].metrics.cyclomatic.sum
old: 2.0
new: 3.0
path: .spaces[6].metrics.mi.mi_visual_studio
old: 58.21377055906012
new: 60.94238778692351
path: .spaces[6].metrics.mi.mi_sei
old: 68.11665567267298
new: 96.57273942851076
path: .spaces[6].metrics.mi.mi_original
old: 99.5455476559928
new: 104.2114831156392
path: .spaces[6].metrics.loc.ploc
old: 12.0
new: 9.0
path: .spaces[6].metrics.loc.sloc
old: 14.0
new: 12.0
path: .spaces[6].metrics.loc.cloc
old: 0.0
new: 1.0
path: .spaces[6].metrics.nexits.average
old: 0.0
new: 3.0
path: .spaces[6].metrics.nexits.sum
old: 0.0
new: 3.0
path: .spaces[6].metrics.halstead.length
old: 52.0
new: 36.0
path: .spaces[6].metrics.halstead.volume
old: 228.40050598449557
new: 144.0
path: .spaces[6].metrics.halstead.n2
old: 11.0
new: 6.0
path: .spaces[6].metrics.halstead.bugs
old: 0.05954978847813364
new: 0.0401108038901437
path: .spaces[6].metrics.halstead.difficulty
old: 10.454545454545457
new: 9.166666666666666
path: .spaces[6].metrics.halstead.vocabulary
old: 21.0
new: 16.0
path: .spaces[6].metrics.halstead.time
old: 132.65685953644945
new: 73.33333333333333
path: .spaces[6].metrics.halstead.N1
old: 29.0
new: 25.0
path: .spaces[6].metrics.halstead.effort
old: 2387.82347165609
new: 1320.0
path: .spaces[6].metrics.halstead.N2
old: 23.0
new: 11.0
path: .spaces[6].metrics.halstead.estimated_program_length
old: 71.27302875388389
new: 48.72905595320056
path: .spaces[6].metrics.halstead.level
old: 0.09565217391304348
new: 0.1090909090909091
path: .spaces[6].metrics.halstead.purity_ratio
old: 1.370635168343921
new: 1.3535848875889045
path: .spaces[6].metrics.nargs.sum
old: 1.0
new: 2.0
path: .spaces[6].metrics.nargs.average
old: 1.0
new: 2.0
Code
static int32_t ns_strcmp(const char* aStr1, const char* aStr2) {
// any string is *before* no string
if (!aStr1) {
return aStr2 != 0;
}
if (!aStr2) {
return -1;
}
return strcmp(aStr1, aStr2);
}
Minimal test - lines (139, 154)
path: .spaces[4].metrics.nexits.average
old: 3.3333333333333335
new: 3.0
path: .spaces[4].metrics.nexits.sum
old: 10.0
new: 3.0
path: .spaces[4].metrics.cyclomatic.average
old: 9.666666666666666
new: 3.0
path: .spaces[4].metrics.cyclomatic.sum
old: 29.0
new: 3.0
path: .spaces[4].metrics.halstead.estimated_program_length
old: 293.5877465509226
new: 101.62290894278166
path: .spaces[4].metrics.halstead.bugs
old: 0.9838338031161136
new: 0.08126901714648174
path: .spaces[4].metrics.halstead.effort
old: 160348.34890912392
new: 3806.881806419626
path: .spaces[4].metrics.halstead.n1
old: 19.0
new: 15.0
path: .spaces[4].metrics.halstead.level
old: 0.018306636155606407
new: 0.0761904761904762
path: .spaces[4].metrics.halstead.time
old: 8908.24160606244
new: 211.49343368997927
path: .spaces[4].metrics.halstead.N1
old: 269.0
new: 40.0
path: .spaces[4].metrics.halstead.difficulty
old: 54.625
new: 13.125
path: .spaces[4].metrics.halstead.length
old: 499.0
new: 61.0
path: .spaces[4].metrics.halstead.purity_ratio
old: 0.5883521974968389
new: 1.665949326930847
path: .spaces[4].metrics.halstead.n2
old: 40.0
new: 12.0
path: .spaces[4].metrics.halstead.vocabulary
old: 59.0
new: 27.0
path: .spaces[4].metrics.halstead.volume
old: 2935.438881631559
new: 290.04813763197154
path: .spaces[4].metrics.halstead.N2
old: 230.0
new: 21.0
path: .spaces[4].metrics.nom.functions
old: 3.0
new: 1.0
path: .spaces[4].metrics.nom.total
old: 3.0
new: 1.0
path: .spaces[4].metrics.cognitive.average
old: 11.333333333333334
new: 2.0
path: .spaces[4].metrics.cognitive.sum
old: 34.0
new: 2.0
path: .spaces[4].metrics.loc.sloc
old: 108.0
new: 16.0
path: .spaces[4].metrics.loc.blank
old: 18.0
new: 3.0
path: .spaces[4].metrics.loc.lloc
old: 62.0
new: 6.0
path: .spaces[4].metrics.loc.ploc
old: 89.0
new: 12.0
path: .spaces[4].metrics.mi.mi_sei
old: 2.4261326510817405
new: 81.8576393562118
path: .spaces[4].metrics.mi.mi_original
old: 46.95949039532192
new: 95.90981881430868
path: .spaces[4].metrics.mi.mi_visual_studio
old: 27.46169028966194
new: 56.08761334170098
path: .spaces[4].metrics.nargs.sum
old: 6.0
new: 2.0
Code
static int32_t ns_wcstol(const wchar_t* aPart, wchar_t** aNext) {
errno = 0;
long result_long = wcstol(aPart, aNext, 10);
// See above for the rationale for using 0 here.
if (errno != 0) {
return 0;
}
mozilla::CheckedInt result = result_long;
if (!result.isValid()) {
return 0;
}
return result.value();
}
Minimal test - lines (299, 324)
path: .spaces[10].metrics.halstead.vocabulary
old: 47.0
new: 28.0
path: .spaces[10].metrics.halstead.volume
old: 1016.4897598570076
new: 548.0384611145669
path: .spaces[10].metrics.halstead.length
old: 183.0
new: 114.0
path: .spaces[10].metrics.halstead.difficulty
old: 27.310344827586206
new: 17.625
path: .spaces[10].metrics.halstead.N2
old: 88.0
new: 47.0
path: .spaces[10].metrics.halstead.bugs
old: 0.30560857769743804
new: 0.1511838919172457
path: .spaces[10].metrics.halstead.effort
old: 27760.685855405176
new: 9659.17787714424
path: .spaces[10].metrics.halstead.n2
old: 29.0
new: 16.0
path: .spaces[10].metrics.halstead.n1
old: 18.0
new: 12.0
path: .spaces[10].metrics.halstead.N1
old: 95.0
new: 67.0
path: .spaces[10].metrics.halstead.estimated_program_length
old: 215.9400988846612
new: 107.01955000865388
path: .spaces[10].metrics.halstead.purity_ratio
old: 1.1800005403533398
new: 0.9387679825320516
path: .spaces[10].metrics.halstead.time
old: 1542.2603253002876
new: 536.62099317468
path: .spaces[10].metrics.halstead.level
old: 0.036616161616161616
new: 0.05673758865248227
path: .spaces[10].metrics.mi.mi_visual_studio
old: 42.23577965992596
new: 49.14961382763022
path: .spaces[10].metrics.mi.mi_sei
old: 49.20335454630021
new: 46.16258322796189
path: .spaces[10].metrics.mi.mi_original
old: 72.2231832184734
new: 84.04583964524767
path: .spaces[10].metrics.loc.cloc
old: 3.0
new: 0.0
path: .spaces[10].metrics.loc.blank
old: 6.0
new: 5.0
path: .spaces[10].metrics.loc.ploc
old: 34.0
new: 21.0
path: .spaces[10].metrics.loc.lloc
old: 18.0
new: 13.0
path: .spaces[10].metrics.loc.sloc
old: 43.0
new: 26.0
path: .spaces[10].metrics.cyclomatic.sum
old: 8.0
new: 6.0
path: .spaces[10].metrics.cyclomatic.average
old: 8.0
new: 6.0
path: .spaces[10].metrics.cognitive.sum
old: 11.0
new: 5.0
path: .spaces[10].metrics.cognitive.average
old: 11.0
new: 5.0
path: .spaces[10].metrics.nexits.sum
old: 2.0
new: 6.0
path: .spaces[10].metrics.nexits.average
old: 2.0
new: 6.0
path: .spaces[10].metrics.nargs.sum
old: 3.0
new: 2.0
path: .spaces[10].metrics.nargs.average
old: 3.0
new: 2.0
Code
static int32_t CompareVP(VersionPartW& aVer1, VersionPartW& aVer2) {
int32_t r = ns_cmp(aVer1.numA, aVer2.numA);
if (r) {
return r;
}
r = wcsncmp(aVer1.strB, aVer2.strB, XPCOM_MIN(aVer1.strBlen, aVer2.strBlen));
if (r) {
return r;
}
r = ns_cmp(aVer1.numC, aVer2.numC);
if (r) {
return r;
}
if (!aVer1.extraD) {
return aVer2.extraD != 0;
}
if (!aVer2.extraD) {
return -1;
}
return wcscmp(aVer1.extraD, aVer2.extraD);
}
Minimal test - lines (265, 271)
path: .spaces[8].metrics.halstead.n2
old: 12.0
new: 4.0
path: .spaces[8].metrics.halstead.volume
old: 171.8953543301665
new: 85.11011351724513
path: .spaces[8].metrics.halstead.N2
old: 18.0
new: 8.0
path: .spaces[8].metrics.halstead.estimated_program_length
old: 81.07329781366414
new: 36.529325012980806
path: .spaces[8].metrics.halstead.bugs
old: 0.042075001229485993
new: 0.02790580347525356
path: .spaces[8].metrics.halstead.difficulty
old: 8.25
new: 9.0
path: .spaces[8].metrics.halstead.length
old: 38.0
new: 23.0
path: .spaces[8].metrics.halstead.purity_ratio
old: 2.133507837201688
new: 1.5882315223035133
path: .spaces[8].metrics.halstead.level
old: 0.12121212121212122
new: 0.1111111111111111
path: .spaces[8].metrics.halstead.vocabulary
old: 23.0
new: 13.0
path: .spaces[8].metrics.halstead.n1
old: 11.0
new: 9.0
path: .spaces[8].metrics.halstead.effort
old: 1418.1366732238737
new: 765.9910216552062
path: .spaces[8].metrics.halstead.time
old: 78.78537073465965
new: 42.55505675862256
path: .spaces[8].metrics.halstead.N1
old: 20.0
new: 15.0
path: .spaces[8].metrics.mi.mi_visual_studio
old: 61.3627426727086
new: 67.78230237120323
path: .spaces[8].metrics.mi.mi_sei
old: 75.88519670603468
new: 91.72230517635676
path: .spaces[8].metrics.mi.mi_original
old: 104.9302899703317
new: 115.90773705475752
path: .spaces[8].metrics.nargs.average
old: 1.0
new: 2.0
path: .spaces[8].metrics.nargs.sum
old: 1.0
new: 2.0
path: .spaces[8].metrics.loc.blank
old: 2.0
new: 1.0
path: .spaces[8].metrics.loc.ploc
old: 9.0
new: 6.0
path: .spaces[8].metrics.loc.sloc
old: 11.0
new: 7.0
path: .spaces[8].metrics.loc.lloc
old: 4.0
new: 3.0
Code
static int32_t ns_cmp(int32_t aNum1, int32_t aNum2) {
if (aNum1 < aNum2) {
return -1;
}
return aNum1 != aNum2;
}
Minimal test - lines (71, 130)
path: .spaces[3].metrics.nexits.average
old: 0.5
new: 2.0
path: .spaces[3].metrics.nexits.sum
old: 1.0
new: 2.0
path: .spaces[3].metrics.cognitive.sum
old: 0.0
new: 21.0
path: .spaces[3].metrics.cognitive.average
old: 0.0
new: 21.0
path: .spaces[3].metrics.halstead.time
old: 276.69643130741065
new: 3577.3320863591907
path: .spaces[3].metrics.halstead.n1
old: 13.0
new: 21.0
path: .spaces[3].metrics.halstead.vocabulary
old: 25.0
new: 45.0
path: .spaces[3].metrics.halstead.purity_ratio
old: 1.3806858537043647
new: 0.7547677831927676
path: .spaces[3].metrics.halstead.volume
old: 306.49450852513183
new: 1471.8166298163528
path: .spaces[3].metrics.halstead.difficulty
old: 16.25
new: 43.75
path: .spaces[3].metrics.halstead.N2
old: 30.0
new: 100.0
path: .spaces[3].metrics.halstead.estimated_program_length
old: 91.12526634448808
new: 202.27776589566173
path: .spaces[3].metrics.halstead.effort
old: 4980.535763533392
new: 64391.97755446543
path: .spaces[3].metrics.halstead.length
old: 66.0
new: 268.0
path: .spaces[3].metrics.halstead.N1
old: 36.0
new: 168.0
path: .spaces[3].metrics.halstead.bugs
old: 0.0972141434389765
new: 0.5355087695494655
path: .spaces[3].metrics.halstead.level
old: 0.06153846153846154
new: 0.022857142857142857
path: .spaces[3].metrics.halstead.n2
old: 12.0
new: 24.0
path: .spaces[3].metrics.nargs.average
old: 1.5
new: 0.0
path: .spaces[3].metrics.nargs.sum
old: 3.0
new: 0.0
path: .spaces[3].metrics.nom.functions
old: 2.0
new: 1.0
path: .spaces[3].metrics.nom.total
old: 2.0
new: 1.0
path: .spaces[3].metrics.mi.mi_visual_studio
old: 56.66581729939733
new: 37.55058710593923
path: .spaces[3].metrics.mi.mi_original
old: 96.89854758196944
new: 64.21150395115609
path: .spaces[3].metrics.mi.mi_sei
old: 64.29784179264676
new: 18.05678477979129
path: .spaces[3].metrics.cyclomatic.average
old: 1.0
new: 11.0
path: .spaces[3].metrics.cyclomatic.sum
old: 2.0
new: 11.0
path: .spaces[3].metrics.loc.blank
old: 2.0
new: 10.0
path: .spaces[3].metrics.loc.lloc
old: 5.0
new: 32.0
path: .spaces[3].metrics.loc.sloc
old: 15.0
new: 60.0
path: .spaces[3].metrics.loc.ploc
old: 13.0
new: 50.0
Code
static char* ParseVP(char* aPart, VersionPart& aResult) {
char* dot;
aResult.numA = 0;
aResult.strB = nullptr;
aResult.strBlen = 0;
aResult.numC = 0;
aResult.extraD = nullptr;
if (!aPart) {
return aPart;
}
dot = strchr(aPart, '.');
if (dot) {
*dot = '\0';
}
if (aPart[0] == '*' && aPart[1] == '\0') {
aResult.numA = INT32_MAX;
aResult.strB = "";
} else {
aResult.numA = ns_strtol(aPart, const_cast(&aResult.strB));
}
if (!*aResult.strB) {
aResult.strB = nullptr;
aResult.strBlen = 0;
} else {
if (aResult.strB[0] == '+') {
static const char kPre[] = "pre";
++aResult.numA;
aResult.strB = kPre;
aResult.strBlen = sizeof(kPre) - 1;
} else {
const char* numstart = strpbrk(aResult.strB, "0123456789+-");
if (!numstart) {
aResult.strBlen = strlen(aResult.strB);
} else {
aResult.strBlen = numstart - aResult.strB;
aResult.numC = ns_strtol(numstart, const_cast(&aResult.extraD));
if (!*aResult.extraD) {
aResult.extraD = nullptr;
}
}
}
}
if (dot) {
++dot;
if (!*dot) {
dot = nullptr;
}
}
return dot;
}
Minimal test - lines (19, 28)
path: .spaces[0].metrics.nom.functions
old: 1.0
new: 0.0
path: .spaces[0].metrics.nom.total
old: 1.0
new: 0.0
path: .spaces[0].metrics.halstead.difficulty
old: 16.176470588235293
new: 2.0
path: .spaces[0].metrics.halstead.n2
old: 34.0
new: 6.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 211.0274844075218
new: 23.509775004326936
path: .spaces[0].metrics.halstead.volume
old: 1120.3380316512537
new: 63.11663380285988
path: .spaces[0].metrics.halstead.n1
old: 11.0
new: 4.0
path: .spaces[0].metrics.halstead.effort
old: 18123.115217887927
new: 126.23326760571976
path: .spaces[0].metrics.halstead.length
old: 204.0
new: 19.0
path: .spaces[0].metrics.halstead.bugs
old: 0.2299856009097745
new: 0.008388055489567838
path: .spaces[0].metrics.halstead.time
old: 1006.8397343271072
new: 7.012959311428876
path: .spaces[0].metrics.halstead.level
old: 0.06181818181818182
new: 0.5
path: .spaces[0].metrics.halstead.vocabulary
old: 45.0
new: 10.0
path: .spaces[0].metrics.halstead.N1
old: 104.0
new: 13.0
path: .spaces[0].metrics.halstead.N2
old: 100.0
new: 6.0
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.034448452978048
new: 1.237356579175102
path: .spaces[0].metrics.cognitive.average
old: 0.0
new: null
path: .spaces[0].metrics.loc.lloc
old: 19.0
new: 0.0
path: .spaces[0].metrics.loc.blank
old: 4.0
new: 1.0
path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 2.0
path: .spaces[0].metrics.loc.ploc
old: 23.0
new: 7.0
path: .spaces[0].metrics.loc.sloc
old: 27.0
new: 10.0
path: .spaces[0].metrics.nexits.average
old: 0.0
new: null
path: .spaces[0].metrics.mi.mi_sei
old: 41.066286905729754
new: 117.79452392841635
path: .spaces[0].metrics.mi.mi_original
old: 80.86623696055054
new: 111.91420289951697
path: .spaces[0].metrics.mi.mi_visual_studio
old: 47.29019705295353
new: 65.44690228041927
path: .spaces[0].metrics.nargs.average
old: 1.0
new: null
path: .spaces[0].metrics.nargs.sum
old: 1.0
new: 0.0
Code
struct VersionPart {
int32_t numA;
const char* strB; // NOT null-terminated, can be a null pointer
uint32_t strBlen;
int32_t numC;
char* extraD; // null-terminated
};
Minimal test - lines (43, 64)
path: .spaces[2].metrics.cyclomatic.sum
old: 2.0
new: 3.0
path: .spaces[2].metrics.cyclomatic.average
old: 1.0
new: 3.0
path: .spaces[2].metrics.nexits.sum
old: 1.0
new: 3.0
path: .spaces[2].metrics.nexits.average
old: 0.5
new: 3.0
path: .spaces[2].metrics.nom.functions
old: 2.0
new: 1.0
path: .spaces[2].metrics.nom.total
old: 2.0
new: 1.0
path: .spaces[2].metrics.cognitive.average
old: 0.0
new: 2.0
path: .spaces[2].metrics.cognitive.sum
old: 0.0
new: 2.0
path: .spaces[2].metrics.halstead.N2
old: 62.0
new: 21.0
path: .spaces[2].metrics.halstead.difficulty
old: 25.1875
new: 13.125
path: .spaces[2].metrics.halstead.length
old: 139.0
new: 61.0
path: .spaces[2].metrics.halstead.effort
old: 17008.095087753823
new: 3806.881806419626
path: .spaces[2].metrics.halstead.level
old: 0.03970223325062035
new: 0.0761904761904762
path: .spaces[2].metrics.halstead.bugs
old: 0.22045292327814067
new: 0.08126901714648174
path: .spaces[2].metrics.halstead.estimated_program_length
old: 112.1057163358342
new: 101.62290894278166
path: .spaces[2].metrics.halstead.n1
old: 13.0
new: 15.0
path: .spaces[2].metrics.halstead.time
old: 944.8941715418792
new: 211.49343368997927
path: .spaces[2].metrics.halstead.vocabulary
old: 29.0
new: 27.0
path: .spaces[2].metrics.halstead.N1
old: 77.0
new: 40.0
path: .spaces[2].metrics.halstead.n2
old: 16.0
new: 12.0
path: .spaces[2].metrics.halstead.purity_ratio
old: 0.8065159448621164
new: 1.665949326930847
path: .spaces[2].metrics.halstead.volume
old: 675.2593583227325
new: 290.04813763197154
path: .spaces[2].metrics.nargs.average
old: 1.5
new: 2.0
path: .spaces[2].metrics.nargs.sum
old: 3.0
new: 2.0
path: .spaces[2].metrics.mi.mi_original
old: 84.51570800868235
new: 90.7508683701884
path: .spaces[2].metrics.mi.mi_sei
old: 46.433180548141905
new: 93.87114169268705
path: .spaces[2].metrics.mi.mi_visual_studio
old: 49.42439064835226
new: 53.07068325742013
path: .spaces[2].metrics.loc.blank
old: 5.0
new: 3.0
path: .spaces[2].metrics.loc.ploc
old: 20.0
new: 12.0
path: .spaces[2].metrics.loc.sloc
old: 25.0
new: 22.0
path: .spaces[2].metrics.loc.cloc
old: 0.0
new: 7.0
path: .spaces[2].metrics.loc.lloc
old: 10.0
new: 6.0
Code
static int32_t ns_strtol(const char* aPart, char** aNext) {
errno = 0;
long result_long = strtol(aPart, aNext, 10);
// Different platforms seem to disagree on what to return when the value
// is out of range so we ensure that it is always what we want it to be.
// We choose 0 firstly because that is the default when the number doesn't
// exist at all and also because it would be easier to recover from should
// you somehow end up in a situation where an old version is invalid. It is
// much easier to create a version either larger or smaller than 0, much
// harder to do the same with INT_MAX.
if (errno != 0) {
return 0;
}
mozilla::CheckedInt result = result_long;
if (!result.isValid()) {
return 0;
}
return result.value();
}