Global Metrics
path: .metrics.halstead.N2
old: 150.0
new: 99.0
path: .metrics.halstead.bugs
old: 0.3347821201312808
new: 0.237199581020391
path: .metrics.halstead.level
old: 0.07022222222222223
new: 0.06216006216006217
path: .metrics.halstead.volume
old: 2235.1147984220743
new: 1179.9516136400189
path: .metrics.halstead.time
old: 1768.2870240680966
new: 1054.5817546907667
path: .metrics.halstead.length
old: 341.0
new: 206.0
path: .metrics.halstead.effort
old: 31829.16643322574
new: 18982.4715844338
path: .metrics.halstead.n1
old: 15.0
new: 13.0
path: .metrics.halstead.n2
old: 79.0
new: 40.0
path: .metrics.halstead.estimated_program_length
old: 556.6020380401189
new: 260.9828401313287
path: .metrics.halstead.purity_ratio
old: 1.632264041173369
new: 1.2669069909287802
path: .metrics.halstead.difficulty
old: 14.240506329113924
new: 16.0875
path: .metrics.halstead.N1
old: 191.0
new: 107.0
path: .metrics.halstead.vocabulary
old: 94.0
new: 53.0
path: .metrics.cyclomatic.sum
old: 18.0
new: 6.0
path: .metrics.loc.blank
old: 29.0
new: 14.0
path: .metrics.loc.lloc
old: 8.0
new: 13.0
path: .metrics.loc.sloc
old: 122.0
new: 59.0
path: .metrics.loc.ploc
old: 75.0
new: 38.0
path: .metrics.loc.cloc
old: 18.0
new: 7.0
path: .metrics.nom.total
old: 11.0
new: 4.0
path: .metrics.nom.functions
old: 11.0
new: 4.0
path: .metrics.mi.mi_visual_studio
old: 28.61532757485786
new: 39.05444684814956
path: .metrics.mi.mi_sei
old: 24.754152612985784
new: 46.69020626479669
path: .metrics.mi.mi_original
old: 48.93221015300695
new: 66.78310411033576
path: .metrics.nargs.average
old: 0.3636363636363637
new: 1.5
path: .metrics.nargs.sum
old: 4.0
new: 6.0
path: .metrics.nexits.sum
old: 7.0
new: 0.0
path: .metrics.nexits.average
old: 0.6363636363636364
new: 0.0
Spaces Data
Minimal test - lines (17, 27)
path: .spaces[0].spaces[0].metrics.nargs.average
old: 0.3636363636363637
new: 1.0
path: .spaces[0].spaces[0].metrics.nargs.sum
old: 4.0
new: 1.0
path: .spaces[0].spaces[0].metrics.cyclomatic.sum
old: 16.0
new: 1.0
path: .spaces[0].spaces[0].metrics.nom.total
old: 11.0
new: 1.0
path: .spaces[0].spaces[0].metrics.nom.functions
old: 11.0
new: 1.0
path: .spaces[0].spaces[0].metrics.loc.cloc
old: 10.0
new: 0.0
path: .spaces[0].spaces[0].metrics.loc.blank
old: 28.0
new: 2.0
path: .spaces[0].spaces[0].metrics.loc.lloc
old: 8.0
new: 3.0
path: .spaces[0].spaces[0].metrics.loc.sloc
old: 104.0
new: 11.0
path: .spaces[0].spaces[0].metrics.loc.ploc
old: 66.0
new: 9.0
path: .spaces[0].spaces[0].metrics.mi.mi_original
old: 52.17771157421015
new: 102.24375860225874
path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 30.51328162234512
new: 59.79167169722733
path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: 24.310799327931296
new: 71.9075313647187
path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 510.460551732369
new: 113.92990370430176
path: .spaces[0].spaces[0].metrics.halstead.time
old: 1755.6602411409217
new: 123.29612584124948
path: .spaces[0].spaces[0].metrics.halstead.n2
old: 73.0
new: 19.0
path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 1.532914569766874
new: 1.837579092004867
path: .spaces[0].spaces[0].metrics.halstead.N2
old: 143.0
new: 28.0
path: .spaces[0].spaces[0].metrics.halstead.effort
old: 31601.88434053659
new: 2219.3302651424906
path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.33318650131642347
new: 0.05671440354902988
path: .spaces[0].spaces[0].metrics.halstead.volume
old: 2150.99072900622
new: 301.19482169790945
path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 88.0
new: 29.0
path: .spaces[0].spaces[0].metrics.halstead.N1
old: 190.0
new: 34.0
path: .spaces[0].spaces[0].metrics.halstead.n1
old: 15.0
new: 10.0
path: .spaces[0].spaces[0].metrics.halstead.length
old: 333.0
new: 62.0
path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 14.691780821917808
new: 7.368421052631579
path: .spaces[0].spaces[0].metrics.halstead.level
old: 0.06806526806526807
new: 0.1357142857142857
path: .spaces[0].spaces[0].metrics.nexits.average
old: 0.6363636363636364
new: 0.0
path: .spaces[0].spaces[0].metrics.nexits.sum
old: 7.0
new: 0.0
Code
static void TestStringStream(uint32_t aNumBytes) {
nsTArray inputData;
testing::CreateData(aNumBytes, inputData);
nsDependentCSubstring inputString(inputData.Elements(), inputData.Length());
nsCOMPtr stream;
nsresult rv = NS_NewCStringInputStream(getter_AddRefs(stream), inputString);
ASSERT_TRUE(NS_SUCCEEDED(rv));
testing::ConsumeAndValidateStream(stream, inputString);
}
Minimal test - lines (15, 53)
path: .spaces[0].metrics.mi.mi_visual_studio
old: 30.17244805474182
new: 44.120281235676465
path: .spaces[0].metrics.mi.mi_sei
old: 24.39560375478909
new: 45.72636650048779
path: .spaces[0].metrics.mi.mi_original
old: 51.594886173608515
new: 75.44568091300675
path: .spaces[0].metrics.loc.sloc
old: 106.0
new: 39.0
path: .spaces[0].metrics.loc.cloc
old: 11.0
new: 1.0
path: .spaces[0].metrics.loc.ploc
old: 68.0
new: 27.0
path: .spaces[0].metrics.loc.blank
old: 27.0
new: 11.0
path: .spaces[0].metrics.loc.lloc
old: 8.0
new: 11.0
path: .spaces[0].metrics.nexits.average
old: 0.6363636363636364
new: 0.0
path: .spaces[0].metrics.nexits.sum
old: 7.0
new: 0.0
path: .spaces[0].metrics.halstead.vocabulary
old: 89.0
new: 39.0
path: .spaces[0].metrics.halstead.volume
old: 2169.3706993737433
new: 924.9453883008936
path: .spaces[0].metrics.halstead.bugs
old: 0.333602489192983
new: 0.2155465726673648
path: .spaces[0].metrics.halstead.n2
old: 74.0
new: 27.0
path: .spaces[0].metrics.halstead.length
old: 335.0
new: 175.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 518.1029079906701
new: 171.40151256706753
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.5465758447482691
new: 0.9794372146689572
path: .spaces[0].metrics.halstead.N2
old: 144.0
new: 80.0
path: .spaces[0].metrics.halstead.N1
old: 191.0
new: 95.0
path: .spaces[0].metrics.halstead.effort
old: 31661.08588275193
new: 16443.473569793663
path: .spaces[0].metrics.halstead.level
old: 0.06851851851851852
new: 0.056249999999999994
path: .spaces[0].metrics.halstead.time
old: 1758.9492157084403
new: 913.5263094329812
path: .spaces[0].metrics.halstead.n1
old: 15.0
new: 12.0
path: .spaces[0].metrics.halstead.difficulty
old: 14.594594594594597
new: 17.77777777777778
path: .spaces[0].metrics.nargs.average
old: 0.3636363636363637
new: 1.0
path: .spaces[0].metrics.nargs.sum
old: 4.0
new: 2.0
path: .spaces[0].metrics.nom.total
old: 11.0
new: 2.0
path: .spaces[0].metrics.nom.functions
old: 11.0
new: 2.0
path: .spaces[0].metrics.cyclomatic.sum
old: 17.0
new: 3.0
Code
namespace {
static void TestStringStream(uint32_t aNumBytes) {
nsTArray inputData;
testing::CreateData(aNumBytes, inputData);
nsDependentCSubstring inputString(inputData.Elements(), inputData.Length());
nsCOMPtr stream;
nsresult rv = NS_NewCStringInputStream(getter_AddRefs(stream), inputString);
ASSERT_TRUE(NS_SUCCEEDED(rv));
testing::ConsumeAndValidateStream(stream, inputString);
}
static void TestStringStreamClone(uint32_t aNumBytes) {
nsTArray inputData;
testing::CreateData(aNumBytes, inputData);
nsDependentCSubstring inputString(inputData.Elements(), inputData.Length());
nsCOMPtr stream;
nsresult rv = NS_NewCStringInputStream(getter_AddRefs(stream), inputString);
ASSERT_TRUE(NS_SUCCEEDED(rv));
nsCOMPtr cloneable = do_QueryInterface(stream);
ASSERT_TRUE(cloneable != nullptr);
ASSERT_TRUE(cloneable->GetCloneable());
nsCOMPtr clone;
rv = cloneable->Clone(getter_AddRefs(clone));
testing::ConsumeAndValidateStream(stream, inputString);
// Release the stream to verify that the clone's string survives correctly.
stream = nullptr;
testing::ConsumeAndValidateStream(clone, inputString);
}
} // namespace