Global Metrics

path: .metrics.mi.mi_original
old: -33.23925634462631
new: 49.22031953656152

path: .metrics.mi.mi_sei
old: -77.37742830096897
new: 32.941824892685716

path: .metrics.mi.mi_visual_studio
old: 0.0
new: 28.78381259448042

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

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

path: .metrics.cyclomatic.sum
old: 172.0
new: 25.0

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

path: .metrics.nexits.average
old: 0.7560975609756098
new: 0.15

path: .metrics.nexits.sum
old: 31.0
new: 3.0

path: .metrics.halstead.time
old: 123713.85304906566
new: 2653.193981612328

path: .metrics.halstead.vocabulary
old: 373.0
new: 43.0

path: .metrics.halstead.n2
old: 339.0
new: 29.0

path: .metrics.halstead.effort
old: 2226849.354883182
new: 47757.4916690219

path: .metrics.halstead.bugs
old: 5.684243023697138
new: 0.438772854211694

path: .metrics.halstead.N2
old: 1428.0
new: 118.0

path: .metrics.halstead.difficulty
old: 71.61061946902655
new: 28.482758620689655

path: .metrics.halstead.length
old: 3640.0
new: 309.0

path: .metrics.halstead.n1
old: 34.0
new: 14.0

path: .metrics.halstead.purity_ratio
old: 0.8303067836828935
new: 0.6284285364644209

path: .metrics.halstead.volume
old: 31096.635825729063
new: 1676.7158092029483

path: .metrics.halstead.estimated_program_length
old: 3022.316692605732
new: 194.18441776750603

path: .metrics.halstead.N1
old: 2212.0
new: 191.0

path: .metrics.halstead.level
old: 0.013964409293129016
new: 0.035108958837772396

path: .metrics.nom.total
old: 41.0
new: 20.0

path: .metrics.nom.functions
old: 40.0
new: 20.0

path: .metrics.nom.closures
old: 1.0
new: 0.0

path: .metrics.nargs.sum
old: 58.0
new: 6.0

path: .metrics.nargs.average
old: 1.4146341463414631
new: 0.3

path: .metrics.loc.cloc
old: 147.0
new: 30.0

path: .metrics.loc.lloc
old: 305.0
new: 18.0

path: .metrics.loc.blank
old: 133.0
new: 24.0

path: .metrics.loc.ploc
old: 659.0
new: 65.0

path: .metrics.loc.sloc
old: 939.0
new: 119.0

Spaces Data

Minimal test - lines (13, 117)

path: .spaces[0].metrics.nargs.average
old: 1.0
new: 0.3

path: .spaces[0].metrics.nargs.sum
old: 1.0
new: 6.0

path: .spaces[0].metrics.mi.mi_original
old: 141.3591763553032
new: 51.64667564905609

path: .spaces[0].metrics.mi.mi_visual_studio
old: 82.66618500310128
new: 30.202734297693624

path: .spaces[0].metrics.mi.mi_sei
old: 128.33915057933606
new: 34.41230393673922

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

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

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

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

path: .spaces[0].metrics.halstead.N1
old: 7.0
new: 191.0

path: .spaces[0].metrics.halstead.difficulty
old: 3.3333333333333335
new: 30.692307692307693

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

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

path: .spaces[0].metrics.halstead.vocabulary
old: 8.0
new: 40.0

path: .spaces[0].metrics.halstead.estimated_program_length
old: 16.36452797660028
new: 175.51440158047484

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.4876843615091162
new: 0.5754570543622126

path: .spaces[0].metrics.halstead.time
old: 6.111111111111111
new: 2767.7437585782804

path: .spaces[0].metrics.halstead.bugs
old: 0.007652568082218515
new: 0.4513128184045031

path: .spaces[0].metrics.halstead.length
old: 11.0
new: 305.0

path: .spaces[0].metrics.halstead.volume
old: 33.0
new: 1623.1880689406455

path: .spaces[0].metrics.halstead.level
old: 0.3
new: 0.03258145363408521

path: .spaces[0].metrics.halstead.effort
old: 110.0
new: 49819.387654409045

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

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

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

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

path: .spaces[0].metrics.loc.ploc
old: 2.0
new: 60.0

path: .spaces[0].metrics.loc.sloc
old: 2.0
new: 105.0

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

Code

namespace mozilla {

/**
 * Monitor provides a *non*-reentrant monitor: *not* a Java-style
 * monitor.  If your code needs support for reentrancy, use
 * ReentrantMonitor instead.  (Rarely should reentrancy be needed.)
 *
 * Instead of directly calling Monitor methods, it's safer and simpler
 * to instead use the RAII wrappers MonitorAutoLock and
 * MonitorAutoUnlock.
 */
class Monitor {
 public:
  explicit Monitor(const char* aName)
      : mMutex(aName), mCondVar(mMutex, "[Monitor.mCondVar]") {}

  ~Monitor() = default;

  void Lock() { mMutex.Lock(); }
  [[nodiscard]] bool TryLock() { return mMutex.TryLock(); }
  void Unlock() { mMutex.Unlock(); }

  void Wait() { mCondVar.Wait(); }
  CVStatus Wait(TimeDuration aDuration) { return mCondVar.Wait(aDuration); }

  void Notify() { mCondVar.Notify(); }
  void NotifyAll() { mCondVar.NotifyAll(); }

  void AssertCurrentThreadOwns() const { mMutex.AssertCurrentThreadOwns(); }

  void AssertNotCurrentThreadOwns() const {
    mMutex.AssertNotCurrentThreadOwns();
  }

 private:
  Monitor();
  Monitor(const Monitor&);
  Monitor& operator=(const Monitor&);

  Mutex mMutex;
  CondVar mCondVar;
};

/**
 * Lock the monitor for the lexical scope instances of this class are
 * bound to (except for MonitorAutoUnlock in nested scopes).
 *
 * The monitor must be unlocked when instances of this class are
 * created.
 */
class MOZ_STACK_CLASS MonitorAutoLock {
 public:
  explicit MonitorAutoLock(Monitor& aMonitor) : mMonitor(&aMonitor) {
    mMonitor->Lock();
  }

  ~MonitorAutoLock() { mMonitor->Unlock(); }

  void Wait() { mMonitor->Wait(); }
  CVStatus Wait(TimeDuration aDuration) { return mMonitor->Wait(aDuration); }

  void Notify() { mMonitor->Notify(); }
  void NotifyAll() { mMonitor->NotifyAll(); }

 private:
  MonitorAutoLock();
  MonitorAutoLock(const MonitorAutoLock&);
  MonitorAutoLock& operator=(const MonitorAutoLock&);
  static void* operator new(size_t) noexcept(true);

  friend class MonitorAutoUnlock;

  Monitor* mMonitor;
};

/**
 * Unlock the monitor for the lexical scope instances of this class
 * are bound to (except for MonitorAutoLock in nested scopes).
 *
 * The monitor must be locked by the current thread when instances of
 * this class are created.
 */
class MOZ_STACK_CLASS MonitorAutoUnlock {
 public:
  explicit MonitorAutoUnlock(Monitor& aMonitor) : mMonitor(&aMonitor) {
    mMonitor->Unlock();
  }

  explicit MonitorAutoUnlock(MonitorAutoLock& aMonitorLock)
      : mMonitor(aMonitorLock.mMonitor) {
    mMonitor->Unlock();
  }

  ~MonitorAutoUnlock() { mMonitor->Lock(); }

 private:
  MonitorAutoUnlock();
  MonitorAutoUnlock(const MonitorAutoUnlock&);
  MonitorAutoUnlock& operator=(const MonitorAutoUnlock&);
  static void* operator new(size_t) noexcept(true);

  Monitor* mMonitor;
};

}  // namespace mozilla