Global Metrics

path: .metrics.nom.total
old: 4.0
new: 8.0

path: .metrics.nom.functions
old: 4.0
new: 8.0

path: .metrics.mi.mi_visual_studio
old: 30.298251571461986
new: 37.02971865681129

path: .metrics.mi.mi_original
old: 51.81001018719999
new: 63.3208189031473

path: .metrics.mi.mi_sei
old: 38.49037983694157
new: 52.505514521927125

path: .metrics.nexits.average
old: 1.25
new: 0.625

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

path: .metrics.cyclomatic.average
old: 1.8333333333333333
new: 1.0833333333333333

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

path: .metrics.loc.lloc
old: 16.0
new: 12.0

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

path: .metrics.loc.ploc
old: 66.0
new: 40.0

path: .metrics.loc.sloc
old: 129.0
new: 73.0

path: .metrics.loc.cloc
old: 41.0
new: 19.0

path: .metrics.cognitive.average
old: 1.25
new: 0.25

path: .metrics.cognitive.sum
old: 5.0
new: 2.0

path: .metrics.halstead.level
old: 0.02894736842105263
new: 0.041522491349480974

path: .metrics.halstead.n2
old: 33.0
new: 24.0

path: .metrics.halstead.time
old: 2825.1955130941515
new: 1161.2493970009698

path: .metrics.halstead.volume
old: 1472.075556822742
new: 867.9234247481296

path: .metrics.halstead.bugs
old: 0.4575368598750874
new: 0.25293606025022236

path: .metrics.halstead.effort
old: 50853.51923569473
new: 20902.489146017455

path: .metrics.halstead.vocabulary
old: 53.0
new: 41.0

path: .metrics.halstead.N2
old: 114.0
new: 68.0

path: .metrics.halstead.purity_ratio
old: 0.984060575239596
new: 1.1081849896207625

path: .metrics.halstead.N1
old: 143.0
new: 94.0

path: .metrics.halstead.estimated_program_length
old: 252.9035678365762
new: 179.5259683185635

path: .metrics.halstead.length
old: 257.0
new: 162.0

path: .metrics.halstead.n1
old: 20.0
new: 17.0

path: .metrics.halstead.difficulty
old: 34.54545454545455
new: 24.083333333333332

Spaces Data

Minimal test - lines (13, 71)

path: .spaces[0].metrics.halstead.volume
old: 31.69925001442312
new: 829.1725471240865

path: .spaces[0].metrics.halstead.vocabulary
old: 9.0
new: 38.0

path: .spaces[0].metrics.halstead.length
old: 10.0
new: 158.0

path: .spaces[0].metrics.halstead.N2
old: 4.0
new: 64.0

path: .spaces[0].metrics.halstead.level
old: 0.4
new: 0.03860294117647059

path: .spaces[0].metrics.halstead.estimated_program_length
old: 19.60964047443681
new: 161.72553417960972

path: .spaces[0].metrics.halstead.difficulty
old: 2.5
new: 25.904761904761905

path: .spaces[0].metrics.halstead.n1
old: 5.0
new: 17.0

path: .spaces[0].metrics.halstead.bugs
old: 0.006149947511600477
new: 0.2575698895449777

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.960964047443681
new: 1.0235793302506944

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

path: .spaces[0].metrics.halstead.effort
old: 79.2481250360578
new: 21479.51741121443

path: .spaces[0].metrics.halstead.n2
old: 4.0
new: 21.0

path: .spaces[0].metrics.halstead.time
old: 4.402673613114322
new: 1193.306522845246

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

path: .spaces[0].metrics.nargs.average
old: null
new: 0.5

path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 12.0

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

path: .spaces[0].metrics.nexits.average
old: null
new: 0.625

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

path: .spaces[0].metrics.mi.mi_original
old: 130.33930763674556
new: 67.23766639251548

path: .spaces[0].metrics.mi.mi_sei
old: 112.44084062782548
new: 54.684313661345286

path: .spaces[0].metrics.mi.mi_visual_studio
old: 76.22181733143016
new: 39.320272744161095

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

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

path: .spaces[0].metrics.loc.sloc
old: 4.0
new: 59.0

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

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

path: .spaces[0].metrics.nom.functions
old: 0.0
new: 8.0

path: .spaces[0].metrics.nom.total
old: 0.0
new: 8.0

path: .spaces[0].metrics.cognitive.average
old: null
new: 0.25

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

Code

namespace mozilla {

/**
 * A wrapper class around nsISimpleEnumerator to support ranged iteration. This
 * requires every element in the enumeration to implement the same interface, T.
 * If any element does not implement this interface, the enumeration ends at
 * that element, and triggers an assertion in debug builds.
 *
 * Typical usage looks something like:
 *
 *   for (auto& docShell : SimpleEnumerator(docShellEnum)) {
 *     docShell.LoadURI(...);
 *   }
 */

template 
class SimpleEnumerator final {
 public:
  explicit SimpleEnumerator(nsISimpleEnumerator* aEnum) : mEnum(aEnum) {}

  class Entry {
   public:
    explicit Entry(T* aPtr) : mPtr(aPtr) {}

    explicit Entry(nsISimpleEnumerator& aEnum) : mEnum(&aEnum) { ++*this; }

    const nsCOMPtr& operator*() {
      MOZ_ASSERT(mPtr);
      return mPtr;
    }

    Entry& operator++() {
      MOZ_ASSERT(mEnum);
      nsCOMPtr next;
      if (NS_SUCCEEDED(mEnum->GetNext(getter_AddRefs(next)))) {
        mPtr = do_QueryInterface(next);
        MOZ_ASSERT(mPtr);
      } else {
        mPtr = nullptr;
      }
      return *this;
    }

    bool operator!=(const Entry& aOther) const { return mPtr != aOther.mPtr; }

   private:
    nsCOMPtr mPtr;
    nsCOMPtr mEnum;
  };

  Entry begin() { return Entry(*mEnum); }

  Entry end() { return Entry(nullptr); }

 private:
  nsCOMPtr mEnum;
};

}  // namespace mozilla