Global Metrics
path: .metrics.nexits.sum
old: 0.0
new: 152.0
path: .metrics.nexits.average
old: null
new: 1.7272727272727273
path: .metrics.cyclomatic.average
old: 1.0
new: 3.659340659340659
path: .metrics.cyclomatic.sum
old: 4.0
new: 333.0
path: .metrics.nom.functions
old: 0.0
new: 88.0
path: .metrics.nom.total
old: 0.0
new: 88.0
path: .metrics.mi.mi_sei
old: 100.84937904401647
new: -147.07776860454493
path: .metrics.mi.mi_visual_studio
old: 54.787543120392264
new: 0.0
path: .metrics.mi.mi_original
old: 93.68669873587078
new: -89.34177443486472
path: .metrics.nargs.sum
old: 0.0
new: 133.0
path: .metrics.nargs.average
old: null
new: 1.5113636363636365
path: .metrics.loc.sloc
old: 26.0
new: 2332.0
path: .metrics.loc.lloc
old: 1.0
new: 868.0
path: .metrics.loc.blank
old: 5.0
new: 469.0
path: .metrics.loc.ploc
old: 11.0
new: 1628.0
path: .metrics.loc.cloc
old: 10.0
new: 235.0
path: .metrics.cognitive.average
old: null
new: 3.7045454545454546
path: .metrics.cognitive.sum
old: 0.0
new: 326.0
path: .metrics.halstead.time
old: 18.23215611283975
new: 419525.0465188436
path: .metrics.halstead.volume
old: 93.76537429460444
new: 71588.3181808774
path: .metrics.halstead.length
old: 24.0
new: 7663.0
path: .metrics.halstead.vocabulary
old: 15.0
new: 649.0
path: .metrics.halstead.effort
old: 328.1788100311155
new: 7551450.837339185
path: .metrics.halstead.estimated_program_length
old: 44.82892142331043
new: 5846.308860300451
path: .metrics.halstead.purity_ratio
old: 1.867871725971268
new: 0.7629269033407869
path: .metrics.halstead.difficulty
old: 3.5
new: 105.48440065681444
path: .metrics.halstead.N1
old: 10.0
new: 4451.0
path: .metrics.halstead.n1
old: 5.0
new: 40.0
path: .metrics.halstead.n2
old: 10.0
new: 609.0
path: .metrics.halstead.N2
old: 14.0
new: 3212.0
path: .metrics.halstead.bugs
old: 0.0158593640802942
new: 12.830168050436829
path: .metrics.halstead.level
old: 0.2857142857142857
new: 0.009480074719800748
Spaces Data
Minimal test - lines (143, 173)
path: .spaces[2].metrics.halstead.bugs
old: 0.01034813093369748
new: 0.1480211503525243
path: .spaces[2].metrics.halstead.time
old: 9.609532273992492
new: 519.870338850015
path: .spaces[2].metrics.halstead.effort
old: 172.97158093186488
new: 9357.66609930027
path: .spaces[2].metrics.halstead.N2
old: 8.0
new: 66.0
path: .spaces[2].metrics.halstead.N1
old: 7.0
new: 77.0
path: .spaces[2].metrics.halstead.n1
old: 5.0
new: 13.0
path: .spaces[2].metrics.halstead.n2
old: 6.0
new: 37.0
path: .spaces[2].metrics.halstead.vocabulary
old: 11.0
new: 50.0
path: .spaces[2].metrics.halstead.volume
old: 51.89147427955946
new: 807.0714351377856
path: .spaces[2].metrics.halstead.estimated_program_length
old: 27.11941547876375
new: 240.85549086410535
path: .spaces[2].metrics.halstead.difficulty
old: 3.3333333333333335
new: 11.594594594594597
path: .spaces[2].metrics.halstead.length
old: 15.0
new: 143.0
path: .spaces[2].metrics.halstead.purity_ratio
old: 1.8079610319175832
new: 1.6843041319168206
path: .spaces[2].metrics.halstead.level
old: 0.3
new: 0.08624708624708624
path: .spaces[2].metrics.nargs.average
old: null
new: 0.0
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.nom.total
old: 0.0
new: 1.0
path: .spaces[2].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[2].metrics.nexits.average
old: null
new: 1.0
path: .spaces[2].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[2].metrics.cognitive.average
old: null
new: 1.0
path: .spaces[2].metrics.cognitive.sum
old: 0.0
new: 1.0
path: .spaces[2].metrics.mi.mi_visual_studio
old: 74.72305726660727
new: 46.84424791341786
path: .spaces[2].metrics.mi.mi_sei
old: 108.74338677859146
new: 66.47825859218572
path: .spaces[2].metrics.mi.mi_original
old: 127.77642792589845
new: 80.10366393194454
path: .spaces[2].metrics.loc.blank
old: 0.0
new: 1.0
path: .spaces[2].metrics.loc.sloc
old: 4.0
new: 31.0
path: .spaces[2].metrics.loc.cloc
old: 0.0
new: 4.0
path: .spaces[2].metrics.loc.lloc
old: 0.0
new: 12.0
path: .spaces[2].metrics.loc.ploc
old: 4.0
new: 26.0
Code
nsresult nsManifestCheck::Begin() {
nsresult rv;
mManifestHash = do_CreateInstance("@mozilla.org/security/hash;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = mManifestHash->Init(nsICryptoHash::MD5);
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewChannel(getter_AddRefs(mChannel), mURI, mLoadingPrincipal,
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED,
nsIContentPolicy::TYPE_OTHER, mUpdate->CookieJarSettings(),
nullptr, // PerformanceStorage
nullptr, // loadGroup
nullptr, // aCallbacks
nsIRequest::LOAD_BYPASS_CACHE);
NS_ENSURE_SUCCESS(rv, rv);
// configure HTTP specific stuff
nsCOMPtr httpChannel = do_QueryInterface(mChannel);
if (httpChannel) {
nsCOMPtr referrerInfo =
new mozilla::dom::ReferrerInfo(mReferrerURI);
rv = httpChannel->SetReferrerInfoWithoutClone(referrerInfo);
MOZ_ASSERT(NS_SUCCEEDED(rv));
rv =
httpChannel->SetRequestHeader("X-Moz"_ns, "offline-resource"_ns, false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
return mChannel->AsyncOpen(this);
}
Minimal test - lines (99, 131)
path: .spaces[1].metrics.mi.mi_original
old: null
new: 79.88470118456793
path: .spaces[1].metrics.mi.mi_sei
old: null
new: 39.8538698280735
path: .spaces[1].metrics.mi.mi_visual_studio
old: null
new: 46.71619952313914
path: .spaces[1].metrics.cognitive.average
old: null
new: 0.0
path: .spaces[1].metrics.cyclomatic.sum
old: 1.0
new: 3.0
path: .spaces[1].metrics.nargs.average
old: null
new: 2.0
path: .spaces[1].metrics.nargs.sum
old: 0.0
new: 4.0
path: .spaces[1].metrics.nom.total
old: 0.0
new: 2.0
path: .spaces[1].metrics.nom.functions
old: 0.0
new: 2.0
path: .spaces[1].metrics.nexits.average
old: null
new: 0.0
path: .spaces[1].metrics.halstead.vocabulary
old: 1.0
new: 46.0
path: .spaces[1].metrics.halstead.effort
old: 0.0
new: 5155.324492319879
path: .spaces[1].metrics.halstead.n2
old: 1.0
new: 36.0
path: .spaces[1].metrics.halstead.n1
old: 0.0
new: 10.0
path: .spaces[1].metrics.halstead.level
old: null
new: 0.1285714285714286
path: .spaces[1].metrics.halstead.N1
old: 0.0
new: 64.0
path: .spaces[1].metrics.halstead.N2
old: 1.0
new: 56.0
path: .spaces[1].metrics.halstead.difficulty
old: 0.0
new: 7.777777777777778
path: .spaces[1].metrics.halstead.purity_ratio
old: null
new: 1.827804841673307
path: .spaces[1].metrics.halstead.bugs
old: 0.0
new: 0.09947548902707166
path: .spaces[1].metrics.halstead.estimated_program_length
old: null
new: 219.33658100079683
path: .spaces[1].metrics.halstead.time
old: 0.0
new: 286.4069162399933
path: .spaces[1].metrics.halstead.length
old: 1.0
new: 120.0
path: .spaces[1].metrics.halstead.volume
old: 0.0
new: 662.8274347268416
path: .spaces[1].metrics.loc.sloc
old: 1.0
new: 33.0
path: .spaces[1].metrics.loc.blank
old: 0.0
new: 5.0
path: .spaces[1].metrics.loc.ploc
old: 1.0
new: 28.0
Code
class nsManifestCheck final : public nsIStreamListener,
public nsIChannelEventSink,
public nsIInterfaceRequestor {
public:
nsManifestCheck(nsOfflineCacheUpdate* aUpdate, nsIURI* aURI,
nsIURI* aReferrerURI, nsIPrincipal* aLoadingPrincipal)
: mUpdate(aUpdate),
mURI(aURI),
mReferrerURI(aReferrerURI),
mLoadingPrincipal(aLoadingPrincipal) {}
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSICHANNELEVENTSINK
NS_DECL_NSIINTERFACEREQUESTOR
nsresult Begin();
private:
~nsManifestCheck() {}
static nsresult ReadManifest(nsIInputStream* aInputStream, void* aClosure,
const char* aFromSegment, uint32_t aOffset,
uint32_t aCount, uint32_t* aBytesConsumed);
RefPtr mUpdate;
nsCOMPtr mURI;
nsCOMPtr mReferrerURI;
nsCOMPtr mLoadingPrincipal;
nsCOMPtr mManifestHash;
nsCOMPtr mChannel;
};
Minimal test - lines (69, 93)
path: .spaces[0].metrics.nom.total
old: 0.0
new: 2.0
path: .spaces[0].metrics.nom.functions
old: 0.0
new: 2.0
path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 6.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 2.0
path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[0].metrics.nexits.average
old: null
new: 0.5
path: .spaces[0].metrics.loc.sloc
old: 1.0
new: 25.0
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 3.0
path: .spaces[0].metrics.loc.ploc
old: 1.0
new: 20.0
path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 2.0
path: .spaces[0].metrics.loc.lloc
old: 0.0
new: 6.0
path: .spaces[0].metrics.mi.mi_original
old: null
new: 84.87050949439582
path: .spaces[0].metrics.mi.mi_sei
old: null
new: 68.56684748537869
path: .spaces[0].metrics.mi.mi_visual_studio
old: null
new: 49.63187689730749
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 4.0
path: .spaces[0].metrics.cognitive.average
old: null
new: 2.0
path: .spaces[0].metrics.nargs.sum
old: 0.0
new: 3.0
path: .spaces[0].metrics.nargs.average
old: null
new: 1.5
path: .spaces[0].metrics.halstead.length
old: 1.0
new: 98.0
path: .spaces[0].metrics.halstead.n1
old: 0.0
new: 15.0
path: .spaces[0].metrics.halstead.time
old: 0.0
new: 358.8221099849077
path: .spaces[0].metrics.halstead.N2
old: 1.0
new: 44.0
path: .spaces[0].metrics.halstead.difficulty
old: 0.0
new: 12.22222222222222
path: .spaces[0].metrics.halstead.estimated_program_length
old: null
new: 186.98532149254143
path: .spaces[0].metrics.halstead.bugs
old: 0.0
new: 0.11560586807076093
path: .spaces[0].metrics.halstead.volume
old: 0.0
new: 528.4471074323186
path: .spaces[0].metrics.halstead.n2
old: 1.0
new: 27.0
path: .spaces[0].metrics.halstead.effort
old: 0.0
new: 6458.797979728338
path: .spaces[0].metrics.halstead.level
old: null
new: 0.08181818181818182
path: .spaces[0].metrics.halstead.purity_ratio
old: null
new: 1.9080134846177697
path: .spaces[0].metrics.halstead.vocabulary
old: 1.0
new: 42.0
path: .spaces[0].metrics.halstead.N1
old: 0.0
new: 54.0
Code
namespace {
nsresult DropReferenceFromURL(nsCOMPtr& aURI) {
// XXXdholbert If this SetRef fails, callers of this method probably
// want to call aURI->CloneIgnoringRef() and use the result of that.
nsCOMPtr uri(aURI);
return NS_GetURIWithoutRef(uri, getter_AddRefs(aURI));
}
void LogToConsole(const char* message,
nsOfflineCacheUpdateItem* item = nullptr) {
nsCOMPtr consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
if (consoleService) {
nsAutoString messageUTF16 = NS_ConvertUTF8toUTF16(message);
if (item && item->mURI) {
messageUTF16.AppendLiteral(", URL=");
messageUTF16.Append(
NS_ConvertUTF8toUTF16(item->mURI->GetSpecOrDefault()));
}
consoleService->LogStringMessage(messageUTF16.get());
}
}
} // namespace