Global Metrics

path: .metrics.loc.blank
old: 13.0
new: 27.0

path: .metrics.loc.sloc
old: 70.0
new: 115.0

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

path: .metrics.loc.lloc
old: 0.0
new: 20.0

path: .metrics.loc.ploc
old: 26.0
new: 69.0

path: .metrics.mi.mi_original
old: 68.46213724751476
new: 50.23099945764207

path: .metrics.mi.mi_visual_studio
old: 40.036337571646065
new: 29.374853484001218

path: .metrics.mi.mi_sei
old: 66.16214816207993
new: 28.85958306972296

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

path: .metrics.nargs.sum
old: 0.0
new: 5.0

path: .metrics.nargs.average
old: null
new: 0.2777777777777778

path: .metrics.cyclomatic.sum
old: 2.0
new: 26.0

path: .metrics.halstead.vocabulary
old: 30.0
new: 46.0

path: .metrics.halstead.volume
old: 598.6406526642393
new: 1469.2674803111654

path: .metrics.halstead.n1
old: 5.0
new: 13.0

path: .metrics.halstead.bugs
old: 0.07466462709861242
new: 0.33074612979006524

path: .metrics.halstead.N1
old: 66.0
new: 158.0

path: .metrics.halstead.effort
old: 3352.38765491974
new: 31255.32639934661

path: .metrics.halstead.estimated_program_length
old: 127.70604521880492
new: 214.57072227466315

path: .metrics.halstead.length
old: 122.0
new: 266.0

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

path: .metrics.halstead.difficulty
old: 5.6
new: 21.272727272727273

path: .metrics.halstead.time
old: 186.24375860665225
new: 1736.4070221859229

path: .metrics.halstead.N2
old: 56.0
new: 108.0

path: .metrics.halstead.level
old: 0.17857142857142858
new: 0.04700854700854701

path: .metrics.halstead.purity_ratio
old: 1.046770862449221
new: 0.8066568506566284

path: .metrics.nexits.sum
old: 0.0
new: 4.0

path: .metrics.nexits.average
old: null
new: 0.2222222222222222

path: .metrics.nom.functions
old: 0.0
new: 18.0

path: .metrics.nom.total
old: 0.0
new: 18.0

Spaces Data

Minimal test - lines (17, 113)

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

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

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

path: .spaces[0].metrics.halstead.n2
old: 1.0
new: 32.0

path: .spaces[0].metrics.halstead.effort
old: 0.0
new: 31217.06596281195

path: .spaces[0].metrics.halstead.purity_ratio
old: null
new: 0.7882792285448265

path: .spaces[0].metrics.halstead.volume
old: 0.0
new: 1449.849217431034

path: .spaces[0].metrics.halstead.difficulty
old: 0.0
new: 21.53125

path: .spaces[0].metrics.halstead.level
old: null
new: 0.04644412191582003

path: .spaces[0].metrics.halstead.length
old: 1.0
new: 264.0

path: .spaces[0].metrics.halstead.n1
old: 0.0
new: 13.0

path: .spaces[0].metrics.halstead.estimated_program_length
old: null
new: 208.1057163358342

path: .spaces[0].metrics.halstead.vocabulary
old: 1.0
new: 45.0

path: .spaces[0].metrics.halstead.N1
old: 0.0
new: 158.0

path: .spaces[0].metrics.halstead.N2
old: 1.0
new: 106.0

path: .spaces[0].metrics.halstead.bugs
old: 0.0
new: 0.3304761582161031

path: .spaces[0].metrics.halstead.time
old: 0.0
new: 1734.2814423784416

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

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

path: .spaces[0].metrics.mi.mi_visual_studio
old: null
new: 31.162435654792365

path: .spaces[0].metrics.mi.mi_sei
old: null
new: 26.45117707112069

path: .spaces[0].metrics.mi.mi_original
old: null
new: 53.28776496969495

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

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

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

path: .spaces[0].metrics.loc.ploc
old: 1.0
new: 64.0

path: .spaces[0].metrics.loc.sloc
old: 1.0
new: 97.0

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

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

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

Code

namespace mozilla {
namespace IOInterposer {

/**
 * The following classes are simple wrappers for PRLock and PRCondVar.
 * IOInterposer and friends use these instead of Mozilla::Mutex et al because
 * of the fact that IOInterposer is permitted to run until the process
 * terminates; we can't use anything that plugs into leak checkers or deadlock
 * detectors because IOInterposer will outlive those and generate false
 * positives.
 */

class Monitor {
 public:
  Monitor() : mLock(PR_NewLock()), mCondVar(PR_NewCondVar(mLock)) {}

  ~Monitor() {
    PR_DestroyCondVar(mCondVar);
    mCondVar = nullptr;
    PR_DestroyLock(mLock);
    mLock = nullptr;
  }

  void Lock() { PR_Lock(mLock); }

  void Unlock() { PR_Unlock(mLock); }

  bool Wait(PRIntervalTime aTimeout = PR_INTERVAL_NO_TIMEOUT) {
    return PR_WaitCondVar(mCondVar, aTimeout) == PR_SUCCESS;
  }

  bool Notify() { return PR_NotifyCondVar(mCondVar) == PR_SUCCESS; }

 private:
  PRLock* mLock;
  PRCondVar* mCondVar;
};

class MonitorAutoLock {
 public:
  explicit MonitorAutoLock(Monitor& aMonitor) : mMonitor(aMonitor) {
    mMonitor.Lock();
  }

  ~MonitorAutoLock() { mMonitor.Unlock(); }

  bool Wait(PRIntervalTime aTimeout = PR_INTERVAL_NO_TIMEOUT) {
    return mMonitor.Wait(aTimeout);
  }

  bool Notify() { return mMonitor.Notify(); }

 private:
  Monitor& mMonitor;
};

class MonitorAutoUnlock {
 public:
  explicit MonitorAutoUnlock(Monitor& aMonitor) : mMonitor(aMonitor) {
    mMonitor.Unlock();
  }

  ~MonitorAutoUnlock() { mMonitor.Lock(); }

 private:
  Monitor& mMonitor;
};

class Mutex {
 public:
  Mutex() : mPRLock(PR_NewLock()) {}

  ~Mutex() {
    PR_DestroyLock(mPRLock);
    mPRLock = nullptr;
  }

  void Lock() { PR_Lock(mPRLock); }

  void Unlock() { PR_Unlock(mPRLock); }

 private:
  PRLock* mPRLock;
};

class AutoLock {
 public:
  explicit AutoLock(Mutex& aLock) : mLock(aLock) { mLock.Lock(); }

  ~AutoLock() { mLock.Unlock(); }

 private:
  Mutex& mLock;
};

}  // namespace IOInterposer
}  // namespace mozilla