Global Metrics

path: .metrics.mi.mi_visual_studio
old: 36.620889939213285
new: 28.385262073978904

path: .metrics.mi.mi_original
old: 62.621721796054715
new: 48.53879814650392

path: .metrics.mi.mi_sei
old: 39.62101997121368
new: 24.488374241795047

path: .metrics.loc.cloc
old: 6.0
new: 20.0

path: .metrics.loc.ploc
old: 50.0
new: 85.0

path: .metrics.loc.blank
old: 5.0
new: 22.0

path: .metrics.loc.lloc
old: 34.0
new: 36.0

path: .metrics.loc.sloc
old: 61.0
new: 127.0

path: .metrics.cyclomatic.average
old: 4.0
new: 3.25

path: .metrics.cyclomatic.sum
old: 16.0
new: 13.0

path: .metrics.nargs.average
old: 1.0
new: 1.6666666666666667

path: .metrics.nargs.sum
old: 3.0
new: 5.0

path: .metrics.cognitive.sum
old: 9.0
new: 18.0

path: .metrics.cognitive.average
old: 3.0
new: 6.0

path: .metrics.halstead.bugs
old: 0.270554091914671
new: 0.567423286397629

path: .metrics.halstead.n2
old: 55.0
new: 73.0

path: .metrics.halstead.effort
old: 23124.00433360221
new: 70233.22552344506

path: .metrics.halstead.purity_ratio
old: 1.6272873755072832
new: 1.3794022773884678

path: .metrics.halstead.time
old: 1284.666907422345
new: 3901.845862413614

path: .metrics.halstead.N1
old: 157.0
new: 235.0

path: .metrics.halstead.difficulty
old: 15.2
new: 26.465753424657535

path: .metrics.halstead.level
old: 0.06578947368421052
new: 0.03778467908902691

path: .metrics.halstead.n1
old: 19.0
new: 23.0

path: .metrics.halstead.N2
old: 88.0
new: 168.0

path: .metrics.halstead.estimated_program_length
old: 398.6854069992844
new: 555.8991177875525

path: .metrics.halstead.length
old: 245.0
new: 403.0

path: .metrics.halstead.volume
old: 1521.3160745790929
new: 2653.7398877906257

path: .metrics.halstead.vocabulary
old: 74.0
new: 96.0

Spaces Data

Minimal test - lines (22, 73)

path: .spaces[0].metrics.cognitive.sum
old: 1.0
new: 7.0

path: .spaces[0].metrics.cognitive.average
old: 1.0
new: 7.0

path: .spaces[0].metrics.mi.mi_visual_studio
old: 60.75309573198398
new: 40.647809235120654

path: .spaces[0].metrics.mi.mi_original
old: 103.88779370169262
new: 69.50775379205632

path: .spaces[0].metrics.mi.mi_sei
old: 74.78847194674167
new: 57.77407821575229

path: .spaces[0].metrics.cyclomatic.average
old: 6.0
new: 5.0

path: .spaces[0].metrics.cyclomatic.sum
old: 6.0
new: 5.0

path: .spaces[0].metrics.halstead.volume
old: 236.83666567851097
new: 1082.4063210825789

path: .spaces[0].metrics.halstead.estimated_program_length
old: 91.8226398830014
new: 293.5877465509226

path: .spaces[0].metrics.halstead.N2
old: 16.0
new: 77.0

path: .spaces[0].metrics.halstead.vocabulary
old: 25.0
new: 59.0

path: .spaces[0].metrics.halstead.N1
old: 35.0
new: 107.0

path: .spaces[0].metrics.halstead.bugs
old: 0.03895027450206386
new: 0.2439168772000967

path: .spaces[0].metrics.halstead.difficulty
old: 5.333333333333333
new: 18.2875

path: .spaces[0].metrics.halstead.n1
old: 10.0
new: 19.0

path: .spaces[0].metrics.halstead.length
old: 51.0
new: 184.0

path: .spaces[0].metrics.halstead.effort
old: 1263.128883618725
new: 19794.505596797662

path: .spaces[0].metrics.halstead.level
old: 0.1875
new: 0.05468215994531784

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.8004439192745376
new: 1.595585579081101

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

path: .spaces[0].metrics.halstead.time
old: 70.17382686770695
new: 1099.694755377648

path: .spaces[0].metrics.nexits.sum
old: 5.0
new: 3.0

path: .spaces[0].metrics.nexits.average
old: 5.0
new: 3.0

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

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

path: .spaces[0].metrics.loc.sloc
old: 10.0
new: 52.0

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

path: .spaces[0].metrics.loc.lloc
old: 12.0
new: 16.0

path: .spaces[0].metrics.loc.ploc
old: 10.0
new: 33.0

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

Code

nsPrintSettingsServiceWin::SerializeToPrintData(nsIPrintSettings* aSettings,
                                                PrintData* data) {
  nsresult rv = nsPrintSettingsService::SerializeToPrintData(aSettings, data);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr psWin = do_QueryInterface(aSettings);
  if (!psWin) {
    return NS_ERROR_FAILURE;
  }

  nsAutoString deviceName;
  nsAutoString driverName;

  psWin->GetDeviceName(deviceName);
  psWin->GetDriverName(driverName);

  data->deviceName().Assign(deviceName);
  data->driverName().Assign(driverName);

  // When creating the print dialog on Windows, we only need to send certain
  // print settings information from the parent to the child not vice versa.
  if (XRE_IsParentProcess()) {
    // A DEVMODE can actually be of arbitrary size. If it turns out that it'll
    // make our IPC message larger than the limit, then we'll error out.
    LPDEVMODEW devModeRaw;
    psWin->GetDevMode(&devModeRaw);  // This actually allocates a copy of the
                                     // the nsIPrintSettingsWin DEVMODE, so
                                     // we're now responsible for deallocating
                                     // it. We'll use an nsAutoDevMode helper
                                     // to do this.
    if (devModeRaw) {
      nsAutoDevMode devMode(devModeRaw);
      devModeRaw = nullptr;

      size_t devModeTotalSize = devMode->dmSize + devMode->dmDriverExtra;
      size_t msgTotalSize = sizeof(PrintData) + devModeTotalSize;

      if (msgTotalSize > IPC::Channel::kMaximumMessageSize / 2) {
        return NS_ERROR_FAILURE;
      }

      // Instead of reaching in and manually reading each member, we'll just
      // copy the bits over.
      const char* devModeData = reinterpret_cast(devMode.get());
      nsTArray arrayBuf;
      arrayBuf.AppendElements(devModeData, devModeTotalSize);
      data->devModeData() = std::move(arrayBuf);
    }
  }

  return NS_OK;
}

Minimal test - lines (76, 115)

path: .spaces[1].metrics.loc.lloc
old: 10.0
new: 16.0

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

path: .spaces[1].metrics.loc.sloc
old: 13.0
new: 40.0

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

path: .spaces[1].metrics.loc.ploc
old: 13.0
new: 31.0

path: .spaces[1].metrics.halstead.N1
old: 27.0
new: 100.0

path: .spaces[1].metrics.halstead.estimated_program_length
old: 71.27302875388389
new: 265.9634674908211

path: .spaces[1].metrics.halstead.volume
old: 175.69269691115042
new: 948.1429930180442

path: .spaces[1].metrics.halstead.N2
old: 13.0
new: 64.0

path: .spaces[1].metrics.halstead.effort
old: 1038.1841181113434
new: 17337.47187232995

path: .spaces[1].metrics.halstead.bugs
old: 0.03417655884469047
new: 0.22328999206568884

path: .spaces[1].metrics.halstead.time
old: 57.67689545063019
new: 963.1928817961084

path: .spaces[1].metrics.halstead.length
old: 40.0
new: 164.0

path: .spaces[1].metrics.halstead.difficulty
old: 5.909090909090909
new: 18.285714285714285

path: .spaces[1].metrics.halstead.vocabulary
old: 21.0
new: 55.0

path: .spaces[1].metrics.halstead.purity_ratio
old: 1.7818257188470974
new: 1.6217284603098845

path: .spaces[1].metrics.halstead.n1
old: 10.0
new: 20.0

path: .spaces[1].metrics.halstead.n2
old: 11.0
new: 35.0

path: .spaces[1].metrics.halstead.level
old: 0.16923076923076924
new: 0.0546875

path: .spaces[1].metrics.cyclomatic.sum
old: 4.0
new: 6.0

path: .spaces[1].metrics.cyclomatic.average
old: 4.0
new: 6.0

path: .spaces[1].metrics.cognitive.average
old: 1.0
new: 11.0

path: .spaces[1].metrics.cognitive.sum
old: 1.0
new: 11.0

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

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

path: .spaces[1].metrics.nexits.sum
old: 3.0
new: 4.0

path: .spaces[1].metrics.nexits.average
old: 3.0
new: 4.0

path: .spaces[1].metrics.mi.mi_sei
old: 71.35694241703989
new: 52.56467888820886

path: .spaces[1].metrics.mi.mi_original
old: 101.65039098011404
new: 74.21672514088847

path: .spaces[1].metrics.mi.mi_visual_studio
old: 59.444673087786
new: 43.401593649642386

Code

nsPrintSettingsServiceWin::DeserializeToPrintSettings(
    const PrintData& data, nsIPrintSettings* settings) {
  nsresult rv =
      nsPrintSettingsService::DeserializeToPrintSettings(data, settings);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr psWin = do_QueryInterface(settings);
  if (!settings) {
    return NS_ERROR_FAILURE;
  }

  if (XRE_IsContentProcess()) {
    psWin->SetDeviceName(data.deviceName());
    psWin->SetDriverName(data.driverName());

    if (data.devModeData().IsEmpty()) {
      psWin->SetDevMode(nullptr);
    } else {
      // Check minimum length of DEVMODE data.
      auto devModeDataLength = data.devModeData().Length();
      if (devModeDataLength < sizeof(DEVMODEW)) {
        NS_WARNING("DEVMODE data is too short.");
        return NS_ERROR_FAILURE;
      }

      DEVMODEW* devMode = reinterpret_cast(
          const_cast(data.devModeData().Elements()));

      // Check actual length of DEVMODE data.
      if ((devMode->dmSize + devMode->dmDriverExtra) != devModeDataLength) {
        NS_WARNING("DEVMODE length is incorrect.");
        return NS_ERROR_FAILURE;
      }

      psWin->SetDevMode(devMode);  // Copies
    }
  }

  return NS_OK;
}

Minimal test - lines (117, 127)

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

path: .spaces[2].metrics.cognitive.average
old: 7.0
new: 0.0

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

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

path: .spaces[2].metrics.nargs.average
old: 2.0
new: 1.0

path: .spaces[2].metrics.nargs.sum
old: 2.0
new: 1.0

path: .spaces[2].metrics.loc.ploc
old: 25.0
new: 9.0

path: .spaces[2].metrics.loc.sloc
old: 25.0
new: 11.0

path: .spaces[2].metrics.loc.cloc
old: 0.0
new: 2.0

path: .spaces[2].metrics.loc.lloc
old: 12.0
new: 4.0

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

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

path: .spaces[2].metrics.mi.mi_original
old: 82.72305108654508
new: 105.3974001211668

path: .spaces[2].metrics.mi.mi_sei
old: 44.15238287477253
new: 107.1359528256673

path: .spaces[2].metrics.mi.mi_visual_studio
old: 48.37605326698544
new: 61.63590650360632

path: .spaces[2].metrics.halstead.N2
old: 57.0
new: 16.0

path: .spaces[2].metrics.halstead.purity_ratio
old: 1.3540136631735746
new: 1.752186126789239

path: .spaces[2].metrics.halstead.vocabulary
old: 45.0
new: 20.0

path: .spaces[2].metrics.halstead.time
old: 660.8529892583375
new: 59.72118822026174

path: .spaces[2].metrics.halstead.n1
old: 15.0
new: 9.0

path: .spaces[2].metrics.halstead.level
old: 0.07017543859649122
new: 0.15277777777777776

path: .spaces[2].metrics.halstead.difficulty
old: 14.25
new: 6.545454545454546

path: .spaces[2].metrics.halstead.N1
old: 95.0
new: 22.0

path: .spaces[2].metrics.halstead.effort
old: 11895.353806650077
new: 1074.9813879647113

path: .spaces[2].metrics.halstead.length
old: 152.0
new: 38.0

path: .spaces[2].metrics.halstead.estimated_program_length
old: 205.81007680238335
new: 66.58307281799108

path: .spaces[2].metrics.halstead.bugs
old: 0.1736988678931838
new: 0.03497942841987602

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

path: .spaces[2].metrics.halstead.volume
old: 834.7616706421105
new: 164.2332676057198

Code

nsresult nsPrintSettingsServiceWin::_CreatePrintSettings(
    nsIPrintSettings** _retval) {
  *_retval = nullptr;
  nsPrintSettingsWin* printSettings =
      new nsPrintSettingsWin();  // does not initially ref count
  NS_ENSURE_TRUE(printSettings, NS_ERROR_OUT_OF_MEMORY);

  NS_ADDREF(*_retval = printSettings);  // ref count

  return NS_OK;
}