Global Metrics

path: .metrics.cyclomatic.sum
old: 4.0
new: 26.0

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

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

path: .metrics.loc.sloc
old: 19.0
new: 137.0

path: .metrics.loc.blank
old: 4.0
new: 19.0

path: .metrics.loc.ploc
old: 8.0
new: 110.0

path: .metrics.loc.cloc
old: 7.0
new: 8.0

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

path: .metrics.nargs.average
old: 0.0
new: 0.875

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

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

path: .metrics.nom.total
old: 1.0
new: 16.0

path: .metrics.nom.functions
old: 1.0
new: 16.0

path: .metrics.halstead.difficulty
old: 2.0
new: 29.272727272727273

path: .metrics.halstead.estimated_program_length
old: 16.0
new: 502.97193686696926

path: .metrics.halstead.vocabulary
old: 8.0
new: 89.0

path: .metrics.halstead.length
old: 10.0
new: 449.0

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

path: .metrics.halstead.effort
old: 60.0
new: 85113.50799838726

path: .metrics.halstead.time
old: 3.3333333333333335
new: 4728.528222132625

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

path: .metrics.halstead.bugs
old: 0.005108729549290353
new: 0.6449772640024174

path: .metrics.halstead.n2
old: 4.0
new: 66.0

path: .metrics.halstead.N1
old: 6.0
new: 281.0

path: .metrics.halstead.volume
old: 30.0
new: 2907.6043105039125

path: .metrics.halstead.level
old: 0.5
new: 0.034161490683229816

path: .metrics.halstead.purity_ratio
old: 1.6
new: 1.1202047591691966

path: .metrics.mi.mi_visual_studio
old: 61.22448079114647
new: 25.640858625169

path: .metrics.mi.mi_original
old: 104.69386215286046
new: 43.845868249038986

path: .metrics.mi.mi_sei
old: 116.135221048307
new: 8.486563289871736

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

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

Spaces Data

Minimal test - lines (22, 24)

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

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

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

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

path: .spaces[0].spaces[0].spaces[0].metrics.halstead.n1
old: 4.0
new: 7.0

path: .spaces[0].spaces[0].spaces[0].metrics.halstead.bugs
old: 0.002712967490108627
new: 0.015295622567773837

path: .spaces[0].spaces[0].spaces[0].metrics.halstead.time
old: 1.289960052715201
new: 17.26871868465843

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

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

path: .spaces[0].spaces[0].spaces[0].metrics.halstead.difficulty
old: 2.0
new: 4.666666666666667

path: .spaces[0].spaces[0].spaces[0].metrics.halstead.effort
old: 23.21928094887362
new: 310.8369363238518

path: .spaces[0].spaces[0].spaces[0].metrics.halstead.volume
old: 11.60964047443681
new: 66.60791492653966

path: .spaces[0].spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 8.0
new: 35.161259458730164

path: .spaces[0].spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 1.6
new: 1.9534033032627869

path: .spaces[0].spaces[0].spaces[0].metrics.halstead.vocabulary
old: 5.0
new: 13.0

path: .spaces[0].spaces[0].spaces[0].metrics.halstead.length
old: 5.0
new: 18.0

path: .spaces[0].spaces[0].spaces[0].metrics.halstead.N1
old: 4.0
new: 10.0

path: .spaces[0].spaces[0].spaces[0].metrics.halstead.level
old: 0.5
new: 0.21428571428571427

path: .spaces[0].spaces[0].spaces[0].metrics.mi.mi_sei
old: 152.37629276875444
new: 113.59397456600368

path: .spaces[0].spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 92.40962204246613
new: 76.68923928350978

path: .spaces[0].spaces[0].spaces[0].metrics.mi.mi_original
old: 158.02045369261705
new: 131.13859917480173

Code

TaskbarPreviewButton::TaskbarPreviewButton(TaskbarWindowPreview* preview,
                                           uint32_t index)
    : mPreview(preview), mIndex(index) {}

Minimal test - lines (17, 136)

path: .spaces[0].spaces[0].metrics.halstead.N1
old: 5.0
new: 280.0

path: .spaces[0].spaces[0].metrics.halstead.N2
old: 2.0
new: 164.0

path: .spaces[0].spaces[0].metrics.halstead.volume
old: 18.094737505048094
new: 2845.7695756451394

path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 6.0
new: 85.0

path: .spaces[0].spaces[0].metrics.halstead.length
old: 7.0
new: 444.0

path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 2.0
new: 30.419354838709676

path: .spaces[0].spaces[0].metrics.halstead.n2
old: 2.0
new: 62.0

path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 10.0
new: 473.20209623329754

path: .spaces[0].spaces[0].metrics.halstead.time
old: 2.0105263894497885
new: 4809.248583930765

path: .spaces[0].spaces[0].metrics.halstead.level
old: 0.5
new: 0.032873806998939555

path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 1.4285714285714286
new: 1.0657704870119311

path: .spaces[0].spaces[0].metrics.halstead.effort
old: 36.18947501009619
new: 86566.47451075376

path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.003646981838562912
new: 0.6522967767893506

path: .spaces[0].spaces[0].metrics.halstead.n1
old: 4.0
new: 23.0

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

path: .spaces[0].spaces[0].metrics.loc.ploc
old: 4.0
new: 102.0

path: .spaces[0].spaces[0].metrics.loc.sloc
old: 6.0
new: 120.0

path: .spaces[0].spaces[0].metrics.loc.blank
old: 2.0
new: 18.0

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

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

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

path: .spaces[0].spaces[0].metrics.nexits.sum
old: 0.0
new: 14.0

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

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

path: .spaces[0].spaces[0].metrics.cyclomatic.sum
old: 2.0
new: 24.0

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

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

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

path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 73.95103310896104
new: 27.230392952794126

path: .spaces[0].spaces[0].metrics.mi.mi_original
old: 126.45626661632338
new: 46.56397194927795

path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: 106.94061646349851
new: -6.079563950989581

Code

namespace widget {

NS_IMPL_ISUPPORTS(TaskbarPreviewButton, nsITaskbarPreviewButton,
                  nsISupportsWeakReference)

TaskbarPreviewButton::TaskbarPreviewButton(TaskbarWindowPreview* preview,
                                           uint32_t index)
    : mPreview(preview), mIndex(index) {}

TaskbarPreviewButton::~TaskbarPreviewButton() { SetVisible(false); }

NS_IMETHODIMP
TaskbarPreviewButton::GetTooltip(nsAString& aTooltip) {
  aTooltip = mTooltip;
  return NS_OK;
}

NS_IMETHODIMP
TaskbarPreviewButton::SetTooltip(const nsAString& aTooltip) {
  mTooltip = aTooltip;
  size_t destLength = sizeof Button().szTip / (sizeof Button().szTip[0]);
  wchar_t* tooltip = &(Button().szTip[0]);
  StringCchCopyNW(tooltip, destLength, mTooltip.get(), mTooltip.Length());
  return Update();
}

NS_IMETHODIMP
TaskbarPreviewButton::GetDismissOnClick(bool* dismiss) {
  *dismiss = (Button().dwFlags & THBF_DISMISSONCLICK) == THBF_DISMISSONCLICK;
  return NS_OK;
}

NS_IMETHODIMP
TaskbarPreviewButton::SetDismissOnClick(bool dismiss) {
  if (dismiss)
    Button().dwFlags |= THBF_DISMISSONCLICK;
  else
    Button().dwFlags &= ~THBF_DISMISSONCLICK;
  return Update();
}

NS_IMETHODIMP
TaskbarPreviewButton::GetHasBorder(bool* hasBorder) {
  *hasBorder = (Button().dwFlags & THBF_NOBACKGROUND) != THBF_NOBACKGROUND;
  return NS_OK;
}

NS_IMETHODIMP
TaskbarPreviewButton::SetHasBorder(bool hasBorder) {
  if (hasBorder)
    Button().dwFlags &= ~THBF_NOBACKGROUND;
  else
    Button().dwFlags |= THBF_NOBACKGROUND;
  return Update();
}

NS_IMETHODIMP
TaskbarPreviewButton::GetDisabled(bool* disabled) {
  *disabled = (Button().dwFlags & THBF_DISABLED) == THBF_DISABLED;
  return NS_OK;
}

NS_IMETHODIMP
TaskbarPreviewButton::SetDisabled(bool disabled) {
  if (disabled)
    Button().dwFlags |= THBF_DISABLED;
  else
    Button().dwFlags &= ~THBF_DISABLED;
  return Update();
}

NS_IMETHODIMP
TaskbarPreviewButton::GetImage(imgIContainer** img) {
  if (mImage)
    NS_ADDREF(*img = mImage);
  else
    *img = nullptr;
  return NS_OK;
}

NS_IMETHODIMP
TaskbarPreviewButton::SetImage(imgIContainer* img) {
  if (Button().hIcon) ::DestroyIcon(Button().hIcon);
  if (img) {
    nsresult rv;
    rv = nsWindowGfx::CreateIcon(
        img, false, LayoutDeviceIntPoint(),
        nsWindowGfx::GetIconMetrics(nsWindowGfx::kRegularIcon),
        &Button().hIcon);
    NS_ENSURE_SUCCESS(rv, rv);
  } else {
    Button().hIcon = nullptr;
  }
  return Update();
}

NS_IMETHODIMP
TaskbarPreviewButton::GetVisible(bool* visible) {
  *visible = (Button().dwFlags & THBF_HIDDEN) != THBF_HIDDEN;
  return NS_OK;
}

NS_IMETHODIMP
TaskbarPreviewButton::SetVisible(bool visible) {
  if (visible)
    Button().dwFlags &= ~THBF_HIDDEN;
  else
    Button().dwFlags |= THBF_HIDDEN;
  return Update();
}

THUMBBUTTON& TaskbarPreviewButton::Button() {
  return mPreview->mThumbButtons[mIndex];
}

nsresult TaskbarPreviewButton::Update() {
  return mPreview->UpdateButton(mIndex);
}

}  // namespace widget

Minimal test - lines (16, 137)

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

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

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

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

path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 14.0

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

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

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

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

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

path: .spaces[0].metrics.loc.blank
old: 3.0
new: 17.0

path: .spaces[0].metrics.loc.ploc
old: 7.0
new: 104.0

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

path: .spaces[0].metrics.loc.sloc
old: 11.0
new: 122.0

path: .spaces[0].metrics.mi.mi_original
old: 114.67086657648636
new: 46.02915453078924

path: .spaces[0].metrics.mi.mi_visual_studio
old: 67.05898630203882
new: 26.91763422853172

path: .spaces[0].metrics.mi.mi_sei
old: 112.55461167758156
new: 0.24057579741051335

path: .spaces[0].metrics.halstead.vocabulary
old: 7.0
new: 86.0

path: .spaces[0].metrics.halstead.N2
old: 3.0
new: 165.0

path: .spaces[0].metrics.halstead.n1
old: 4.0
new: 23.0

path: .spaces[0].metrics.halstead.volume
old: 25.26619429851844
new: 2866.114080597136

path: .spaces[0].metrics.halstead.time
old: 2.807354922057604
new: 4795.812581951557

path: .spaces[0].metrics.halstead.n2
old: 3.0
new: 63.0

path: .spaces[0].metrics.halstead.bugs
old: 0.004556086527391188
new: 0.6510812928296323

path: .spaces[0].metrics.halstead.difficulty
old: 2.0
new: 30.11904761904762

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.4172097224626077
new: 1.0776021528470987

path: .spaces[0].metrics.halstead.N1
old: 6.0
new: 281.0

path: .spaces[0].metrics.halstead.estimated_program_length
old: 12.754887502163468
new: 480.6105601698061

path: .spaces[0].metrics.halstead.effort
old: 50.53238859703688
new: 86324.62647512803

path: .spaces[0].metrics.halstead.length
old: 9.0
new: 446.0

path: .spaces[0].metrics.halstead.level
old: 0.5
new: 0.03320158102766798

Code

namespace mozilla {
namespace widget {

NS_IMPL_ISUPPORTS(TaskbarPreviewButton, nsITaskbarPreviewButton,
                  nsISupportsWeakReference)

TaskbarPreviewButton::TaskbarPreviewButton(TaskbarWindowPreview* preview,
                                           uint32_t index)
    : mPreview(preview), mIndex(index) {}

TaskbarPreviewButton::~TaskbarPreviewButton() { SetVisible(false); }

NS_IMETHODIMP
TaskbarPreviewButton::GetTooltip(nsAString& aTooltip) {
  aTooltip = mTooltip;
  return NS_OK;
}

NS_IMETHODIMP
TaskbarPreviewButton::SetTooltip(const nsAString& aTooltip) {
  mTooltip = aTooltip;
  size_t destLength = sizeof Button().szTip / (sizeof Button().szTip[0]);
  wchar_t* tooltip = &(Button().szTip[0]);
  StringCchCopyNW(tooltip, destLength, mTooltip.get(), mTooltip.Length());
  return Update();
}

NS_IMETHODIMP
TaskbarPreviewButton::GetDismissOnClick(bool* dismiss) {
  *dismiss = (Button().dwFlags & THBF_DISMISSONCLICK) == THBF_DISMISSONCLICK;
  return NS_OK;
}

NS_IMETHODIMP
TaskbarPreviewButton::SetDismissOnClick(bool dismiss) {
  if (dismiss)
    Button().dwFlags |= THBF_DISMISSONCLICK;
  else
    Button().dwFlags &= ~THBF_DISMISSONCLICK;
  return Update();
}

NS_IMETHODIMP
TaskbarPreviewButton::GetHasBorder(bool* hasBorder) {
  *hasBorder = (Button().dwFlags & THBF_NOBACKGROUND) != THBF_NOBACKGROUND;
  return NS_OK;
}

NS_IMETHODIMP
TaskbarPreviewButton::SetHasBorder(bool hasBorder) {
  if (hasBorder)
    Button().dwFlags &= ~THBF_NOBACKGROUND;
  else
    Button().dwFlags |= THBF_NOBACKGROUND;
  return Update();
}

NS_IMETHODIMP
TaskbarPreviewButton::GetDisabled(bool* disabled) {
  *disabled = (Button().dwFlags & THBF_DISABLED) == THBF_DISABLED;
  return NS_OK;
}

NS_IMETHODIMP
TaskbarPreviewButton::SetDisabled(bool disabled) {
  if (disabled)
    Button().dwFlags |= THBF_DISABLED;
  else
    Button().dwFlags &= ~THBF_DISABLED;
  return Update();
}

NS_IMETHODIMP
TaskbarPreviewButton::GetImage(imgIContainer** img) {
  if (mImage)
    NS_ADDREF(*img = mImage);
  else
    *img = nullptr;
  return NS_OK;
}

NS_IMETHODIMP
TaskbarPreviewButton::SetImage(imgIContainer* img) {
  if (Button().hIcon) ::DestroyIcon(Button().hIcon);
  if (img) {
    nsresult rv;
    rv = nsWindowGfx::CreateIcon(
        img, false, LayoutDeviceIntPoint(),
        nsWindowGfx::GetIconMetrics(nsWindowGfx::kRegularIcon),
        &Button().hIcon);
    NS_ENSURE_SUCCESS(rv, rv);
  } else {
    Button().hIcon = nullptr;
  }
  return Update();
}

NS_IMETHODIMP
TaskbarPreviewButton::GetVisible(bool* visible) {
  *visible = (Button().dwFlags & THBF_HIDDEN) != THBF_HIDDEN;
  return NS_OK;
}

NS_IMETHODIMP
TaskbarPreviewButton::SetVisible(bool visible) {
  if (visible)
    Button().dwFlags &= ~THBF_HIDDEN;
  else
    Button().dwFlags |= THBF_HIDDEN;
  return Update();
}

THUMBBUTTON& TaskbarPreviewButton::Button() {
  return mPreview->mThumbButtons[mIndex];
}

nsresult TaskbarPreviewButton::Update() {
  return mPreview->UpdateButton(mIndex);
}

}  // namespace widget
}  // namespace mozilla