Global Metrics
path: .metrics.nexits.average
old: 3.4
new: 0.75
path: .metrics.nexits.sum
old: 17.0
new: 3.0
path: .metrics.halstead.n2
old: 73.0
new: 29.0
path: .metrics.halstead.length
old: 638.0
new: 132.0
path: .metrics.halstead.volume
old: 4210.744393315387
new: 720.6449736601232
path: .metrics.halstead.n1
old: 24.0
new: 15.0
path: .metrics.halstead.N2
old: 261.0
new: 56.0
path: .metrics.halstead.difficulty
old: 42.9041095890411
new: 14.482758620689657
path: .metrics.halstead.bugs
old: 1.0652476713311445
new: 0.15919417826297502
path: .metrics.halstead.estimated_program_length
old: 561.896292815549
new: 199.48480779282735
path: .metrics.halstead.effort
old: 180658.23890224376
new: 10436.92720473282
path: .metrics.halstead.N1
old: 377.0
new: 76.0
path: .metrics.halstead.level
old: 0.023307790549169857
new: 0.06904761904761905
path: .metrics.halstead.purity_ratio
old: 0.8807151925008605
new: 1.5112485438850558
path: .metrics.halstead.time
old: 10036.56882790243
new: 579.8292891518233
path: .metrics.halstead.vocabulary
old: 97.0
new: 44.0
path: .metrics.loc.cloc
old: 10.0
new: 12.0
path: .metrics.loc.blank
old: 20.0
new: 8.0
path: .metrics.loc.sloc
old: 148.0
new: 57.0
path: .metrics.loc.ploc
old: 118.0
new: 37.0
path: .metrics.loc.lloc
old: 50.0
new: 6.0
path: .metrics.mi.mi_sei
old: 4.524481976836142
new: 56.77554779714938
path: .metrics.mi.mi_original
old: 39.97910858690544
new: 68.29580710065643
path: .metrics.mi.mi_visual_studio
old: 23.379595664856986
new: 39.93906847991604
path: .metrics.nom.total
old: 5.0
new: 4.0
path: .metrics.nom.functions
old: 5.0
new: 4.0
path: .metrics.nargs.sum
old: 14.0
new: 3.0
path: .metrics.nargs.average
old: 2.8
new: 0.75
path: .metrics.cognitive.sum
old: 25.0
new: 2.0
path: .metrics.cognitive.average
old: 5.0
new: 0.5
path: .metrics.cyclomatic.average
old: 4.142857142857143
new: 1.625
path: .metrics.cyclomatic.sum
old: 29.0
new: 13.0
Spaces Data
Minimal test - lines (14, 54)
path: .spaces[0].spaces[0].metrics.loc.lloc
old: 3.0
new: 6.0
path: .spaces[0].spaces[0].metrics.loc.ploc
old: 6.0
new: 30.0
path: .spaces[0].spaces[0].metrics.loc.sloc
old: 6.0
new: 41.0
path: .spaces[0].spaces[0].metrics.loc.blank
old: 0.0
new: 7.0
path: .spaces[0].spaces[0].metrics.loc.cloc
old: 0.0
new: 4.0
path: .spaces[0].spaces[0].metrics.mi.mi_original
old: 117.36266392297036
new: 74.46792116320904
path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: 93.8213209539836
new: 56.114825272991695
path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 68.6331367970587
new: 43.54849190830938
path: .spaces[0].spaces[0].metrics.nargs.average
old: 2.0
new: 0.75
path: .spaces[0].spaces[0].metrics.nargs.sum
old: 2.0
new: 3.0
path: .spaces[0].spaces[0].metrics.nexits.sum
old: 2.0
new: 3.0
path: .spaces[0].spaces[0].metrics.nexits.average
old: 2.0
new: 0.75
path: .spaces[0].spaces[0].metrics.halstead.volume
old: 104.0
new: 670.5629399558077
path: .spaces[0].spaces[0].metrics.halstead.level
old: 0.15
new: 0.06535947712418301
path: .spaces[0].spaces[0].metrics.halstead.n1
old: 10.0
new: 15.0
path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 48.72905595320056
new: 174.6997636784959
path: .spaces[0].spaces[0].metrics.halstead.effort
old: 693.3333333333334
new: 10259.61298132386
path: .spaces[0].spaces[0].metrics.halstead.n2
old: 6.0
new: 25.0
path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 16.0
new: 40.0
path: .spaces[0].spaces[0].metrics.halstead.N1
old: 18.0
new: 75.0
path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 1.874194459738483
new: 1.3865060609404438
path: .spaces[0].spaces[0].metrics.halstead.time
old: 38.51851851851852
new: 569.9784989624366
path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.026111999701497093
new: 0.15738598781776394
path: .spaces[0].spaces[0].metrics.halstead.length
old: 26.0
new: 126.0
path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 6.666666666666667
new: 15.3
path: .spaces[0].spaces[0].metrics.halstead.N2
old: 8.0
new: 51.0
path: .spaces[0].spaces[0].metrics.cyclomatic.average
old: 2.0
new: 1.8333333333333333
path: .spaces[0].spaces[0].metrics.cyclomatic.sum
old: 2.0
new: 11.0
path: .spaces[0].spaces[0].metrics.nom.total
old: 1.0
new: 4.0
path: .spaces[0].spaces[0].metrics.nom.functions
old: 1.0
new: 4.0
path: .spaces[0].spaces[0].metrics.cognitive.average
old: 1.0
new: 0.5
path: .spaces[0].spaces[0].metrics.cognitive.sum
old: 1.0
new: 2.0
Code
namespace widget {
// An Event subclass that guards against stale events.
// (See the implmentation of mozilla::jni::detail::ProxyNativeCall for info
// about the default template parameters for this class)
template
class WindowEvent : public Runnable {
bool IsStaleCall() {
if (IsStatic) {
// Static calls are never stale.
return false;
}
return jni::NativePtrTraits::IsStale(mInstance);
}
Lambda mLambda;
const InstanceType mInstance;
public:
WindowEvent(Lambda&& aLambda, InstanceType&& aInstance)
: Runnable("mozilla::widget::WindowEvent"),
mLambda(std::move(aLambda)),
mInstance(std::forward(aInstance)) {}
explicit WindowEvent(Lambda&& aLambda)
: Runnable("mozilla::widget::WindowEvent"),
mLambda(std::move(aLambda)),
mInstance(mLambda.GetThisArg()) {}
NS_IMETHOD Run() override {
if (!IsStaleCall()) {
mLambda();
}
return NS_OK;
}
};
} // namespace widget
Minimal test - lines (13, 55)
path: .spaces[0].metrics.cognitive.average
old: 5.0
new: 0.5
path: .spaces[0].metrics.cognitive.sum
old: 25.0
new: 2.0
path: .spaces[0].metrics.mi.mi_sei
old: -0.08306956680545952
new: 56.54434638340356
path: .spaces[0].metrics.mi.mi_visual_studio
old: 24.212152202205427
new: 42.89459856511224
path: .spaces[0].metrics.mi.mi_original
old: 41.40278026577128
new: 73.34976354634193
path: .spaces[0].metrics.nom.functions
old: 5.0
new: 4.0
path: .spaces[0].metrics.nom.total
old: 5.0
new: 4.0
path: .spaces[0].metrics.nargs.average
old: 2.8
new: 0.75
path: .spaces[0].metrics.nargs.sum
old: 14.0
new: 3.0
path: .spaces[0].metrics.halstead.effort
old: 184086.5642692024
new: 10286.49984886672
path: .spaces[0].metrics.halstead.estimated_program_length
old: 539.0889112034554
new: 180.8147916057962
path: .spaces[0].metrics.halstead.length
old: 635.0
new: 128.0
path: .spaces[0].metrics.halstead.volume
old: 4162.1639208153
new: 685.7666565911147
path: .spaces[0].metrics.halstead.time
old: 10227.031348289023
new: 571.472213825929
path: .spaces[0].metrics.halstead.difficulty
old: 44.22857142857143
new: 15.0
path: .spaces[0].metrics.halstead.bugs
old: 1.0786821037035677
new: 0.15766083704776007
path: .spaces[0].metrics.halstead.purity_ratio
old: 0.8489589152810321
new: 1.4126155594202827
path: .spaces[0].metrics.halstead.N1
old: 377.0
new: 76.0
path: .spaces[0].metrics.halstead.level
old: 0.02260981912144703
new: 0.06666666666666667
path: .spaces[0].metrics.halstead.vocabulary
old: 94.0
new: 41.0
path: .spaces[0].metrics.halstead.N2
old: 258.0
new: 52.0
path: .spaces[0].metrics.halstead.n1
old: 24.0
new: 15.0
path: .spaces[0].metrics.halstead.n2
old: 70.0
new: 26.0
path: .spaces[0].metrics.nexits.average
old: 3.4
new: 0.75
path: .spaces[0].metrics.nexits.sum
old: 17.0
new: 3.0
path: .spaces[0].metrics.loc.lloc
old: 50.0
new: 6.0
path: .spaces[0].metrics.loc.blank
old: 19.0
new: 6.0
path: .spaces[0].metrics.loc.cloc
old: 4.0
new: 5.0
path: .spaces[0].metrics.loc.sloc
old: 138.0
new: 43.0
path: .spaces[0].metrics.loc.ploc
old: 115.0
new: 32.0
path: .spaces[0].metrics.cyclomatic.average
old: 4.666666666666667
new: 1.7142857142857142
path: .spaces[0].metrics.cyclomatic.sum
old: 28.0
new: 12.0
Code
namespace mozilla {
namespace widget {
// An Event subclass that guards against stale events.
// (See the implmentation of mozilla::jni::detail::ProxyNativeCall for info
// about the default template parameters for this class)
template
class WindowEvent : public Runnable {
bool IsStaleCall() {
if (IsStatic) {
// Static calls are never stale.
return false;
}
return jni::NativePtrTraits::IsStale(mInstance);
}
Lambda mLambda;
const InstanceType mInstance;
public:
WindowEvent(Lambda&& aLambda, InstanceType&& aInstance)
: Runnable("mozilla::widget::WindowEvent"),
mLambda(std::move(aLambda)),
mInstance(std::forward(aInstance)) {}
explicit WindowEvent(Lambda&& aLambda)
: Runnable("mozilla::widget::WindowEvent"),
mLambda(std::move(aLambda)),
mInstance(mLambda.GetThisArg()) {}
NS_IMETHOD Run() override {
if (!IsStaleCall()) {
mLambda();
}
return NS_OK;
}
};
} // namespace widget
} // namespace mozilla