# Global Metrics

path: .metrics.cognitive.sum
old: 10.0
new: 0.0
path: .metrics.cognitive.average
old: 0.47619047619047616
new: 0.0
path: .metrics.mi.mi_sei
old: -11.287668715533744
new: 11.331361009775016
path: .metrics.mi.mi_visual_studio
old: 15.589820948356088
new: 19.750064897994527
path: .metrics.mi.mi_original
old: 26.65859382168891
new: 33.77261097557064
path: .metrics.loc.lloc
old: 71.0
new: 37.0
path: .metrics.loc.blank
old: 51.0
new: 35.0
path: .metrics.loc.cloc
old: 24.0
new: 52.0
path: .metrics.loc.sloc
old: 257.0
new: 213.0
path: .metrics.loc.ploc
old: 182.0
new: 126.0
path: .metrics.halstead.purity_ratio
old: 0.954619732374659
new: 0.5412076665671524
path: .metrics.halstead.n1
old: 16.0
new: 19.0
path: .metrics.halstead.time
old: 13591.492552991707
new: 9030.939379924155
path: .metrics.halstead.effort
old: 244646.86595385073
new: 162556.9088386348
path: .metrics.halstead.vocabulary
old: 167.0
new: 60.0
path: .metrics.halstead.volume
old: 8949.049602478552
new: 3278.324280562728
path: .metrics.halstead.estimated_program_length
old: 1156.9991156380868
new: 300.37025494476956
path: .metrics.halstead.N1
old: 696.0
new: 341.0
path: .metrics.halstead.bugs
old: 1.303882679684064
new: 0.9928470888551232
path: .metrics.halstead.length
old: 1212.0
new: 555.0
path: .metrics.halstead.level
old: 0.03657945736434108
new: 0.02016724053123463
path: .metrics.halstead.n2
old: 151.0
new: 41.0
path: .metrics.halstead.N2
old: 516.0
new: 214.0
path: .metrics.halstead.difficulty
old: 27.337748344370866
new: 49.58536585365854
path: .metrics.nom.total
old: 21.0
new: 28.0
path: .metrics.nom.functions
old: 21.0
new: 28.0
path: .metrics.nargs.average
old: 1.5238095238095235
new: 0.5
path: .metrics.nargs.sum
old: 32.0
new: 14.0
path: .metrics.nexits.average
old: 0.3333333333333333
new: 0.5
path: .metrics.nexits.sum
old: 7.0
new: 14.0
path: .metrics.cyclomatic.sum
old: 31.0
new: 36.0
path: .metrics.cyclomatic.average
old: 1.4090909090909092
new: 1.1612903225806452

# Spaces Data

## Minimal test - lines (192, 193)

path: .spaces[1].metrics.cyclomatic.average
old: 4.0
new: 1.0
path: .spaces[1].metrics.cyclomatic.sum
old: 4.0
new: 1.0
path: .spaces[1].metrics.halstead.difficulty
old: 11.25
new: 6.0
path: .spaces[1].metrics.halstead.estimated_program_length
old: 203.01955000865388
new: 39.50977500432694
path: .spaces[1].metrics.halstead.effort
old: 9335.62806786978
new: 502.5708497116037
path: .spaces[1].metrics.halstead.n2
old: 32.0
new: 6.0
path: .spaces[1].metrics.halstead.volume
old: 829.8336060328692
new: 83.76180828526729
path: .spaces[1].metrics.halstead.level
old: 0.08888888888888889
new: 0.16666666666666666
path: .spaces[1].metrics.halstead.purity_ratio
old: 1.3356549342674595
new: 1.7958988638330426
path: .spaces[1].metrics.halstead.bugs
old: 0.14778865815587683
new: 0.021070601904317903
path: .spaces[1].metrics.halstead.n1
old: 12.0
new: 8.0
path: .spaces[1].metrics.halstead.vocabulary
old: 44.0
new: 14.0
path: .spaces[1].metrics.halstead.N1
old: 92.0
new: 13.0
path: .spaces[1].metrics.halstead.N2
old: 60.0
new: 9.0
path: .spaces[1].metrics.halstead.length
old: 152.0
new: 22.0
path: .spaces[1].metrics.halstead.time
old: 518.6460037705433
new: 27.920602761755763
path: .spaces[1].metrics.nexits.sum
old: 3.0
new: 0.0
path: .spaces[1].metrics.nexits.average
old: 3.0
new: 0.0
path: .spaces[1].metrics.mi.mi_sei
old: 68.8665549820994
new: 121.35125244839124
path: .spaces[1].metrics.mi.mi_original
old: 76.20073314105721
new: 136.51553446779872
path: .spaces[1].metrics.mi.mi_visual_studio
old: 44.56183224623229
new: 79.83364588760159
path: .spaces[1].metrics.loc.sloc
old: 38.0
new: 2.0
path: .spaces[1].metrics.loc.blank
old: 6.0
new: 0.0
path: .spaces[1].metrics.loc.lloc
old: 13.0
new: 0.0
path: .spaces[1].metrics.loc.cloc
old: 9.0
new: 0.0
path: .spaces[1].metrics.loc.ploc
old: 23.0
new: 2.0
path: .spaces[1].metrics.cognitive.sum
old: 3.0
new: 0.0
path: .spaces[1].metrics.cognitive.average
old: 3.0
new: 0.0

### Code

    nsCOMPtr::nsCOMPtr(const mozilla::OwningNonNull& aOther)
        : nsCOMPtr(aOther.get()) {}

## Minimal test - lines (204, 205)

path: .spaces[3].metrics.loc.lloc
old: 5.0
new: 0.0
path: .spaces[3].metrics.loc.blank
old: 1.0
new: 0.0
path: .spaces[3].metrics.loc.sloc
old: 9.0
new: 2.0
path: .spaces[3].metrics.loc.ploc
old: 8.0
new: 2.0
path: .spaces[3].metrics.nargs.average
old: 2.0
new: 1.0
path: .spaces[3].metrics.nargs.sum
old: 2.0
new: 1.0
path: .spaces[3].metrics.halstead.level
old: 0.11285266457680251
new: 0.16666666666666666
path: .spaces[3].metrics.halstead.difficulty
old: 8.86111111111111
new: 6.0
path: .spaces[3].metrics.halstead.vocabulary
old: 29.0
new: 14.0
path: .spaces[3].metrics.halstead.length
old: 65.0
new: 22.0
path: .spaces[3].metrics.halstead.N1
old: 36.0
new: 13.0
path: .spaces[3].metrics.halstead.n1
old: 11.0
new: 8.0
path: .spaces[3].metrics.halstead.volume
old: 315.76876468329215
new: 83.76180828526729
path: .spaces[3].metrics.halstead.N2
old: 29.0
new: 9.0
path: .spaces[3].metrics.halstead.bugs
old: 0.06618866864658426
new: 0.021070601904317903
path: .spaces[3].metrics.halstead.estimated_program_length
old: 113.11239783097189
new: 39.50977500432694
path: .spaces[3].metrics.halstead.n2
old: 18.0
new: 6.0
path: .spaces[3].metrics.halstead.time
old: 155.4478949598305
new: 27.920602761755763
path: .spaces[3].metrics.halstead.purity_ratio
old: 1.7401907358611055
new: 1.7958988638330426
path: .spaces[3].metrics.halstead.effort
old: 2798.0621092769497
new: 502.5708497116037
path: .spaces[3].metrics.mi.mi_visual_studio
old: 61.5490695131712
new: 79.83364588760159
path: .spaces[3].metrics.mi.mi_original
old: 105.24890886752276
new: 136.51553446779872
path: .spaces[3].metrics.mi.mi_sei
old: 76.24304674954124
new: 121.35125244839124

### Code

    RefPtr::RefPtr(const mozilla::OwningNonNull& aOther)
        : RefPtr(aOther.get()) {}

## Minimal test - lines (197, 199)

path: .spaces[2].metrics.halstead.N2
old: 59.0
new: 10.0
path: .spaces[2].metrics.halstead.n2
old: 27.0
new: 7.0
path: .spaces[2].metrics.halstead.effort
old: 10658.343660699697
new: 817.4925682500678
path: .spaces[2].metrics.halstead.length
old: 141.0
new: 28.0
path: .spaces[2].metrics.halstead.time
old: 592.1302033722054
new: 45.416253791670435
path: .spaces[2].metrics.halstead.N1
old: 82.0
new: 18.0
path: .spaces[2].metrics.halstead.n1
old: 13.0
new: 10.0
path: .spaces[2].metrics.halstead.vocabulary
old: 40.0
new: 17.0
path: .spaces[2].metrics.halstead.estimated_program_length
old: 176.48767889424784
new: 52.87076540327685
path: .spaces[2].metrics.halstead.level
old: 0.07040417209908735
new: 0.14
path: .spaces[2].metrics.halstead.volume
old: 750.3918613791182
new: 114.4489595550095
path: .spaces[2].metrics.halstead.purity_ratio
old: 1.251685665916651
new: 1.8882416215456015
path: .spaces[2].metrics.halstead.difficulty
old: 14.203703703703704
new: 7.142857142857143
path: .spaces[2].metrics.halstead.bugs
old: 0.16143779784598294
new: 0.029143024456734404
path: .spaces[2].metrics.loc.blank
old: 6.0
new: 0.0
path: .spaces[2].metrics.loc.ploc
old: 21.0
new: 3.0
path: .spaces[2].metrics.loc.lloc
old: 12.0
new: 1.0
path: .spaces[2].metrics.loc.cloc
old: 10.0
new: 0.0
path: .spaces[2].metrics.loc.sloc
old: 37.0
new: 3.0
path: .spaces[2].metrics.cyclomatic.sum
old: 4.0
new: 1.0
path: .spaces[2].metrics.cyclomatic.average
old: 4.0
new: 1.0
path: .spaces[2].metrics.cognitive.average
old: 4.0
new: 0.0
path: .spaces[2].metrics.cognitive.sum
old: 4.0
new: 0.0
path: .spaces[2].metrics.nargs.average
old: 1.0
new: 0.0
path: .spaces[2].metrics.nargs.sum
old: 1.0
new: 0.0
path: .spaces[2].metrics.mi.mi_visual_studio
old: 45.120487102434865
new: 75.04316395018249
path: .spaces[2].metrics.mi.mi_sei
old: 72.0740039268881
new: 109.53309269425488
path: .spaces[2].metrics.mi.mi_original
old: 77.15603294516362
new: 128.32381035481205

### Code

    nsCOMPtr& nsCOMPtr::operator=(const mozilla::OwningNonNull& aOther) {
      return operator=(aOther.get());
    }

## Minimal test - lines (209, 211)

path: .spaces[4].metrics.loc.lloc
old: 2.0
new: 1.0
path: .spaces[4].metrics.loc.ploc
old: 11.0
new: 3.0
path: .spaces[4].metrics.loc.sloc
old: 11.0
new: 3.0
path: .spaces[4].metrics.nargs.average
old: 4.0
new: 0.0
path: .spaces[4].metrics.nargs.sum
old: 4.0
new: 0.0
path: .spaces[4].metrics.mi.mi_original
old: 100.50108827090916
new: 128.32381035481205
path: .spaces[4].metrics.mi.mi_sei
old: 69.3933895197763
new: 109.53309269425488
path: .spaces[4].metrics.mi.mi_visual_studio
old: 58.77256624029775
new: 75.04316395018249
path: .spaces[4].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[4].metrics.nexits.average
old: 0.0
new: 1.0
path: .spaces[4].metrics.halstead.length
old: 85.0
new: 28.0
path: .spaces[4].metrics.halstead.level
old: 0.10769230769230768
new: 0.14
path: .spaces[4].metrics.halstead.time
old: 217.23757630863085
new: 45.416253791670435
path: .spaces[4].metrics.halstead.N2
old: 39.0
new: 10.0
path: .spaces[4].metrics.halstead.difficulty
old: 9.285714285714286
new: 7.142857142857143
path: .spaces[4].metrics.halstead.volume
old: 421.1066863828844
new: 114.4489595550095
path: .spaces[4].metrics.halstead.bugs
old: 0.0827339414310516
new: 0.029143024456734404
path: .spaces[4].metrics.halstead.estimated_program_length
old: 125.4579468272276
new: 52.87076540327685
path: .spaces[4].metrics.halstead.N1
old: 46.0
new: 18.0
path: .spaces[4].metrics.halstead.effort
old: 3910.2763735553553
new: 817.4925682500678
path: .spaces[4].metrics.halstead.vocabulary
old: 31.0
new: 17.0
path: .spaces[4].metrics.halstead.purity_ratio
old: 1.475975845026207
new: 1.8882416215456015
path: .spaces[4].metrics.halstead.n2
old: 21.0
new: 7.0

### Code

    RefPtr& RefPtr::operator=(const mozilla::OwningNonNull& aOther) {
      return operator=(aOther.get());
    }

## Minimal test - lines (15, 187)

path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 31.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 1.1923076923076923
path: .spaces[0].metrics.nom.functions
old: 1.0
new: 24.0
path: .spaces[0].metrics.nom.total
old: 1.0
new: 24.0
path: .spaces[0].metrics.halstead.volume
old: 286.7268228066066
new: 2468.6405976750298
path: .spaces[0].metrics.halstead.level
old: 0.09404388714733544
new: 0.023106546854942234
path: .spaces[0].metrics.halstead.difficulty
old: 10.633333333333333
new: 43.27777777777778
path: .spaces[0].metrics.halstead.length
old: 61.0
new: 427.0
path: .spaces[0].metrics.halstead.n1
old: 11.0
new: 19.0
path: .spaces[0].metrics.halstead.bugs
old: 0.07008696366961947
new: 0.7505171572084167
path: .spaces[0].metrics.halstead.vocabulary
old: 26.0
new: 55.0
path: .spaces[0].metrics.halstead.effort
old: 3048.8618825102503
new: 106837.27919938046
path: .spaces[0].metrics.halstead.time
old: 169.3812156950139
new: 5935.4043999655805
path: .spaces[0].metrics.halstead.N2
old: 29.0
new: 164.0
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.5845427334284925
new: 0.6248897489633521
path: .spaces[0].metrics.halstead.N1
old: 32.0
new: 263.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 96.65710673913804
new: 266.82792280735134
path: .spaces[0].metrics.halstead.n2
old: 15.0
new: 36.0
path: .spaces[0].metrics.nargs.average
old: 4.0
new: 0.5
path: .spaces[0].metrics.nargs.sum
old: 4.0
new: 12.0
path: .spaces[0].metrics.loc.sloc
old: 9.0
new: 173.0
path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 42.0
path: .spaces[0].metrics.loc.blank
old: 1.0
new: 28.0
path: .spaces[0].metrics.loc.lloc
old: 4.0
new: 35.0
path: .spaces[0].metrics.loc.ploc
old: 8.0
new: 103.0
path: .spaces[0].metrics.mi.mi_original
old: 105.7506062342182
new: 39.7672770225672
path: .spaces[0].metrics.mi.mi_sei
old: 76.96684305249981
new: 19.39385834851037
path: .spaces[0].metrics.mi.mi_visual_studio
old: 61.84245978609252
new: 23.255717557056844
path: .spaces[0].metrics.nexits.average
old: 1.0
new: 0.5
path: .spaces[0].metrics.nexits.sum
old: 1.0
new: 12.0

### Code

    namespace mozilla {

    // OwningNonNull is similar to a RefPtr, which is not null after initial
    // initialization. It has a restricted interface compared to RefPtr, with some
    // additional operations defined. The main use is in DOM bindings. Use it
    // outside DOM bindings only if you can ensure it never escapes without being
    // properly initialized, and you don't need to move it. Otherwise, use a
    // RefPtr instead.
    //
    // Compared to a plain RefPtr, in particular
    // - it is copyable but not movable
    // - it can be constructed and assigned from T& and is convertible to T&
    // implicitly
    // - it cannot be cleared by the user once initialized, though it can be
    //   re-assigned a new (non-null) value
    // - it is not convertible to bool, but there is an explicit isInitialized
    //   member function
    //
    // Beware that there are two cases where an OwningNonNull actually is nullptr
    // - it was default-constructed and not yet initialized
    // - it was cleared during CC unlinking.
    // All attempts to use it in an invalid state will trigger an assertion in debug
    // builds.
    //
    // The original intent of OwningNonNull was to implement a class with the
    // same auto-conversion and annotation semantics as mozilla::dom::NonNull
    // (i.e. never null once you have properly initialized it, auto-converts to T&),
    // but that holds a strong reference to the object involved. This was designed
    // for use in DOM bindings and in particular for storing what WebIDL represents
    // as InterfaceName (as opposed to `InterfaceName?`) in various containers
    // (dictionaries, sequences). DOM bindings never allow a default-constructed
    // uninitialized OwningNonNull to escape. RefPtr could have been used for this
    // use case, just like we could have used T* instead of NonNull, but it
    // seemed desirable to explicitly annotate the non-null nature of the things
    // involved to eliminate pointless null-checks, which otherwise tend to
    // proliferate.
    template
    class MOZ_IS_SMARTPTR_TO_REFCOUNTED OwningNonNull {
     public:
      using element_type = T;

      OwningNonNull() = default;

      MOZ_IMPLICIT OwningNonNull(T& aValue) { init(&aValue); }

      template
      MOZ_IMPLICIT OwningNonNull(already_AddRefed&& aValue) {
        init(aValue);
      }

      template
      MOZ_IMPLICIT OwningNonNull(RefPtr&& aValue) {
        init(std::move(aValue));
      }

      template
      MOZ_IMPLICIT OwningNonNull(const OwningNonNull& aValue) {
        init(aValue);
      }

      // This is no worse than get() in terms of const handling.
      operator T&() const { return ref(); }

      operator T*() const { return get(); }

      // Conversion to bool is always true, so delete to catch errors
      explicit operator bool() const = delete;

      T* operator->() const { return get(); }

      T& operator*() const { return ref(); }

      OwningNonNull& operator=(T* aValue) {
        init(aValue);
        return *this;
      }

      OwningNonNull& operator=(T& aValue) {
        init(&aValue);
        return *this;
      }

      template
      OwningNonNull& operator=(already_AddRefed&& aValue) {
        init(aValue);
        return *this;
      }

      template
      OwningNonNull& operator=(RefPtr&& aValue) {
        init(std::move(aValue));
        return *this;
      }

      template
      OwningNonNull& operator=(const OwningNonNull& aValue) {
        init(aValue);
        return *this;
      }

      // Don't allow assigning nullptr, it makes no sense
      void operator=(decltype(nullptr)) = delete;

      T& ref() const {
        MOZ_ASSERT(mInited);
        MOZ_ASSERT(mPtr, "OwningNonNull was set to null");
        return *mPtr;
      }

      // Make us work with smart pointer helpers that expect a get().
      T* get() const {
        MOZ_ASSERT(mInited);
        MOZ_ASSERT(mPtr, "OwningNonNull was set to null");
        return mPtr;
      }

      template
      void swap(U& aOther) {
        mPtr.swap(aOther);
    #ifdef DEBUG
        mInited = mPtr;
    #endif
      }

      // We have some consumers who want to check whether we're inited in non-debug
      // builds as well.  Luckily, we have the invariant that we're inited precisely
      // when mPtr is non-null.
      bool isInitialized() const {
        MOZ_ASSERT(!!mPtr == mInited, "mInited out of sync with mPtr?");
        return mPtr;
      }

     private:
      void unlinkForCC() {
    #ifdef DEBUG
        mInited = false;
    #endif
        mPtr = nullptr;
      }

      // Allow ImplCycleCollectionUnlink to call unlinkForCC().
      template
      friend void ImplCycleCollectionUnlink(OwningNonNull& aField);

     protected:
      template
      void init(U&& aValue) {
        mPtr = aValue;
        MOZ_ASSERT(mPtr);
    #ifdef DEBUG
        mInited = true;
    #endif
      }

      RefPtr mPtr;
    #ifdef DEBUG
      bool mInited = false;
    #endif
    };

    template
    inline void ImplCycleCollectionUnlink(OwningNonNull& aField) {
      aField.unlinkForCC();
    }

    template
    inline void ImplCycleCollectionTraverse(
        nsCycleCollectionTraversalCallback& aCallback, OwningNonNull& aField,
        const char* aName, uint32_t aFlags = 0) {
      CycleCollectionNoteChild(aCallback, aField.get(), aName, aFlags);
    }

    }  // namespace mozilla