# Global Metrics

path: .metrics.halstead.vocabulary
old: 136.0
new: 82.0
path: .metrics.halstead.length
old: 472.0
new: 326.0
path: .metrics.halstead.n1
old: 13.0
new: 21.0
path: .metrics.halstead.bugs
old: 0.40097205511302497
new: 0.43687564028947873
path: .metrics.halstead.level
old: 0.08018252933507171
new: 0.04368063014679556
path: .metrics.halstead.time
old: 2317.8244332798668
new: 2636.00434250494
path: .metrics.halstead.N2
old: 236.0
new: 133.0
path: .metrics.halstead.estimated_program_length
old: 902.0350004925608
new: 454.01364346969007
path: .metrics.halstead.difficulty
old: 12.471544715447154
new: 22.89344262295082
path: .metrics.halstead.N1
old: 236.0
new: 193.0
path: .metrics.halstead.n2
old: 123.0
new: 61.0
path: .metrics.halstead.purity_ratio
old: 1.911091102738476
new: 1.3926798879438345
path: .metrics.halstead.volume
old: 3345.28246107016
new: 2072.5619535054952
path: .metrics.halstead.effort
old: 41720.8397990376
new: 47448.07816508892
path: .metrics.nargs.average
old: 1.0
new: 1.5714285714285714
path: .metrics.nargs.sum
old: 2.0
new: 11.0
path: .metrics.cyclomatic.sum
old: 14.0
new: 21.0
path: .metrics.cyclomatic.average
old: 1.0
new: 2.1
path: .metrics.mi.mi_sei
old: 25.20499134406134
new: 18.716944038547847
path: .metrics.mi.mi_visual_studio
old: 25.598093182082373
new: 29.25164107054608
path: .metrics.mi.mi_original
old: 43.77273934136086
new: 50.02030623063379
path: .metrics.loc.lloc
old: 1.0
new: 36.0
path: .metrics.loc.cloc
old: 43.0
new: 8.0
path: .metrics.loc.blank
old: 33.0
new: 15.0
path: .metrics.loc.sloc
old: 156.0
new: 112.0
path: .metrics.loc.ploc
old: 80.0
new: 89.0
path: .metrics.cognitive.sum
old: 0.0
new: 10.0
path: .metrics.cognitive.average
old: 0.0
new: 1.4285714285714286
path: .metrics.nexits.sum
old: 1.0
new: 14.0
path: .metrics.nexits.average
old: 0.5
new: 2.0
path: .metrics.nom.total
old: 2.0
new: 7.0
path: .metrics.nom.functions
old: 2.0
new: 7.0

# Spaces Data

## Minimal test - lines (12, 111)

path: .spaces[0].spaces[0].metrics.nargs.average
old: null
new: 1.5714285714285714
path: .spaces[0].spaces[0].metrics.nargs.sum
old: 0.0
new: 11.0
path: .spaces[0].spaces[0].metrics.cognitive.sum
old: 0.0
new: 10.0
path: .spaces[0].spaces[0].metrics.cognitive.average
old: null
new: 1.4285714285714286
path: .spaces[0].spaces[0].metrics.halstead.n2
old: 1.0
new: 56.0
path: .spaces[0].spaces[0].metrics.halstead.level
old: null
new: 0.041666666666666664
path: .spaces[0].spaces[0].metrics.halstead.time
old: 0.0
new: 2673.8289240298245
path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.0
new: 0.4410449224856547
path: .spaces[0].spaces[0].metrics.halstead.N2
old: 1.0
new: 128.0
path: .spaces[0].spaces[0].metrics.halstead.volume
old: 0.0
new: 2005.3716930223684
path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: null
new: 417.45054151357976
path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 0.0
new: 24.0
path: .spaces[0].spaces[0].metrics.halstead.N1
old: 0.0
new: 192.0
path: .spaces[0].spaces[0].metrics.halstead.length
old: 1.0
new: 320.0
path: .spaces[0].spaces[0].metrics.halstead.n1
old: 0.0
new: 21.0
path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: null
new: 1.3045329422299368
path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 1.0
new: 77.0
path: .spaces[0].spaces[0].metrics.halstead.effort
old: 0.0
new: 48128.92063253684
path: .spaces[0].spaces[0].metrics.mi.mi_original
old: null
new: 52.48760251780581
path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: null
new: 30.694504396377667
path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: null
new: 15.21331876411216
path: .spaces[0].spaces[0].metrics.loc.lloc
old: 0.0
new: 36.0
path: .spaces[0].spaces[0].metrics.loc.blank
old: 0.0
new: 14.0
path: .spaces[0].spaces[0].metrics.loc.cloc
old: 0.0
new: 3.0
path: .spaces[0].spaces[0].metrics.loc.sloc
old: 1.0
new: 100.0
path: .spaces[0].spaces[0].metrics.loc.ploc
old: 1.0
new: 83.0
path: .spaces[0].spaces[0].metrics.nom.total
old: 0.0
new: 7.0
path: .spaces[0].spaces[0].metrics.nom.functions
old: 0.0
new: 7.0
path: .spaces[0].spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 19.0
path: .spaces[0].spaces[0].metrics.cyclomatic.average
old: 1.0
new: 2.375
path: .spaces[0].spaces[0].metrics.nexits.sum
old: 0.0
new: 14.0
path: .spaces[0].spaces[0].metrics.nexits.average
old: null
new: 2.0

### Code

    namespace widget {

    NS_IMPL_ISUPPORTS(HeadlessClipboard, nsIClipboard)

    HeadlessClipboard::HeadlessClipboard()
        : mClipboard(MakeUnique()) {}

    NS_IMETHODIMP
    HeadlessClipboard::SetData(nsITransferable* aTransferable,
                               nsIClipboardOwner* anOwner,
                               int32_t aWhichClipboard) {
      if (aWhichClipboard != kGlobalClipboard) {
        return NS_ERROR_NOT_IMPLEMENTED;
      }

      // Clear out the clipboard in order to set the new data.
      EmptyClipboard(aWhichClipboard);

      // Only support plain text for now.
      nsCOMPtr clip;
      nsresult rv =
          aTransferable->GetTransferData(kUnicodeMime, getter_AddRefs(clip));
      if (NS_FAILED(rv)) {
        return rv;
      }
      nsCOMPtr wideString = do_QueryInterface(clip);
      if (!wideString) {
        return NS_ERROR_NOT_IMPLEMENTED;
      }
      nsAutoString utf16string;
      wideString->GetData(utf16string);
      mClipboard->SetText(utf16string);

      return NS_OK;
    }

    NS_IMETHODIMP
    HeadlessClipboard::GetData(nsITransferable* aTransferable,
                               int32_t aWhichClipboard) {
      if (aWhichClipboard != kGlobalClipboard) {
        return NS_ERROR_NOT_IMPLEMENTED;
      }

      nsresult rv;
      nsCOMPtr dataWrapper =
          do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
      rv = dataWrapper->SetData(mClipboard->GetText());
      if (NS_WARN_IF(NS_FAILED(rv))) {
        return rv;
      }
      nsCOMPtr genericDataWrapper = do_QueryInterface(dataWrapper);
      rv = aTransferable->SetTransferData(kUnicodeMime, genericDataWrapper);
      if (NS_WARN_IF(NS_FAILED(rv))) {
        return rv;
      }
      return NS_OK;
    }

    NS_IMETHODIMP
    HeadlessClipboard::EmptyClipboard(int32_t aWhichClipboard) {
      if (aWhichClipboard != kGlobalClipboard) {
        return NS_ERROR_NOT_IMPLEMENTED;
      }
      mClipboard->Clear();
      return NS_OK;
    }

    NS_IMETHODIMP
    HeadlessClipboard::HasDataMatchingFlavors(
        const nsTArray& aFlavorList, int32_t aWhichClipboard,
        bool* aHasType) {
      *aHasType = false;
      if (aWhichClipboard != kGlobalClipboard) {
        return NS_ERROR_NOT_IMPLEMENTED;
      }
      // Retrieve the union of all aHasType in aFlavorList
      for (auto& flavor : aFlavorList) {
        if (flavor.EqualsLiteral(kUnicodeMime) && mClipboard->HasText()) {
          *aHasType = true;
          break;
        }
      }
      return NS_OK;
    }

    NS_IMETHODIMP
    HeadlessClipboard::SupportsSelectionClipboard(bool* aIsSupported) {
      *aIsSupported = false;
      return NS_OK;
    }

    NS_IMETHODIMP
    HeadlessClipboard::SupportsFindClipboard(bool* _retval) {
      NS_ENSURE_ARG_POINTER(_retval);

      *_retval = false;
      return NS_OK;
    }

    }  // namespace widget

## Minimal test - lines (11, 112)

path: .spaces[0].metrics.nom.total
old: 2.0
new: 7.0
path: .spaces[0].metrics.nom.functions
old: 2.0
new: 7.0
path: .spaces[0].metrics.cognitive.average
old: 0.0
new: 1.4285714285714286
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 10.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 2.2222222222222223
path: .spaces[0].metrics.cyclomatic.sum
old: 13.0
new: 20.0
path: .spaces[0].metrics.halstead.N1
old: 236.0
new: 193.0
path: .spaces[0].metrics.halstead.difficulty
old: 12.516528925619834
new: 23.76315789473684
path: .spaces[0].metrics.halstead.n1
old: 13.0
new: 21.0
path: .spaces[0].metrics.halstead.length
old: 469.0
new: 322.0
path: .spaces[0].metrics.halstead.level
old: 0.07989435457246616
new: 0.042081949058693245
path: .spaces[0].metrics.halstead.bugs
old: 0.3994256849568112
new: 0.4408330483398576
path: .spaces[0].metrics.halstead.effort
old: 41479.724669642565
new: 48094.24372551844
path: .spaces[0].metrics.halstead.n2
old: 121.0
new: 57.0
path: .spaces[0].metrics.halstead.time
old: 2304.4291483134757
new: 2671.902429195469
path: .spaces[0].metrics.halstead.volume
old: 3313.995830324695
new: 2023.899514473644
path: .spaces[0].metrics.halstead.estimated_program_length
old: 885.2881680460602
new: 424.7133966857442
path: .spaces[0].metrics.halstead.N2
old: 233.0
new: 129.0
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.887608034213348
new: 1.3189857039929944
path: .spaces[0].metrics.halstead.vocabulary
old: 134.0
new: 78.0
path: .spaces[0].metrics.loc.lloc
old: 1.0
new: 36.0
path: .spaces[0].metrics.loc.cloc
old: 38.0
new: 4.0
path: .spaces[0].metrics.loc.blank
old: 30.0
new: 13.0
path: .spaces[0].metrics.loc.sloc
old: 144.0
new: 102.0
path: .spaces[0].metrics.loc.ploc
old: 76.0
new: 85.0
path: .spaces[0].metrics.nargs.average
old: 1.0
new: 1.5714285714285714
path: .spaces[0].metrics.nargs.sum
old: 2.0
new: 11.0
path: .spaces[0].metrics.nexits.sum
old: 1.0
new: 14.0
path: .spaces[0].metrics.nexits.average
old: 0.5
new: 2.0
path: .spaces[0].metrics.mi.mi_original
old: 45.34829285998386
new: 51.888977237481114
path: .spaces[0].metrics.mi.mi_visual_studio
old: 26.51946950876249
new: 30.34443113302989
path: .spaces[0].metrics.mi.mi_sei
old: 26.7685281858245
new: 16.295328421953535

### Code

    namespace mozilla {
    namespace widget {

    NS_IMPL_ISUPPORTS(HeadlessClipboard, nsIClipboard)

    HeadlessClipboard::HeadlessClipboard()
        : mClipboard(MakeUnique()) {}

    NS_IMETHODIMP
    HeadlessClipboard::SetData(nsITransferable* aTransferable,
                               nsIClipboardOwner* anOwner,
                               int32_t aWhichClipboard) {
      if (aWhichClipboard != kGlobalClipboard) {
        return NS_ERROR_NOT_IMPLEMENTED;
      }

      // Clear out the clipboard in order to set the new data.
      EmptyClipboard(aWhichClipboard);

      // Only support plain text for now.
      nsCOMPtr clip;
      nsresult rv =
          aTransferable->GetTransferData(kUnicodeMime, getter_AddRefs(clip));
      if (NS_FAILED(rv)) {
        return rv;
      }
      nsCOMPtr wideString = do_QueryInterface(clip);
      if (!wideString) {
        return NS_ERROR_NOT_IMPLEMENTED;
      }
      nsAutoString utf16string;
      wideString->GetData(utf16string);
      mClipboard->SetText(utf16string);

      return NS_OK;
    }

    NS_IMETHODIMP
    HeadlessClipboard::GetData(nsITransferable* aTransferable,
                               int32_t aWhichClipboard) {
      if (aWhichClipboard != kGlobalClipboard) {
        return NS_ERROR_NOT_IMPLEMENTED;
      }

      nsresult rv;
      nsCOMPtr dataWrapper =
          do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
      rv = dataWrapper->SetData(mClipboard->GetText());
      if (NS_WARN_IF(NS_FAILED(rv))) {
        return rv;
      }
      nsCOMPtr genericDataWrapper = do_QueryInterface(dataWrapper);
      rv = aTransferable->SetTransferData(kUnicodeMime, genericDataWrapper);
      if (NS_WARN_IF(NS_FAILED(rv))) {
        return rv;
      }
      return NS_OK;
    }

    NS_IMETHODIMP
    HeadlessClipboard::EmptyClipboard(int32_t aWhichClipboard) {
      if (aWhichClipboard != kGlobalClipboard) {
        return NS_ERROR_NOT_IMPLEMENTED;
      }
      mClipboard->Clear();
      return NS_OK;
    }

    NS_IMETHODIMP
    HeadlessClipboard::HasDataMatchingFlavors(
        const nsTArray& aFlavorList, int32_t aWhichClipboard,
        bool* aHasType) {
      *aHasType = false;
      if (aWhichClipboard != kGlobalClipboard) {
        return NS_ERROR_NOT_IMPLEMENTED;
      }
      // Retrieve the union of all aHasType in aFlavorList
      for (auto& flavor : aFlavorList) {
        if (flavor.EqualsLiteral(kUnicodeMime) && mClipboard->HasText()) {
          *aHasType = true;
          break;
        }
      }
      return NS_OK;
    }

    NS_IMETHODIMP
    HeadlessClipboard::SupportsSelectionClipboard(bool* aIsSupported) {
      *aIsSupported = false;
      return NS_OK;
    }

    NS_IMETHODIMP
    HeadlessClipboard::SupportsFindClipboard(bool* _retval) {
      NS_ENSURE_ARG_POINTER(_retval);

      *_retval = false;
      return NS_OK;
    }

    }  // namespace widget
    }  // namespace mozilla