# Global Metrics

path: .metrics.cognitive.average
old: 0.0
new: 0.3333333333333333
path: .metrics.cognitive.sum
old: 0.0
new: 4.0
path: .metrics.mi.mi_visual_studio
old: 50.97213291753987
new: 31.618595804349944
path: .metrics.mi.mi_original
old: 87.16234728899316
new: 54.0677988254384
path: .metrics.mi.mi_sei
old: 81.00116104482834
new: 24.750880751290016
path: .metrics.nom.functions
old: 4.0
new: 12.0
path: .metrics.nom.total
old: 4.0
new: 12.0
path: .metrics.cyclomatic.average
old: 1.0
new: 1.2666666666666666
path: .metrics.cyclomatic.sum
old: 5.0
new: 19.0
path: .metrics.nexits.sum
old: 4.0
new: 9.0
path: .metrics.nexits.average
old: 1.0
new: 0.75
path: .metrics.nargs.sum
old: 1.0
new: 8.0
path: .metrics.nargs.average
old: 0.25
new: 0.6666666666666666
path: .metrics.halstead.length
old: 56.0
new: 309.0
path: .metrics.halstead.difficulty
old: 7.916666666666667
new: 26.289473684210527
path: .metrics.halstead.purity_ratio
old: 1.361407695670134
new: 0.8882844515754622
path: .metrics.halstead.bugs
old: 0.05250717770585681
new: 0.4352023569684583
path: .metrics.halstead.n1
old: 10.0
new: 18.0
path: .metrics.halstead.volume
old: 249.72817064368863
new: 1794.4726709157997
path: .metrics.halstead.vocabulary
old: 22.0
new: 56.0
path: .metrics.halstead.N1
old: 37.0
new: 198.0
path: .metrics.halstead.N2
old: 19.0
new: 111.0
path: .metrics.halstead.time
old: 109.8341491256964
new: 2620.8745588375496
path: .metrics.halstead.level
old: 0.1263157894736842
new: 0.038038038038038034
path: .metrics.halstead.effort
old: 1977.0146842625352
new: 47175.74205907589
path: .metrics.halstead.n2
old: 12.0
new: 38.0
path: .metrics.halstead.estimated_program_length
old: 76.2388309575275
new: 274.4798955368178
path: .metrics.loc.lloc
old: 8.0
new: 32.0
path: .metrics.loc.cloc
old: 5.0
new: 7.0
path: .metrics.loc.blank
old: 7.0
new: 21.0
path: .metrics.loc.ploc
old: 16.0
new: 66.0
path: .metrics.loc.sloc
old: 28.0
new: 94.0

# Spaces Data

## Minimal test - lines (8, 94)

path: .spaces[0].metrics.nargs.sum
old: 1.0
new: 8.0
path: .spaces[0].metrics.nargs.average
old: 1.0
new: 0.6666666666666666
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 1.2857142857142858
path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 18.0
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 20.0
path: .spaces[0].metrics.loc.ploc
old: 4.0
new: 65.0
path: .spaces[0].metrics.loc.sloc
old: 4.0
new: 87.0
path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 2.0
path: .spaces[0].metrics.loc.lloc
old: 2.0
new: 32.0
path: .spaces[0].metrics.mi.mi_original
old: 127.59108063160195
new: 55.59164732855322
path: .spaces[0].metrics.mi.mi_sei
old: 108.4759871562677
new: 17.970406785059083
path: .spaces[0].metrics.mi.mi_visual_studio
old: 74.61466703602454
new: 32.50973527985569
path: .spaces[0].metrics.halstead.n1
old: 8.0
new: 18.0
path: .spaces[0].metrics.halstead.bugs
old: 0.013885962850227664
new: 0.4380814505958993
path: .spaces[0].metrics.halstead.difficulty
old: 5.0
new: 26.75675675675676
path: .spaces[0].metrics.halstead.effort
old: 268.87218755408674
new: 47644.65415805241
path: .spaces[0].metrics.halstead.time
old: 14.937343753004818
new: 2646.925231002912
path: .spaces[0].metrics.halstead.N2
old: 5.0
new: 110.0
path: .spaces[0].metrics.halstead.N1
old: 10.0
new: 198.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 32.0
new: 267.8084245542328
path: .spaces[0].metrics.halstead.length
old: 15.0
new: 308.0
path: .spaces[0].metrics.halstead.level
old: 0.2
new: 0.03737373737373737
path: .spaces[0].metrics.halstead.purity_ratio
old: 2.1333333333333333
new: 0.8695078719293272
path: .spaces[0].metrics.halstead.vocabulary
old: 12.0
new: 55.0
path: .spaces[0].metrics.halstead.n2
old: 4.0
new: 37.0
path: .spaces[0].metrics.halstead.volume
old: 53.77443751081734
new: 1780.6587917655952
path: .spaces[0].metrics.nom.total
old: 1.0
new: 12.0
path: .spaces[0].metrics.nom.functions
old: 1.0
new: 12.0
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 4.0
path: .spaces[0].metrics.cognitive.average
old: 0.0
new: 0.3333333333333333
path: .spaces[0].metrics.nexits.average
old: 1.0
new: 0.75
path: .spaces[0].metrics.nexits.sum
old: 1.0
new: 9.0

### Code

    namespace mozilla {
    namespace widget {

    WindowsEMF::WindowsEMF() : mEmf(nullptr), mDC(nullptr) {}

    WindowsEMF::~WindowsEMF() { ReleaseAllResource(); }

    bool WindowsEMF::InitForDrawing(const wchar_t* aMetafilePath /* = nullptr */) {
      ReleaseAllResource();

      mDC = ::CreateEnhMetaFile(nullptr, aMetafilePath, nullptr, nullptr);
      return !!mDC;
    }

    bool WindowsEMF::InitFromFileContents(const wchar_t* aMetafilePath) {
      MOZ_ASSERT(aMetafilePath);
      ReleaseAllResource();

      mEmf = ::GetEnhMetaFileW(aMetafilePath);
      return !!mEmf;
    }

    bool WindowsEMF::InitFromFileContents(LPBYTE aBytes, UINT aSize) {
      MOZ_ASSERT(aBytes && aSize != 0);
      ReleaseAllResource();

      mEmf = SetEnhMetaFileBits(aSize, aBytes);

      return !!mEmf;
    }

    bool WindowsEMF::FinishDocument() {
      if (mDC) {
        mEmf = ::CloseEnhMetaFile(mDC);
        mDC = nullptr;
      }
      return !!mEmf;
    }

    void WindowsEMF::ReleaseEMFHandle() {
      if (mEmf) {
        ::DeleteEnhMetaFile(mEmf);
        mEmf = nullptr;
      }
    }

    void WindowsEMF::ReleaseAllResource() {
      FinishDocument();
      ReleaseEMFHandle();
    }

    bool WindowsEMF::Playback(HDC aDeviceContext, const RECT& aRect) {
      DebugOnly result = FinishDocument();
      MOZ_ASSERT(result, "This function should be used after InitXXX.");

      return ::PlayEnhMetaFile(aDeviceContext, mEmf, &aRect) != 0;
    }

    bool WindowsEMF::SaveToFile() {
      DebugOnly result = FinishDocument();
      MOZ_ASSERT(result, "This function should be used after InitXXX.");

      ReleaseEMFHandle();
      return true;
    }

    UINT WindowsEMF::GetEMFContentSize() {
      DebugOnly result = FinishDocument();
      MOZ_ASSERT(result, "This function should be used after InitXXX.");

      return GetEnhMetaFileBits(mEmf, 0, NULL);
    }

    bool WindowsEMF::GetEMFContentBits(LPBYTE aBytes) {
      DebugOnly result = FinishDocument();
      MOZ_ASSERT(result, "This function should be used after InitXXX.");

      UINT emfSize = GetEMFContentSize();
      if (GetEnhMetaFileBits(mEmf, emfSize, aBytes) != emfSize) {
        return false;
      }

      return true;
    }

    }  // namespace widget
    }  // namespace mozilla