Global Metrics
path: .metrics.cyclomatic.average
old: 7.0
new: 5.285714285714286
path: .metrics.cyclomatic.sum
old: 28.0
new: 37.0
path: .metrics.mi.mi_sei
old: 26.405526642177463
new: -17.353038359561175
path: .metrics.mi.mi_original
old: 48.55301690639452
new: 22.91395441740066
path: .metrics.mi.mi_visual_studio
old: 28.393577138242406
new: 13.399973343509158
path: .metrics.nom.closures
old: 0.0
new: 3.0
path: .metrics.nom.functions
old: 3.0
new: 6.0
path: .metrics.nom.total
old: 3.0
new: 9.0
path: .metrics.nexits.average
old: 0.6666666666666666
new: 1.1111111111111112
path: .metrics.nexits.sum
old: 2.0
new: 10.0
path: .metrics.halstead.estimated_program_length
old: 382.46581253703624
new: 1666.8950173564417
path: .metrics.halstead.time
old: 4361.303287695652
new: 16793.721431724014
path: .metrics.halstead.n1
old: 27.0
new: 30.0
path: .metrics.halstead.effort
old: 78503.45917852173
new: 302286.9857710322
path: .metrics.halstead.difficulty
old: 37.858695652173914
new: 35.80402010050251
path: .metrics.halstead.length
old: 335.0
new: 1077.0
path: .metrics.halstead.bugs
old: 0.6111361040048781
new: 1.5013837533609542
path: .metrics.halstead.n2
old: 46.0
new: 199.0
path: .metrics.halstead.vocabulary
old: 73.0
new: 229.0
path: .metrics.halstead.N1
old: 206.0
new: 602.0
path: .metrics.halstead.N2
old: 129.0
new: 475.0
path: .metrics.halstead.level
old: 0.02641401091013494
new: 0.02792982456140351
path: .metrics.halstead.volume
old: 2073.591227224806
new: 8442.822479780409
path: .metrics.halstead.purity_ratio
old: 1.1416889926478693
new: 1.5477205360784043
path: .metrics.loc.blank
old: 19.0
new: 40.0
path: .metrics.loc.ploc
old: 74.0
new: 238.0
path: .metrics.loc.cloc
old: 18.0
new: 25.0
path: .metrics.loc.lloc
old: 40.0
new: 83.0
path: .metrics.loc.sloc
old: 111.0
new: 303.0
path: .metrics.nargs.sum
old: 2.0
new: 11.0
path: .metrics.nargs.average
old: 0.6666666666666666
new: 1.2222222222222223
path: .metrics.cognitive.sum
old: 28.0
new: 37.0
path: .metrics.cognitive.average
old: 9.333333333333334
new: 4.111111111111111
Spaces Data
Minimal test - lines (61, 75)
path: .spaces[1].metrics.cognitive.average
old: 0.0
new: 3.0
path: .spaces[1].metrics.cognitive.sum
old: 0.0
new: 3.0
path: .spaces[1].metrics.cyclomatic.average
old: 1.0
new: 4.0
path: .spaces[1].metrics.cyclomatic.sum
old: 1.0
new: 4.0
path: .spaces[1].metrics.halstead.level
old: 0.2857142857142857
new: 0.1944444444444444
path: .spaces[1].metrics.halstead.n2
old: 2.0
new: 7.0
path: .spaces[1].metrics.halstead.difficulty
old: 3.5
new: 5.142857142857143
path: .spaces[1].metrics.halstead.bugs
old: 0.007174392059877131
new: 0.025905120023054454
path: .spaces[1].metrics.halstead.length
old: 9.0
new: 36.0
path: .spaces[1].metrics.halstead.volume
old: 28.52932501298081
new: 133.21582985307933
path: .spaces[1].metrics.halstead.purity_ratio
old: 2.405720494933692
new: 0.9767016516313934
path: .spaces[1].metrics.halstead.effort
old: 99.85263754543284
new: 685.1099821015508
path: .spaces[1].metrics.halstead.vocabulary
old: 9.0
new: 13.0
path: .spaces[1].metrics.halstead.n1
old: 7.0
new: 6.0
path: .spaces[1].metrics.halstead.N1
old: 7.0
new: 24.0
path: .spaces[1].metrics.halstead.time
old: 5.547368752524046
new: 38.06166567230838
path: .spaces[1].metrics.halstead.N2
old: 2.0
new: 12.0
path: .spaces[1].metrics.halstead.estimated_program_length
old: 21.651484454403228
new: 35.161259458730164
path: .spaces[1].metrics.loc.sloc
old: 4.0
new: 15.0
path: .spaces[1].metrics.loc.ploc
old: 4.0
new: 13.0
path: .spaces[1].metrics.loc.blank
old: 0.0
new: 2.0
path: .spaces[1].metrics.loc.lloc
old: 1.0
new: 8.0
path: .spaces[1].metrics.mi.mi_sei
old: 113.23125671373975
new: 70.08873942882843
path: .spaces[1].metrics.mi.mi_original
old: 130.88718231816625
new: 100.77133965445762
path: .spaces[1].metrics.mi.mi_visual_studio
old: 76.54221188196857
new: 58.93060798506294
path: .spaces[1].metrics.nexits.average
old: 1.0
new: 0.0
path: .spaces[1].metrics.nexits.sum
old: 1.0
new: 0.0
Code
nsDeviceContextSpecX::~nsDeviceContextSpecX() {
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
if (mPrintSession) {
::PMRelease(mPrintSession);
}
if (mPageFormat) {
::PMRelease(mPageFormat);
}
if (mPrintSettings) {
::PMRelease(mPrintSettings);
}
NS_OBJC_END_TRY_IGNORE_BLOCK;
}
Minimal test - lines (50, 59)
path: .spaces[0].metrics.halstead.estimated_program_length
old: 8.0
new: 35.60964047443681
path: .spaces[0].metrics.halstead.N2
old: 1.0
new: 10.0
path: .spaces[0].metrics.halstead.length
old: 5.0
new: 21.0
path: .spaces[0].metrics.halstead.N1
old: 4.0
new: 11.0
path: .spaces[0].metrics.halstead.n1
old: 4.0
new: 5.0
path: .spaces[0].metrics.halstead.volume
old: 11.60964047443681
new: 77.70923408096293
path: .spaces[0].metrics.halstead.vocabulary
old: 5.0
new: 13.0
path: .spaces[0].metrics.halstead.n2
old: 1.0
new: 8.0
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.6
new: 1.6956971654493718
path: .spaces[0].metrics.halstead.bugs
old: 0.002712967490108627
new: 0.012974596048359972
path: .spaces[0].metrics.halstead.difficulty
old: 2.0
new: 3.125
path: .spaces[0].metrics.halstead.effort
old: 23.21928094887362
new: 242.84135650300917
path: .spaces[0].metrics.halstead.level
old: 0.5
new: 0.32
path: .spaces[0].metrics.halstead.time
old: 1.289960052715201
new: 13.491186472389398
path: .spaces[0].metrics.loc.sloc
old: 4.0
new: 10.0
path: .spaces[0].metrics.loc.cloc
old: 1.0
new: 0.0
path: .spaces[0].metrics.loc.ploc
old: 3.0
new: 10.0
path: .spaces[0].metrics.mi.mi_original
old: 135.56248504247483
new: 110.83265620961984
path: .spaces[0].metrics.mi.mi_visual_studio
old: 79.27630704238294
new: 64.81441883603499
path: .spaces[0].metrics.mi.mi_sei
old: 154.9476862919269
new: 84.29869134956165
Code
nsDeviceContextSpecX::nsDeviceContextSpecX()
: mPrintSession(nullptr),
mPageFormat(nullptr),
mPrintSettings(nullptr)
#ifdef MOZ_ENABLE_SKIA_PDF
,
mPrintViaSkPDF(false)
#endif
{
}
Minimal test - lines (79, 164)
path: .spaces[2].metrics.loc.cloc
old: 9.0
new: 12.0
path: .spaces[2].metrics.loc.ploc
old: 60.0
new: 66.0
path: .spaces[2].metrics.loc.blank
old: 11.0
new: 8.0
path: .spaces[2].metrics.loc.sloc
old: 80.0
new: 86.0
path: .spaces[2].metrics.loc.lloc
old: 39.0
new: 32.0
path: .spaces[2].metrics.nargs.average
old: 2.0
new: 1.5
path: .spaces[2].metrics.nargs.sum
old: 2.0
new: 3.0
path: .spaces[2].metrics.nexits.average
old: 1.0
new: 1.5
path: .spaces[2].metrics.nexits.sum
old: 1.0
new: 3.0
path: .spaces[2].metrics.cyclomatic.average
old: 25.0
new: 17.0
path: .spaces[2].metrics.cyclomatic.sum
old: 25.0
new: 17.0
path: .spaces[2].metrics.halstead.time
old: 4118.803418803418
new: 2953.8129922303233
path: .spaces[2].metrics.halstead.n2
old: 39.0
new: 75.0
path: .spaces[2].metrics.halstead.difficulty
old: 39.1025641025641
new: 22.44
path: .spaces[2].metrics.halstead.vocabulary
old: 64.0
new: 97.0
path: .spaces[2].metrics.halstead.effort
old: 74138.46153846153
new: 53168.63386014582
path: .spaces[2].metrics.halstead.level
old: 0.02557377049180328
new: 0.044563279857397504
path: .spaces[2].metrics.halstead.bugs
old: 0.5882669619679697
new: 0.4713198668014864
path: .spaces[2].metrics.halstead.N2
old: 122.0
new: 153.0
path: .spaces[2].metrics.halstead.volume
old: 1896.0
new: 2369.368710345179
path: .spaces[2].metrics.halstead.estimated_program_length
old: 322.2270912799958
new: 565.2688973972116
path: .spaces[2].metrics.halstead.N1
old: 194.0
new: 206.0
path: .spaces[2].metrics.halstead.n1
old: 25.0
new: 22.0
path: .spaces[2].metrics.halstead.purity_ratio
old: 1.019705985063278
new: 1.574565173808389
path: .spaces[2].metrics.halstead.length
old: 316.0
new: 359.0
path: .spaces[2].metrics.cognitive.sum
old: 28.0
new: 24.0
path: .spaces[2].metrics.cognitive.average
old: 28.0
new: 12.0
path: .spaces[2].metrics.mi.mi_visual_studio
old: 32.17202325593292
new: 31.885148465398323
path: .spaces[2].metrics.mi.mi_sei
old: 31.040610015365292
new: 32.03746162286034
path: .spaces[2].metrics.mi.mi_original
old: 55.014159767645296
new: 54.52360387583113
path: .spaces[2].metrics.nom.closures
old: 0.0
new: 1.0
path: .spaces[2].metrics.nom.total
old: 1.0
new: 2.0
Code
NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIWidget* aWidget, nsIPrintSettings* aPS,
bool aIsPrintPreview) {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
RefPtr settings(do_QueryObject(aPS));
if (!settings) {
return NS_ERROR_NO_INTERFACE;
}
bool toFile;
settings->GetPrintToFile(&toFile);
NSPrintInfo* printInfo = settings->CreateOrCopyPrintInfo();
if (!printInfo) {
return NS_ERROR_FAILURE;
}
mPrintSession = static_cast([printInfo PMPrintSession]);
mPageFormat = static_cast([printInfo PMPageFormat]);
mPrintSettings = static_cast([printInfo PMPrintSettings]);
MOZ_ASSERT(mPrintSession && mPageFormat && mPrintSettings);
::PMRetain(mPrintSession);
::PMRetain(mPageFormat);
::PMRetain(mPrintSettings);
[printInfo release];
#ifdef MOZ_ENABLE_SKIA_PDF
nsAutoString printViaPdf;
mozilla::Preferences::GetString("print.print_via_pdf_encoder", printViaPdf);
if (printViaPdf.EqualsLiteral("skia-pdf")) {
// Annoyingly, PMPrinterPrintWithFile does not pay attention to the
// kPMDestination* value set in the PMPrintSession; it always sends the PDF
// to the specified printer. This means that if we create the PDF using
// SkPDF then we need to manually handle user actions like "Open PDF in
// Preview" and "Save as PDF...".
// TODO: Currently we do not support using SkPDF for kPMDestinationFax or
// kPMDestinationProcessPDF ("Add PDF to iBooks, etc.), and we only support
// it for kPMDestinationFile if the destination file is a PDF.
// XXX Could PMWorkflowSubmitPDFWithSettings/PMPrinterPrintWithProvider help?
OSStatus status = noErr;
PMDestinationType destination;
status = ::PMSessionGetDestinationType(mPrintSession, mPrintSettings, &destination);
if (status == noErr) {
if (destination == kPMDestinationPrinter || destination == kPMDestinationPreview) {
mPrintViaSkPDF = true;
} else if (destination == kPMDestinationFile) {
AutoCFRelease destURL(nullptr);
status =
::PMSessionCopyDestinationLocation(mPrintSession, mPrintSettings, destURL.receive());
if (status == noErr) {
AutoCFRelease destPathRef =
CFURLCopyFileSystemPath(destURL, kCFURLPOSIXPathStyle);
NSString* destPath = (NSString*)CFStringRef(destPathRef);
NSString* destPathExt = [destPath pathExtension];
if ([destPathExt isEqualToString:@"pdf"]) {
mPrintViaSkPDF = true;
}
}
}
}
}
#endif
int16_t outputFormat;
aPS->GetOutputFormat(&outputFormat);
if (outputFormat == nsIPrintSettings::kOutputFormatPDF) {
// We don't actually currently support/use kOutputFormatPDF on mac, but
// this is for completeness in case we add that (we probably need to in
// order to support adding links into saved PDFs, for example).
Telemetry::ScalarAdd(Telemetry::ScalarID::PRINTING_TARGET_TYPE, u"pdf_file"_ns, 1);
} else {
PMDestinationType destination;
OSStatus status = ::PMSessionGetDestinationType(mPrintSession, mPrintSettings, &destination);
if (status == noErr &&
(destination == kPMDestinationFile || destination == kPMDestinationPreview ||
destination == kPMDestinationProcessPDF)) {
Telemetry::ScalarAdd(Telemetry::ScalarID::PRINTING_TARGET_TYPE, u"pdf_file"_ns, 1);
} else {
Telemetry::ScalarAdd(Telemetry::ScalarID::PRINTING_TARGET_TYPE, u"unknown"_ns, 1);
}
}
return NS_OK;
NS_OBJC_END_TRY_BLOCK_RETURN(NS_ERROR_FAILURE);
}