Global Metrics
path: .metrics.nargs.average
old: 3.4
new: 2.0
path: .metrics.nargs.sum
old: 17.0
new: 50.0
path: .metrics.nexits.sum
old: 0.0
new: 15.0
path: .metrics.nexits.average
old: 0.0
new: 0.6
path: .metrics.nom.closures
old: 0.0
new: 2.0
path: .metrics.nom.functions
old: 5.0
new: 23.0
path: .metrics.nom.total
old: 5.0
new: 25.0
path: .metrics.cognitive.average
old: 0.8
new: 0.08
path: .metrics.cognitive.sum
old: 4.0
new: 2.0
path: .metrics.cyclomatic.average
old: 2.0
new: 1.1153846153846154
path: .metrics.cyclomatic.sum
old: 12.0
new: 29.0
path: .metrics.halstead.time
old: 3875.71179410116
new: 41295.406909827085
path: .metrics.halstead.vocabulary
old: 94.0
new: 154.0
path: .metrics.halstead.n2
old: 79.0
new: 128.0
path: .metrics.halstead.length
old: 505.0
new: 1540.0
path: .metrics.halstead.n1
old: 15.0
new: 26.0
path: .metrics.halstead.level
old: 0.04744744744744744
new: 0.015055281110326982
path: .metrics.halstead.purity_ratio
old: 1.10218225354479
new: 0.6611762549816028
path: .metrics.halstead.bugs
old: 0.5648867634620401
new: 2.735236701768442
path: .metrics.halstead.effort
old: 69762.81229382088
new: 743317.3243768875
path: .metrics.halstead.N1
old: 283.0
new: 886.0
path: .metrics.halstead.estimated_program_length
old: 556.6020380401189
new: 1018.2114326716684
path: .metrics.halstead.difficulty
old: 21.075949367088608
new: 66.421875
path: .metrics.halstead.volume
old: 3310.067370097207
new: 11190.851272670148
path: .metrics.halstead.N2
old: 222.0
new: 654.0
path: .metrics.loc.sloc
old: 95.0
new: 376.0
path: .metrics.loc.cloc
old: 16.0
new: 40.0
path: .metrics.loc.ploc
old: 71.0
new: 268.0
path: .metrics.loc.blank
old: 8.0
new: 68.0
path: .metrics.loc.lloc
old: 40.0
new: 108.0
path: .metrics.mi.mi_sei
old: 30.696670559658813
new: -19.991395190640645
path: .metrics.mi.mi_visual_studio
old: 30.59802952245576
new: 11.574167332395664
path: .metrics.mi.mi_original
old: 52.32263048339935
new: 19.791826138396587
Spaces Data
Minimal test - lines (67, 75)
path: .spaces[2].metrics.halstead.N2
old: 33.0
new: 27.0
path: .spaces[2].metrics.halstead.bugs
old: 0.09197083824485829
new: 0.08469324259929253
path: .spaces[2].metrics.halstead.time
old: 254.6153568622745
new: 225.0
path: .spaces[2].metrics.halstead.estimated_program_length
old: 112.50641830990963
new: 128.09022723538357
path: .spaces[2].metrics.halstead.N1
old: 48.0
new: 41.0
path: .spaces[2].metrics.halstead.difficulty
old: 11.647058823529411
new: 11.911764705882351
path: .spaces[2].metrics.halstead.level
old: 0.08585858585858586
new: 0.08395061728395062
path: .spaces[2].metrics.halstead.volume
old: 393.4964606053333
new: 340.0
path: .spaces[2].metrics.halstead.effort
old: 4583.076423520941
new: 4050.0
path: .spaces[2].metrics.halstead.purity_ratio
old: 1.388968127282835
new: 1.8836798122850524
path: .spaces[2].metrics.halstead.vocabulary
old: 29.0
new: 32.0
path: .spaces[2].metrics.halstead.length
old: 81.0
new: 68.0
path: .spaces[2].metrics.halstead.n1
old: 12.0
new: 15.0
path: .spaces[2].metrics.mi.mi_original
old: 97.9174456286532
new: 104.63444463558017
path: .spaces[2].metrics.mi.mi_visual_studio
old: 57.26166411032351
new: 61.18973370501763
path: .spaces[2].metrics.mi.mi_sei
old: 94.31452442510714
new: 75.4583821087185
path: .spaces[2].metrics.nargs.average
old: 2.0
new: 6.0
path: .spaces[2].metrics.nargs.sum
old: 2.0
new: 6.0
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.cloc
old: 2.0
new: 0.0
path: .spaces[2].metrics.loc.sloc
old: 13.0
new: 9.0
path: .spaces[2].metrics.loc.lloc
old: 4.0
new: 5.0
path: .spaces[2].metrics.loc.ploc
old: 12.0
new: 9.0
Code
static nsresult ReadSegmentsFunction(nsIInputStream* aInStr, void* aClosure,
const char* aBuffer, uint32_t aOffset,
uint32_t aCount, uint32_t* aCountWritten) {
ReadSegmentsData* data = static_cast(aClosure);
if (aInStr != data->mStream) return NS_ERROR_FAILURE;
memcpy(&data->mBuffer[aOffset], aBuffer, aCount);
*aCountWritten = aCount;
return NS_OK;
}
Minimal test - lines (77, 101)
path: .spaces[3].metrics.halstead.length
old: 72.0
new: 114.0
path: .spaces[3].metrics.halstead.N2
old: 32.0
new: 53.0
path: .spaces[3].metrics.halstead.estimated_program_length
old: 82.60335893412778
new: 187.90890672641936
path: .spaces[3].metrics.halstead.purity_ratio
old: 1.147268874085108
new: 1.6483237432142048
path: .spaces[3].metrics.halstead.difficulty
old: 8.533333333333333
new: 13.25
path: .spaces[3].metrics.halstead.n1
old: 8.0
new: 14.0
path: .spaces[3].metrics.halstead.volume
old: 325.69646083610496
new: 614.7241861967788
path: .spaces[3].metrics.halstead.level
old: 0.1171875
new: 0.07547169811320754
path: .spaces[3].metrics.halstead.bugs
old: 0.06589208427946382
new: 0.13494067075355975
path: .spaces[3].metrics.halstead.time
old: 154.40424810007937
new: 452.50530372818434
path: .spaces[3].metrics.halstead.vocabulary
old: 23.0
new: 42.0
path: .spaces[3].metrics.halstead.n2
old: 15.0
new: 28.0
path: .spaces[3].metrics.halstead.N1
old: 40.0
new: 61.0
path: .spaces[3].metrics.halstead.effort
old: 2779.276465801429
new: 8145.095467107319
path: .spaces[3].metrics.nargs.sum
old: 4.0
new: 2.0
path: .spaces[3].metrics.nargs.average
old: 4.0
new: 2.0
path: .spaces[3].metrics.mi.mi_visual_studio
old: 58.729526242569264
new: 49.84450786656807
path: .spaces[3].metrics.mi.mi_original
old: 100.42748987479344
new: 85.2341084518314
path: .spaces[3].metrics.mi.mi_sei
old: 98.84356533944744
new: 72.93105419166835
path: .spaces[3].metrics.loc.lloc
old: 7.0
new: 6.0
path: .spaces[3].metrics.loc.sloc
old: 12.0
new: 25.0
path: .spaces[3].metrics.loc.cloc
old: 2.0
new: 3.0
path: .spaces[3].metrics.loc.ploc
old: 10.0
new: 19.0
path: .spaces[3].metrics.loc.blank
old: 0.0
new: 3.0
Code
TEST(TestNonBlockingAsyncInputStream, ReadSegments)
{
nsCString data;
data.Assign("Hello world!");
nsCOMPtr async;
{
// Let's create a test string inputStream
nsCOMPtr stream;
ASSERT_EQ(NS_OK, NS_NewCStringInputStream(getter_AddRefs(stream), data));
// Here the non-blocking stream.
ASSERT_EQ(NS_OK, NonBlockingAsyncInputStream::Create(
stream.forget(), getter_AddRefs(async)));
}
// Read works fine.
char buffer[1024];
uint32_t read = 0;
ReadSegmentsData closure(async, buffer);
ASSERT_EQ(NS_OK, async->ReadSegments(ReadSegmentsFunction, &closure,
sizeof(buffer), &read));
ASSERT_EQ(data.Length(), read);
ASSERT_TRUE(data.Equals(nsCString(buffer, read)));
}
Minimal test - lines (58, 65)
path: .spaces[1].metrics.nargs.average
old: 7.0
new: 2.0
path: .spaces[1].metrics.nargs.sum
old: 7.0
new: 2.0
path: .spaces[1].metrics.cognitive.average
old: 2.0
new: 0.0
path: .spaces[1].metrics.cognitive.sum
old: 2.0
new: 0.0
path: .spaces[1].metrics.mi.mi_original
old: 80.42372991864767
new: 112.53916010114216
path: .spaces[1].metrics.mi.mi_visual_studio
old: 47.03142100505712
new: 65.81237432815331
path: .spaces[1].metrics.mi.mi_sei
old: 65.52270586879243
new: 86.86247591052307
path: .spaces[1].metrics.loc.lloc
old: 14.0
new: 0.0
path: .spaces[1].metrics.loc.sloc
old: 27.0
new: 8.0
path: .spaces[1].metrics.loc.cloc
old: 3.0
new: 0.0
path: .spaces[1].metrics.loc.ploc
old: 24.0
new: 7.0
path: .spaces[1].metrics.loc.blank
old: 0.0
new: 1.0
path: .spaces[1].metrics.cyclomatic.sum
old: 5.0
new: 2.0
path: .spaces[1].metrics.cyclomatic.average
old: 5.0
new: 1.0
path: .spaces[1].metrics.halstead.n2
old: 34.0
new: 6.0
path: .spaces[1].metrics.halstead.N1
old: 103.0
new: 17.0
path: .spaces[1].metrics.halstead.purity_ratio
old: 1.2015187659692703
new: 1.2124572227148334
path: .spaces[1].metrics.halstead.bugs
old: 0.21012200927356575
new: 0.027545140571351757
path: .spaces[1].metrics.halstead.length
old: 184.0
new: 29.0
path: .spaces[1].metrics.halstead.estimated_program_length
old: 221.07945293834572
new: 35.161259458730164
path: .spaces[1].metrics.halstead.vocabulary
old: 47.0
new: 13.0
path: .spaces[1].metrics.halstead.level
old: 0.06457739791073125
new: 0.14285714285714285
path: .spaces[1].metrics.halstead.difficulty
old: 15.485294117647058
new: 7.0
path: .spaces[1].metrics.halstead.volume
old: 1022.0443487086852
new: 107.31275182609168
path: .spaces[1].metrics.halstead.effort
old: 15826.657341033024
new: 751.1892627826417
path: .spaces[1].metrics.halstead.time
old: 879.2587411685013
new: 41.73273682125787
path: .spaces[1].metrics.halstead.N2
old: 81.0
new: 12.0
path: .spaces[1].metrics.halstead.n1
old: 13.0
new: 7.0
Code
class ReadSegmentsData {
public:
ReadSegmentsData(nsIInputStream* aStream, char* aBuffer)
: mStream(aStream), mBuffer(aBuffer) {}
nsIInputStream* mStream;
char* mBuffer;
};
Minimal test - lines (103, 146)
path: .spaces[4].metrics.mi.mi_visual_studio
old: 66.27126771560744
new: 42.128952067060595
path: .spaces[4].metrics.mi.mi_sei
old: 87.89274994770298
new: 55.40245041443339
path: .spaces[4].metrics.mi.mi_original
old: 113.32386779368872
new: 72.04050803467362
path: .spaces[4].metrics.nargs.sum
old: 1.0
new: 2.0
path: .spaces[4].metrics.nom.total
old: 1.0
new: 2.0
path: .spaces[4].metrics.nom.closures
old: 0.0
new: 1.0
path: .spaces[4].metrics.loc.sloc
old: 6.0
new: 44.0
path: .spaces[4].metrics.loc.blank
old: 0.0
new: 8.0
path: .spaces[4].metrics.loc.ploc
old: 6.0
new: 30.0
path: .spaces[4].metrics.loc.cloc
old: 0.0
new: 6.0
path: .spaces[4].metrics.loc.lloc
old: 4.0
new: 17.0
path: .spaces[4].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[4].metrics.nexits.average
old: 0.0
new: 0.5
path: .spaces[4].metrics.halstead.volume
old: 236.34987578777677
new: 1335.7318132437258
path: .spaces[4].metrics.halstead.bugs
old: 0.05080584308313289
new: 0.3080971477192638
path: .spaces[4].metrics.halstead.level
old: 0.12560386473429952
new: 0.047534165181224
path: .spaces[4].metrics.halstead.estimated_program_length
old: 76.63504134881501
new: 282.3639920967503
path: .spaces[4].metrics.halstead.N2
old: 23.0
new: 99.0
path: .spaces[4].metrics.halstead.N1
old: 30.0
new: 130.0
path: .spaces[4].metrics.halstead.n1
old: 9.0
new: 17.0
path: .spaces[4].metrics.halstead.length
old: 53.0
new: 229.0
path: .spaces[4].metrics.halstead.time
old: 104.53936813690126
new: 1561.1365567286043
path: .spaces[4].metrics.halstead.n2
old: 13.0
new: 40.0
path: .spaces[4].metrics.halstead.purity_ratio
old: 1.445944176392736
new: 1.233030533173582
path: .spaces[4].metrics.halstead.vocabulary
old: 22.0
new: 57.0
path: .spaces[4].metrics.halstead.difficulty
old: 7.961538461538462
new: 21.0375
path: .spaces[4].metrics.halstead.effort
old: 1881.7086264642228
new: 28100.45802111488
Code
TEST(TestNonBlockingAsyncInputStream, AsyncWait_Simple)
{
nsCString data;
data.Assign("Hello world!");
nsCOMPtr async;
{
// Let's create a test string inputStream
nsCOMPtr stream;
ASSERT_EQ(NS_OK, NS_NewCStringInputStream(getter_AddRefs(stream), data));
// Here the non-blocking stream.
ASSERT_EQ(NS_OK, NonBlockingAsyncInputStream::Create(
stream.forget(), getter_AddRefs(async)));
}
ASSERT_TRUE(!!async);
// Testing ::Available()
uint64_t length;
ASSERT_EQ(NS_OK, async->Available(&length));
ASSERT_EQ(data.Length(), length);
// Testing ::AsyncWait - without EventTarget
RefPtr cb = new testing::InputStreamCallback();
ASSERT_EQ(NS_OK, async->AsyncWait(cb, 0, 0, nullptr));
ASSERT_TRUE(cb->Called());
// Testing ::AsyncWait - with EventTarget
cb = new testing::InputStreamCallback();
nsCOMPtr thread = do_GetCurrentThread();
ASSERT_EQ(NS_OK, async->AsyncWait(cb, 0, 0, thread));
ASSERT_FALSE(cb->Called());
MOZ_ALWAYS_TRUE(SpinEventLoopUntil([&]() { return cb->Called(); }));
ASSERT_TRUE(cb->Called());
// Read works fine.
char buffer[1024];
uint32_t read = 0;
ASSERT_EQ(NS_OK, async->Read(buffer, sizeof(buffer), &read));
ASSERT_EQ(data.Length(), read);
ASSERT_TRUE(data.Equals(nsCString(buffer, read)));
}
Minimal test - lines (14, 56)
path: .spaces[0].metrics.nargs.sum
old: 3.0
new: 2.0
path: .spaces[0].metrics.nargs.average
old: 3.0
new: 2.0
path: .spaces[0].metrics.cognitive.average
old: 1.0
new: 0.0
path: .spaces[0].metrics.cognitive.sum
old: 1.0
new: 0.0
path: .spaces[0].metrics.halstead.n2
old: 19.0
new: 33.0
path: .spaces[0].metrics.halstead.length
old: 112.0
new: 180.0
path: .spaces[0].metrics.halstead.time
old: 441.9071062711766
new: 1040.8339205889429
path: .spaces[0].metrics.halstead.bugs
old: 0.13282538161303867
new: 0.2351336074584321
path: .spaces[0].metrics.halstead.level
old: 0.06909090909090909
new: 0.05365853658536585
path: .spaces[0].metrics.halstead.N2
old: 50.0
new: 82.0
path: .spaces[0].metrics.halstead.effort
old: 7954.327912881178
new: 18735.01057060097
path: .spaces[0].metrics.halstead.n1
old: 11.0
new: 15.0
path: .spaces[0].metrics.halstead.N1
old: 62.0
new: 98.0
path: .spaces[0].metrics.halstead.vocabulary
old: 30.0
new: 48.0
path: .spaces[0].metrics.halstead.volume
old: 549.5717467081541
new: 1005.293250129808
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.0603961657181995
new: 1.2503798048497596
path: .spaces[0].metrics.halstead.difficulty
old: 14.473684210526317
new: 18.636363636363637
path: .spaces[0].metrics.halstead.estimated_program_length
old: 118.76437056043838
new: 225.06836487295675
path: .spaces[0].metrics.loc.sloc
old: 21.0
new: 43.0
path: .spaces[0].metrics.loc.cloc
old: 3.0
new: 7.0
path: .spaces[0].metrics.loc.blank
old: 2.0
new: 8.0
path: .spaces[0].metrics.loc.ploc
old: 16.0
new: 28.0
path: .spaces[0].metrics.loc.lloc
old: 11.0
new: 15.0
path: .spaces[0].metrics.mi.mi_visual_studio
old: 51.70246314589086
new: 43.2109815008314
path: .spaces[0].metrics.mi.mi_sei
old: 79.68568194865762
new: 60.26004832292654
path: .spaces[0].metrics.mi.mi_original
old: 88.41121197947336
new: 73.8907783664217
path: .spaces[0].metrics.cyclomatic.sum
old: 2.0
new: 1.0
path: .spaces[0].metrics.cyclomatic.average
old: 2.0
new: 1.0
Code
TEST(TestNonBlockingAsyncInputStream, Simple)
{
nsCString data;
data.Assign("Hello world!");
// It should not be async.
bool nonBlocking = false;
nsCOMPtr async;
{
// Let's create a test string inputStream
nsCOMPtr stream;
ASSERT_EQ(NS_OK, NS_NewCStringInputStream(getter_AddRefs(stream), data));
async = do_QueryInterface(stream);
ASSERT_EQ(nullptr, async);
// It must be non-blocking
ASSERT_EQ(NS_OK, stream->IsNonBlocking(&nonBlocking));
ASSERT_TRUE(nonBlocking);
// Here the non-blocking stream.
ASSERT_EQ(NS_OK, NonBlockingAsyncInputStream::Create(
stream.forget(), getter_AddRefs(async)));
}
ASSERT_TRUE(!!async);
// Still non-blocking
ASSERT_EQ(NS_OK, async->IsNonBlocking(&nonBlocking));
ASSERT_TRUE(nonBlocking);
// Testing ::Available()
uint64_t length;
ASSERT_EQ(NS_OK, async->Available(&length));
ASSERT_EQ(data.Length(), length);
// Read works fine.
char buffer[1024];
uint32_t read = 0;
ASSERT_EQ(NS_OK, async->Read(buffer, sizeof(buffer), &read));
ASSERT_EQ(data.Length(), read);
ASSERT_TRUE(data.Equals(nsCString(buffer, read)));
}