Global Metrics

path: .metrics.nargs.average
old: 3.5
new: 0.8

path: .metrics.nargs.sum
old: 14.0
new: 4.0

path: .metrics.loc.cloc
old: 11.0
new: 28.0

path: .metrics.loc.blank
old: 7.0
new: 21.0

path: .metrics.loc.ploc
old: 40.0
new: 79.0

path: .metrics.loc.sloc
old: 58.0
new: 128.0

path: .metrics.loc.lloc
old: 17.0
new: 0.0

path: .metrics.cognitive.sum
old: 8.0
new: 0.0

path: .metrics.cognitive.average
old: 2.0
new: 0.0

path: .metrics.mi.mi_original
old: 65.17387580455681
new: 48.679013745099255

path: .metrics.mi.mi_sei
old: 50.676968145792394
new: 29.094230565562945

path: .metrics.mi.mi_visual_studio
old: 38.11337766348351
new: 28.467259500058045

path: .metrics.nexits.sum
old: 1.0
new: 0.0

path: .metrics.nexits.average
old: 0.25
new: 0.0

path: .metrics.cyclomatic.average
old: 1.5714285714285714
new: 1.0

path: .metrics.cyclomatic.sum
old: 11.0
new: 14.0

path: .metrics.nom.total
old: 4.0
new: 5.0

path: .metrics.nom.functions
old: 4.0
new: 5.0

path: .metrics.halstead.purity_ratio
old: 0.788275465331989
new: 1.6622633292171691

path: .metrics.halstead.vocabulary
old: 44.0
new: 100.0

path: .metrics.halstead.N2
old: 108.0
new: 185.0

path: .metrics.halstead.bugs
old: 0.5500051332358324
new: 0.385750077128822

path: .metrics.halstead.effort
old: 67024.25514904952
new: 39367.779037440145

path: .metrics.halstead.estimated_program_length
old: 196.28059086766527
new: 603.4015885058324

path: .metrics.halstead.n1
old: 21.0
new: 15.0

path: .metrics.halstead.time
old: 3723.569730502752
new: 2187.0988354133415

path: .metrics.halstead.length
old: 249.0
new: 363.0

path: .metrics.halstead.level
old: 0.020282186948853614
new: 0.06126126126126126

path: .metrics.halstead.volume
old: 1359.3984730406871
new: 2411.719796888225

path: .metrics.halstead.n2
old: 23.0
new: 85.0

path: .metrics.halstead.difficulty
old: 49.30434782608695
new: 16.323529411764707

path: .metrics.halstead.N1
old: 141.0
new: 178.0

Spaces Data

Minimal test - lines (65, 111)

path: .spaces[3].metrics.nargs.sum
old: 3.0
new: 0.0

path: .spaces[3].metrics.nargs.average
old: 3.0
new: 0.0

path: .spaces[3].metrics.cyclomatic.sum
old: 1.0
new: 2.0

path: .spaces[3].metrics.halstead.N1
old: 15.0
new: 106.0

path: .spaces[3].metrics.halstead.effort
old: 408.33881539067806
new: 22285.66714061158

path: .spaces[3].metrics.halstead.bugs
old: 0.018346751908285344
new: 0.2639748215789553

path: .spaces[3].metrics.halstead.n1
old: 6.0
new: 14.0

path: .spaces[3].metrics.halstead.n2
old: 8.0
new: 53.0

path: .spaces[3].metrics.halstead.level
old: 0.24242424242424243
new: 0.06206088992974239

path: .spaces[3].metrics.halstead.estimated_program_length
old: 39.50977500432694
new: 356.882753000656

path: .spaces[3].metrics.halstead.difficulty
old: 4.125
new: 16.11320754716981

path: .spaces[3].metrics.halstead.time
old: 22.68548974392656
new: 1238.0926189228655

path: .spaces[3].metrics.halstead.length
old: 26.0
new: 228.0

path: .spaces[3].metrics.halstead.N2
old: 11.0
new: 122.0

path: .spaces[3].metrics.halstead.purity_ratio
old: 1.5196067309356516
new: 1.5652752324590176

path: .spaces[3].metrics.halstead.vocabulary
old: 14.0
new: 67.0

path: .spaces[3].metrics.halstead.volume
old: 98.99122797349771
new: 1383.068335424372

path: .spaces[3].metrics.mi.mi_sei
old: 140.2019583580246
new: 56.12625242131689

path: .spaces[3].metrics.mi.mi_original
old: 120.80294337118892
new: 70.5608981967451

path: .spaces[3].metrics.mi.mi_visual_studio
old: 70.6449961235023
new: 41.26368315599129

path: .spaces[3].metrics.loc.sloc
old: 5.0
new: 47.0

path: .spaces[3].metrics.loc.cloc
old: 2.0
new: 8.0

path: .spaces[3].metrics.loc.lloc
old: 1.0
new: 0.0

path: .spaces[3].metrics.loc.ploc
old: 5.0
new: 33.0

path: .spaces[3].metrics.loc.blank
old: 0.0
new: 6.0

Code

class nsPaper final : public nsIPaper {
  using Promise = mozilla::dom::Promise;
  using CommonPaperSize = mozilla::CommonPaperSize;

 public:
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  NS_DECL_CYCLE_COLLECTION_CLASS(nsPaper)
  NS_DECL_NSIPAPER

  nsPaper() = delete;
  explicit nsPaper(const mozilla::PaperInfo&);
  nsPaper(nsPrinterBase&, const mozilla::PaperInfo&);

  // This list is used for both our fallback paper sizes (used when a printer
  // does not provide a list of available paper sizes), and for localizing
  // common paper sizes to avoid querying the printer for extra information in
  // the common case, as well as to provide more uniform paper names in the
  // frontend.
  // If we need to separate these two uses, we will need to either split this
  // into two lists, or add a flag to indicate what the size is used for.
#define mm *72.0 / 25.4
#define in *72.0
  static constexpr CommonPaperSize kCommonPaperSizes[] = {
      CommonPaperSize{u"iso_a5"_ns, "a5"_ns, {148 mm, 210 mm}},
      CommonPaperSize{u"iso_a4"_ns, "a4"_ns, {210 mm, 297 mm}},
      CommonPaperSize{u"iso_a3"_ns, "a3"_ns, {297 mm, 420 mm}},
      CommonPaperSize{u"iso_b5"_ns, "b5"_ns, {176 mm, 250 mm}},
      CommonPaperSize{u"iso_b4"_ns, "b4"_ns, {250 mm, 353 mm}},
      CommonPaperSize{u"jis_b5"_ns, "jis-b5"_ns, {182 mm, 257 mm}},
      CommonPaperSize{u"jis_b4"_ns, "jis-b4"_ns, {257 mm, 364 mm}},
      CommonPaperSize{u"na_letter"_ns, "letter"_ns, {8.5 in, 11 in}},
      CommonPaperSize{u"na_legal"_ns, "legal"_ns, {8.5 in, 14 in}},
      CommonPaperSize{u"na_ledger"_ns, "tabloid"_ns, {11 in, 17 in}}};
#undef mm
#undef in
  static constexpr size_t kNumCommonPaperSizes =
      mozilla::ArrayLength(kCommonPaperSizes);

 private:
  ~nsPaper();

  // null if not associated with a printer (for "Save-to-PDF" paper sizes)
  RefPtr mPrinter;

  RefPtr mMarginPromise;
  const mozilla::PaperInfo mInfo;
};

Minimal test - lines (63, 63)

path: .spaces[2].metrics.cyclomatic.sum
old: 3.0
new: 1.0

path: .spaces[2].metrics.cyclomatic.average
old: 3.0
new: 1.0

path: .spaces[2].metrics.mi.mi_original
old: 89.861949574918
new: null

path: .spaces[2].metrics.mi.mi_sei
old: 54.24799660254892
new: null

path: .spaces[2].metrics.mi.mi_visual_studio
old: 52.55084770463041
new: null

path: .spaces[2].metrics.nom.functions
old: 1.0
new: 0.0

path: .spaces[2].metrics.nom.total
old: 1.0
new: 0.0

path: .spaces[2].metrics.halstead.estimated_program_length
old: 91.35671671381672
new: null

path: .spaces[2].metrics.halstead.bugs
old: 0.22876748279060735
new: 0.0

path: .spaces[2].metrics.halstead.level
old: 0.030219780219780217
new: null

path: .spaces[2].metrics.halstead.length
old: 117.0
new: 1.0

path: .spaces[2].metrics.halstead.n2
old: 11.0
new: 1.0

path: .spaces[2].metrics.halstead.purity_ratio
old: 0.7808266385796301
new: null

path: .spaces[2].metrics.halstead.N2
old: 52.0
new: 1.0

path: .spaces[2].metrics.halstead.difficulty
old: 33.09090909090909
new: 0.0

path: .spaces[2].metrics.halstead.vocabulary
old: 25.0
new: 1.0

path: .spaces[2].metrics.halstead.effort
old: 17979.322491829633
new: 0.0

path: .spaces[2].metrics.halstead.time
old: 998.8512495460908
new: 0.0

path: .spaces[2].metrics.halstead.N1
old: 65.0
new: 0.0

path: .spaces[2].metrics.halstead.n1
old: 14.0
new: 0.0

path: .spaces[2].metrics.halstead.volume
old: 543.3311742036427
new: 0.0

path: .spaces[2].metrics.nexits.sum
old: 1.0
new: 0.0

path: .spaces[2].metrics.nexits.average
old: 1.0
new: null

path: .spaces[2].metrics.nargs.average
old: 4.0
new: null

path: .spaces[2].metrics.nargs.sum
old: 4.0
new: 0.0

path: .spaces[2].metrics.loc.ploc
old: 16.0
new: 1.0

path: .spaces[2].metrics.loc.sloc
old: 19.0
new: 1.0

path: .spaces[2].metrics.loc.lloc
old: 9.0
new: 0.0

path: .spaces[2].metrics.loc.blank
old: 3.0
new: 0.0

path: .spaces[2].metrics.cognitive.sum
old: 4.0
new: 0.0

path: .spaces[2].metrics.cognitive.average
old: 4.0
new: null

Code

class nsPrinterBase;

Minimal test - lines (20, 61)

path: .spaces[1].metrics.loc.lloc
old: 1.0
new: 0.0

path: .spaces[1].metrics.loc.sloc
old: 4.0
new: 42.0

path: .spaces[1].metrics.loc.cloc
old: 0.0
new: 12.0

path: .spaces[1].metrics.loc.ploc
old: 4.0
new: 23.0

path: .spaces[1].metrics.loc.blank
old: 0.0
new: 7.0

path: .spaces[1].metrics.mi.mi_sei
old: 104.80145491368997
new: 73.49446313879494

path: .spaces[1].metrics.mi.mi_visual_studio
old: 73.08392562532828
new: 45.34015482657003

path: .spaces[1].metrics.mi.mi_original
old: 124.97351281931137
new: 77.53166475343474

path: .spaces[1].metrics.cyclomatic.sum
old: 2.0
new: 5.0

path: .spaces[1].metrics.halstead.vocabulary
old: 13.0
new: 32.0

path: .spaces[1].metrics.halstead.estimated_program_length
old: 35.161259458730164
new: 130.29241368336423

path: .spaces[1].metrics.halstead.difficulty
old: 4.714285714285714
new: 11.0

path: .spaces[1].metrics.halstead.time
old: 22.290744016421343
new: 275.0

path: .spaces[1].metrics.halstead.n2
old: 7.0
new: 21.0

path: .spaces[1].metrics.halstead.N2
old: 11.0
new: 42.0

path: .spaces[1].metrics.halstead.bugs
old: 0.018133297705928825
new: 0.09681638840982984

path: .spaces[1].metrics.halstead.volume
old: 85.11011351724513
new: 450.0

path: .spaces[1].metrics.halstead.n1
old: 6.0
new: 11.0

path: .spaces[1].metrics.halstead.length
old: 23.0
new: 90.0

path: .spaces[1].metrics.halstead.N1
old: 12.0
new: 48.0

path: .spaces[1].metrics.halstead.level
old: 0.21212121212121213
new: 0.09090909090909093

path: .spaces[1].metrics.halstead.purity_ratio
old: 1.5287504112491377
new: 1.4476934853707135

path: .spaces[1].metrics.halstead.effort
old: 401.23339229558417
new: 4950.0

path: .spaces[1].metrics.nom.total
old: 1.0
new: 2.0

path: .spaces[1].metrics.nom.functions
old: 1.0
new: 2.0

path: .spaces[1].metrics.nargs.sum
old: 2.0
new: 4.0

Code

namespace mozilla {

// Simple struct that can be used off the main thread to hold all the info from
// an nsPaper instance.
struct PaperInfo {
  using MarginDouble = mozilla::gfx::MarginDouble;
  using SizeDouble = mozilla::gfx::SizeDouble;

  PaperInfo() = default;
  PaperInfo(const nsAString& aId, const nsAString& aName,
            const SizeDouble& aSize,
            const Maybe& aUnwriteableMargin)
      : mId(aId),
        mName(aName),
        mSize(aSize),
        mUnwriteableMargin(aUnwriteableMargin) {}

  nsString mId;
  nsString mName;

  SizeDouble mSize;

  // The margins may not be known by some back-ends.
  Maybe mUnwriteableMargin{Nothing()};
};

/**
 * Plain struct used for commonly used, hard-coded paper sizes.
 *
 * Used to construct PaperInfo at runtime by localizing the name.
 */
struct CommonPaperSize final {
  // The standardized PWG name, which should be used as the PaperInfo id
  nsLiteralString mPWGName;
  // The name key to localize the name of this paper size using strings in
  // printUI.ftl
  nsLiteralCString mLocalizableNameKey;
  // Size is in points, same as PaperInfo
  gfx::SizeDouble mSize;
};

}  // namespace mozilla

Minimal test - lines (18, 18)

path: .spaces[0].metrics.cognitive.average
old: 4.0
new: null

path: .spaces[0].metrics.cognitive.sum
old: 4.0
new: 0.0

path: .spaces[0].metrics.cyclomatic.average
old: 2.0
new: 1.0

path: .spaces[0].metrics.cyclomatic.sum
old: 4.0
new: 1.0

path: .spaces[0].metrics.loc.blank
old: 1.0
new: 0.0

path: .spaces[0].metrics.loc.sloc
old: 15.0
new: 1.0

path: .spaces[0].metrics.loc.ploc
old: 14.0
new: 1.0

path: .spaces[0].metrics.loc.lloc
old: 6.0
new: 0.0

path: .spaces[0].metrics.nom.functions
old: 1.0
new: 0.0

path: .spaces[0].metrics.nom.total
old: 1.0
new: 0.0

path: .spaces[0].metrics.nexits.average
old: 0.0
new: null

path: .spaces[0].metrics.nargs.average
old: 5.0
new: null

path: .spaces[0].metrics.nargs.sum
old: 5.0
new: 0.0

path: .spaces[0].metrics.halstead.bugs
old: 0.1472127817430393
new: 0.0

path: .spaces[0].metrics.halstead.estimated_program_length
old: 123.1643663617958
new: null

path: .spaces[0].metrics.halstead.length
old: 82.0
new: 1.0

path: .spaces[0].metrics.halstead.n2
old: 13.0
new: 1.0

path: .spaces[0].metrics.halstead.level
old: 0.04377104377104377
new: null

path: .spaces[0].metrics.halstead.n1
old: 18.0
new: 0.0

path: .spaces[0].metrics.halstead.time
old: 515.617508304111
new: 0.0

path: .spaces[0].metrics.halstead.vocabulary
old: 31.0
new: 1.0

path: .spaces[0].metrics.halstead.N2
old: 33.0
new: 1.0

path: .spaces[0].metrics.halstead.difficulty
old: 22.846153846153847
new: 0.0

path: .spaces[0].metrics.halstead.volume
old: 406.24409745172375
new: 0.0

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.502004467826778
new: null

path: .spaces[0].metrics.halstead.N1
old: 49.0
new: 0.0

path: .spaces[0].metrics.halstead.effort
old: 9281.115149473995
new: 0.0

path: .spaces[0].metrics.mi.mi_visual_studio
old: 55.5400145499196
new: null

path: .spaces[0].metrics.mi.mi_sei
old: 61.724116536744546
new: null

path: .spaces[0].metrics.mi.mi_original
old: 94.9734248803625
new: null

Code

struct JSContext;

Minimal test - lines (24, 44)

path: .spaces[1].spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 3.0

path: .spaces[1].spaces[0].metrics.cognitive.average
old: null
new: 0.0

path: .spaces[1].spaces[0].metrics.mi.mi_visual_studio
old: null
new: 52.958939476599426

path: .spaces[1].spaces[0].metrics.mi.mi_sei
old: null
new: 71.83771884314277

path: .spaces[1].spaces[0].metrics.mi.mi_original
old: null
new: 90.55978650498504

path: .spaces[1].spaces[0].metrics.nom.functions
old: 0.0
new: 2.0

path: .spaces[1].spaces[0].metrics.nom.total
old: 0.0
new: 2.0

path: .spaces[1].spaces[0].metrics.nexits.average
old: null
new: 0.0

path: .spaces[1].spaces[0].metrics.loc.blank
old: 0.0
new: 4.0

path: .spaces[1].spaces[0].metrics.loc.sloc
old: 1.0
new: 21.0

path: .spaces[1].spaces[0].metrics.loc.cloc
old: 0.0
new: 1.0

path: .spaces[1].spaces[0].metrics.loc.ploc
old: 1.0
new: 16.0

path: .spaces[1].spaces[0].metrics.nargs.average
old: null
new: 2.0

path: .spaces[1].spaces[0].metrics.nargs.sum
old: 0.0
new: 4.0

path: .spaces[1].spaces[0].metrics.halstead.volume
old: 0.0
new: 347.8325391424408

path: .spaces[1].spaces[0].metrics.halstead.estimated_program_length
old: null
new: 96.65710673913804

path: .spaces[1].spaces[0].metrics.halstead.N1
old: 0.0
new: 40.0

path: .spaces[1].spaces[0].metrics.halstead.time
old: 0.0
new: 240.90624007272748

path: .spaces[1].spaces[0].metrics.halstead.vocabulary
old: 1.0
new: 26.0

path: .spaces[1].spaces[0].metrics.halstead.bugs
old: 0.0
new: 0.08863919059327005

path: .spaces[1].spaces[0].metrics.halstead.n2
old: 1.0
new: 15.0

path: .spaces[1].spaces[0].metrics.halstead.effort
old: 0.0
new: 4336.312321309095

path: .spaces[1].spaces[0].metrics.halstead.n1
old: 0.0
new: 11.0

path: .spaces[1].spaces[0].metrics.halstead.N2
old: 1.0
new: 34.0

path: .spaces[1].spaces[0].metrics.halstead.level
old: null
new: 0.08021390374331551

path: .spaces[1].spaces[0].metrics.halstead.purity_ratio
old: null
new: 1.30617711809646

path: .spaces[1].spaces[0].metrics.halstead.length
old: 1.0
new: 74.0

path: .spaces[1].spaces[0].metrics.halstead.difficulty
old: 0.0
new: 12.466666666666669

Code

struct PaperInfo {
  using MarginDouble = mozilla::gfx::MarginDouble;
  using SizeDouble = mozilla::gfx::SizeDouble;

  PaperInfo() = default;
  PaperInfo(const nsAString& aId, const nsAString& aName,
            const SizeDouble& aSize,
            const Maybe& aUnwriteableMargin)
      : mId(aId),
        mName(aName),
        mSize(aSize),
        mUnwriteableMargin(aUnwriteableMargin) {}

  nsString mId;
  nsString mName;

  SizeDouble mSize;

  // The margins may not be known by some back-ends.
  Maybe mUnwriteableMargin{Nothing()};
};