Global Metrics
path: .metrics.loc.blank
old: 19.0
new: 18.0
path: .metrics.loc.cloc
old: 89.0
new: 29.0
path: .metrics.loc.sloc
old: 155.0
new: 92.0
path: .metrics.loc.ploc
old: 47.0
new: 45.0
path: .metrics.loc.lloc
old: 14.0
new: 1.0
path: .metrics.nexits.sum
old: 3.0
new: 1.0
path: .metrics.nexits.average
old: 1.5
new: 0.3333333333333333
path: .metrics.cyclomatic.average
old: 1.75
new: 1.1666666666666667
path: .metrics.nargs.sum
old: 4.0
new: 3.0
path: .metrics.nargs.average
old: 2.0
new: 1.0
path: .metrics.nom.total
old: 2.0
new: 3.0
path: .metrics.nom.functions
old: 2.0
new: 3.0
path: .metrics.halstead.length
old: 219.0
new: 229.0
path: .metrics.halstead.bugs
old: 0.2639400559692753
new: 0.2826854525898902
path: .metrics.halstead.time
old: 1237.8480408950184
new: 1372.033029437702
path: .metrics.halstead.effort
old: 22281.26473611033
new: 24696.594529878636
path: .metrics.halstead.purity_ratio
old: 1.484318155382872
new: 1.41950076868493
path: .metrics.halstead.level
old: 0.05875
new: 0.055424528301886794
path: .metrics.halstead.N2
old: 100.0
new: 106.0
path: .metrics.halstead.volume
old: 1309.0243032464818
new: 1368.797102481481
path: .metrics.halstead.difficulty
old: 17.02127659574468
new: 18.04255319148936
path: .metrics.halstead.N1
old: 119.0
new: 123.0
path: .metrics.cognitive.average
old: 2.0
new: 0.0
path: .metrics.cognitive.sum
old: 4.0
new: 0.0
path: .metrics.mi.mi_original
old: 50.36591897947271
new: 58.5842495019338
path: .metrics.mi.mi_visual_studio
old: 29.45375378916533
new: 34.25979503037065
path: .metrics.mi.mi_sei
old: 43.787999583649245
new: 47.740529342416586
Spaces Data
Minimal test - lines (34, 39)
path: .spaces[0].spaces[1].metrics.loc.lloc
old: 5.0
new: 0.0
path: .spaces[0].spaces[1].metrics.loc.ploc
old: 9.0
new: 4.0
path: .spaces[0].spaces[1].metrics.loc.sloc
old: 11.0
new: 6.0
path: .spaces[0].spaces[1].metrics.loc.cloc
old: 3.0
new: 2.0
path: .spaces[0].spaces[1].metrics.halstead.n1
old: 12.0
new: 5.0
path: .spaces[0].spaces[1].metrics.halstead.N2
old: 20.0
new: 5.0
path: .spaces[0].spaces[1].metrics.halstead.vocabulary
old: 24.0
new: 10.0
path: .spaces[0].spaces[1].metrics.halstead.N1
old: 33.0
new: 6.0
path: .spaces[0].spaces[1].metrics.halstead.effort
old: 2430.0301253822126
new: 91.35302260940249
path: .spaces[0].spaces[1].metrics.halstead.n2
old: 12.0
new: 5.0
path: .spaces[0].spaces[1].metrics.halstead.purity_ratio
old: 1.62337924560958
new: 2.110843722624874
path: .spaces[0].spaces[1].metrics.halstead.time
old: 135.00167363234516
new: 5.075167922744582
path: .spaces[0].spaces[1].metrics.halstead.difficulty
old: 10.0
new: 2.5
path: .spaces[0].spaces[1].metrics.halstead.volume
old: 243.00301253822127
new: 36.541209043760986
path: .spaces[0].spaces[1].metrics.halstead.length
old: 53.0
new: 11.0
path: .spaces[0].spaces[1].metrics.halstead.level
old: 0.1
new: 0.4
path: .spaces[0].spaces[1].metrics.halstead.bugs
old: 0.06024946345509445
new: 0.006761255684837643
path: .spaces[0].spaces[1].metrics.halstead.estimated_program_length
old: 86.03910001730775
new: 23.21928094887362
path: .spaces[0].spaces[1].metrics.mi.mi_sei
old: 109.009330170972
new: 140.8905871932982
path: .spaces[0].spaces[1].metrics.mi.mi_visual_studio
old: 60.041001526231966
new: 71.94830717990641
path: .spaces[0].spaces[1].metrics.mi.mi_original
old: 102.67011260985666
new: 123.03160527763995
path: .spaces[0].spaces[1].metrics.nom.total
old: 1.0
new: 0.0
path: .spaces[0].spaces[1].metrics.nom.functions
old: 1.0
new: 0.0
path: .spaces[0].spaces[1].metrics.cognitive.average
old: 4.0
new: null
path: .spaces[0].spaces[1].metrics.cognitive.sum
old: 4.0
new: 0.0
path: .spaces[0].spaces[1].metrics.nargs.average
old: 4.0
new: null
path: .spaces[0].spaces[1].metrics.nargs.sum
old: 4.0
new: 0.0
path: .spaces[0].spaces[1].metrics.cyclomatic.average
old: 4.0
new: 1.0
path: .spaces[0].spaces[1].metrics.cyclomatic.sum
old: 4.0
new: 1.0
path: .spaces[0].spaces[1].metrics.nexits.average
old: 3.0
new: null
path: .spaces[0].spaces[1].metrics.nexits.sum
old: 3.0
new: 0.0
Code
struct PrinterInfo {
// Both windows and CUPS: The name of the printer.
nsString mName;
// CUPS only: Handle to owned cups_dest_t.
void* mCupsHandle = nullptr;
};
Minimal test - lines (22, 24)
path: .spaces[0].spaces[0].metrics.mi.mi_original
old: 158.02045369261705
new: 133.808130442365
path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: 152.37629276875444
new: 117.44529408721525
path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 92.40962204246613
new: 78.25036867974562
path: .spaces[0].spaces[0].metrics.nargs.average
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].metrics.nargs.sum
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].metrics.nexits.average
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].metrics.halstead.n1
old: 4.0
new: 5.0
path: .spaces[0].spaces[0].metrics.halstead.n2
old: 1.0
new: 5.0
path: .spaces[0].spaces[0].metrics.halstead.N1
old: 4.0
new: 6.0
path: .spaces[0].spaces[0].metrics.halstead.N2
old: 1.0
new: 6.0
path: .spaces[0].spaces[0].metrics.halstead.level
old: 0.5
new: 0.3333333333333333
path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 5.0
new: 10.0
path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 1.6
new: 1.9349400790728015
path: .spaces[0].spaces[0].metrics.halstead.length
old: 5.0
new: 12.0
path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.002712967490108627
new: 0.008091093705353408
path: .spaces[0].spaces[0].metrics.halstead.time
old: 1.289960052715201
new: 6.643856189774725
path: .spaces[0].spaces[0].metrics.halstead.volume
old: 11.60964047443681
new: 39.86313713864835
path: .spaces[0].spaces[0].metrics.halstead.effort
old: 23.21928094887362
new: 119.58941141594504
path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 2.0
new: 3.0
path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 8.0
new: 23.21928094887362
path: .spaces[0].spaces[0].metrics.loc.lloc
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].metrics.loc.sloc
old: 1.0
new: 3.0
path: .spaces[0].spaces[0].metrics.loc.ploc
old: 1.0
new: 3.0
Code
NS_IMETHOD GetSystemDefaultPrinterName(nsAString& aName) final {
return SystemDefaultPrinterName(aName);
}
Minimal test - lines (16, 90)
path: .spaces[0].metrics.nargs.sum
old: 4.0
new: 3.0
path: .spaces[0].metrics.nargs.average
old: 2.0
new: 1.0
path: .spaces[0].metrics.nexits.sum
old: 3.0
new: 1.0
path: .spaces[0].metrics.nexits.average
old: 1.5
new: 0.3333333333333333
path: .spaces[0].metrics.cyclomatic.average
old: 2.0
new: 1.2
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.749329102786262
new: 1.2835277474630835
path: .spaces[0].metrics.halstead.difficulty
old: 12.692307692307692
new: 19.317073170731707
path: .spaces[0].metrics.halstead.n1
old: 15.0
new: 16.0
path: .spaces[0].metrics.halstead.volume
old: 293.24865024551383
new: 1289.0686931304078
path: .spaces[0].metrics.halstead.estimated_program_length
old: 106.70907526996196
new: 283.65963218934144
path: .spaces[0].metrics.halstead.length
old: 61.0
new: 221.0
path: .spaces[0].metrics.halstead.N1
old: 39.0
new: 122.0
path: .spaces[0].metrics.halstead.bugs
old: 0.08005647945864997
new: 0.28424336501565906
path: .spaces[0].metrics.halstead.effort
old: 3722.002099269983
new: 24901.034267299583
path: .spaces[0].metrics.halstead.level
old: 0.0787878787878788
new: 0.05176767676767677
path: .spaces[0].metrics.halstead.n2
old: 13.0
new: 41.0
path: .spaces[0].metrics.halstead.time
old: 206.77789440388793
new: 1383.3907926277543
path: .spaces[0].metrics.halstead.vocabulary
old: 28.0
new: 57.0
path: .spaces[0].metrics.halstead.N2
old: 22.0
new: 99.0
path: .spaces[0].metrics.cognitive.sum
old: 4.0
new: 0.0
path: .spaces[0].metrics.cognitive.average
old: 2.0
new: 0.0
path: .spaces[0].metrics.mi.mi_sei
old: 96.21834378579328
new: 53.97867989654334
path: .spaces[0].metrics.mi.mi_original
old: 87.29752748319783
new: 62.435981035450936
path: .spaces[0].metrics.mi.mi_visual_studio
old: 51.05118566268879
new: 36.51226961137481
path: .spaces[0].metrics.nom.functions
old: 2.0
new: 3.0
path: .spaces[0].metrics.nom.total
old: 2.0
new: 3.0
path: .spaces[0].metrics.loc.cloc
old: 14.0
new: 25.0
path: .spaces[0].metrics.loc.sloc
old: 26.0
new: 75.0
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 13.0
path: .spaces[0].metrics.loc.lloc
old: 5.0
new: 1.0
path: .spaces[0].metrics.loc.ploc
old: 13.0
new: 37.0
Code
class nsPrinterListBase : public nsIPrinterList {
public:
using Promise = mozilla::dom::Promise;
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsPrinterListBase)
NS_IMETHOD GetSystemDefaultPrinterName(nsAString& aName) final {
return SystemDefaultPrinterName(aName);
}
NS_IMETHOD GetPrinters(JSContext*, Promise**) final;
NS_IMETHOD GetPrinterByName(const nsAString& aPrinterName, JSContext* aCx,
Promise** aResult) final;
NS_IMETHOD GetPrinterBySystemName(const nsAString& aPrinterName,
JSContext* aCx, Promise** aResult) final;
NS_IMETHOD GetNamedOrDefaultPrinter(const nsAString& aPrinterName,
JSContext* aCx, Promise** aResult) final;
NS_IMETHOD GetFallbackPaperList(JSContext*, Promise**) final;
struct PrinterInfo {
// Both windows and CUPS: The name of the printer.
nsString mName;
// CUPS only: Handle to owned cups_dest_t.
void* mCupsHandle = nullptr;
};
// Called off the main thread, collect information to create an appropriate
// list of printers.
virtual nsTArray Printers() const = 0;
// Create an nsIPrinter object given the information we obtained from the
// background thread.
virtual RefPtr CreatePrinter(PrinterInfo) const = 0;
mozilla::Maybe NamedOrDefaultPrinter(nsString aName) const;
// No copy or move, we're an identity.
nsPrinterListBase(const nsPrinterListBase&) = delete;
nsPrinterListBase(nsPrinterListBase&&) = delete;
protected:
nsPrinterListBase();
virtual ~nsPrinterListBase();
// This could be implemented in terms of Printers() and then searching the
// returned printer info for a printer of the given name, but we expect
// backends to have more efficient methods of implementing this.
virtual mozilla::Maybe PrinterByName(nsString aName) const = 0;
// Same as NamedPrinter, but uses the system name.
// Depending on whether or not there is a more efficient way to address the
// printer for a given backend, this may or may not be equivalent to
// NamedPrinter.
virtual mozilla::Maybe PrinterBySystemName(
nsString aName) const = 0;
// This is implemented separately from the IDL interface version so that it
// can be made const, which allows it to be used while resolving promises.
virtual nsresult SystemDefaultPrinterName(nsAString&) const = 0;
// Return "paper" sizes to be supported by the Save to PDF destination;
// for actual printer drivers the list is retrieved from nsIPrinter.
nsTArray> FallbackPaperList() const;
// Constructs mCommonPaperInfo by localizing the sizes in
// nsPaper::kCommonPaperSizes and creating corresponding PaperInfo.
void EnsureCommonPaperInfo(JSContext* aCx);
RefPtr mPrintersPromise;
// PaperInfo for our fallback sizes and common size localization.
// This field contains the same data for every instance of this class.
// It's unfortunate that this needs to be a member rather than static data
// like nsPaper::kCommonPaperSizes, but that's because PaperInfo contains
// localized data, and we need a JSContext to do the localization.
RefPtr mCommonPaperInfo;
};