# Global Metrics

path: .metrics.nargs.average
old: 2.25
new: 1.5
path: .metrics.nargs.sum
old: 9.0
new: 3.0
path: .metrics.halstead.purity_ratio
old: 0.919895803516003
new: 1.2290153023259875
path: .metrics.halstead.N1
old: 314.0
new: 96.0
path: .metrics.halstead.effort
old: 185801.45182288604
new: 12830.683681359733
path: .metrics.halstead.difficulty
old: 51.2578125
new: 14.96551724137931
path: .metrics.halstead.n2
old: 64.0
new: 29.0
path: .metrics.halstead.level
old: 0.01950922115531169
new: 0.06682027649769585
path: .metrics.halstead.estimated_program_length
old: 512.3819625584136
new: 194.18441776750603
path: .metrics.halstead.volume
old: 3624.841614590674
new: 857.3498312429315
path: .metrics.halstead.N2
old: 243.0
new: 62.0
path: .metrics.halstead.time
old: 10322.302879049224
new: 712.8157600755408
path: .metrics.halstead.n1
old: 27.0
new: 14.0
path: .metrics.halstead.vocabulary
old: 91.0
new: 43.0
path: .metrics.halstead.bugs
old: 1.0853708348158726
new: 0.18268880885025013
path: .metrics.halstead.length
old: 557.0
new: 158.0
path: .metrics.loc.blank
old: 19.0
new: 11.0
path: .metrics.loc.sloc
old: 129.0
new: 88.0
path: .metrics.loc.lloc
old: 45.0
new: 1.0
path: .metrics.loc.cloc
old: 31.0
new: 38.0
path: .metrics.loc.ploc
old: 79.0
new: 39.0
path: .metrics.nom.total
old: 4.0
new: 2.0
path: .metrics.nom.functions
old: 4.0
new: 2.0
path: .metrics.cyclomatic.average
old: 5.2
new: 1.0
path: .metrics.cyclomatic.sum
old: 26.0
new: 8.0
path: .metrics.cognitive.sum
old: 17.0
new: 0.0
path: .metrics.cognitive.average
old: 4.25
new: 0.0
path: .metrics.nexits.average
old: 3.0
new: 0.0
path: .metrics.nexits.sum
old: 12.0
new: 0.0
path: .metrics.mi.mi_visual_studio
old: 25.540407313182342
new: 35.96909017459029
path: .metrics.mi.mi_original
old: 43.67409650554181
new: 61.5071441985494
path: .metrics.mi.mi_sei
old: 24.380520604783356
new: 56.40324920725754

# Spaces Data

## Minimal test - lines (15, 86)

path: .spaces[0].metrics.halstead.estimated_program_length
old: 420.80302513413505
new: 169.39937365317456
path: .spaces[0].metrics.halstead.bugs
old: 0.6846192578632334
new: 0.18340604775746647
path: .spaces[0].metrics.halstead.difficulty
old: 37.77777777777778
new: 15.96
path: .spaces[0].metrics.halstead.effort
old: 93079.82308110672
new: 12906.317970195349
path: .spaces[0].metrics.halstead.N2
old: 170.0
new: 57.0
path: .spaces[0].metrics.halstead.level
old: 0.026470588235294117
new: 0.06265664160401002
path: .spaces[0].metrics.halstead.n2
old: 54.0
new: 25.0
path: .spaces[0].metrics.halstead.time
old: 5171.101282283707
new: 717.0176650108527
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.073477104934018
new: 1.1071854487135593
path: .spaces[0].metrics.halstead.N1
old: 222.0
new: 96.0
path: .spaces[0].metrics.halstead.n1
old: 24.0
new: 14.0
path: .spaces[0].metrics.halstead.vocabulary
old: 78.0
new: 39.0
path: .spaces[0].metrics.halstead.volume
old: 2463.8776697940016
new: 808.6665394859241
path: .spaces[0].metrics.halstead.length
old: 392.0
new: 153.0
path: .spaces[0].metrics.mi.mi_visual_studio
old: 34.283958777951746
new: 38.18245516105761
path: .spaces[0].metrics.mi.mi_sei
old: 37.96375219544194
new: 61.722671197798405
path: .spaces[0].metrics.mi.mi_original
old: 58.62556951029748
new: 65.29199832540851
path: .spaces[0].metrics.nom.total
old: 1.0
new: 2.0
path: .spaces[0].metrics.nom.functions
old: 1.0
new: 2.0
path: .spaces[0].metrics.nexits.sum
old: 7.0
new: 0.0
path: .spaces[0].metrics.nexits.average
old: 7.0
new: 0.0
path: .spaces[0].metrics.loc.cloc
old: 9.0
new: 31.0
path: .spaces[0].metrics.loc.lloc
old: 33.0
new: 1.0
path: .spaces[0].metrics.loc.ploc
old: 46.0
new: 33.0
path: .spaces[0].metrics.loc.blank
old: 10.0
new: 8.0
path: .spaces[0].metrics.loc.sloc
old: 65.0
new: 72.0
path: .spaces[0].metrics.nargs.average
old: 3.0
new: 1.5
path: .spaces[0].metrics.cyclomatic.sum
old: 18.0
new: 7.0
path: .spaces[0].metrics.cyclomatic.average
old: 18.0
new: 1.0
path: .spaces[0].metrics.cognitive.sum
old: 13.0
new: 0.0
path: .spaces[0].metrics.cognitive.average
old: 13.0
new: 0.0

### Code

    namespace mozilla {
    namespace widget {

    /* this is handy wrapper around JSAPI to make it more pleasant to use.
     * We collect the JSAPI errors and so that callers don't need to */
    class MOZ_STACK_CLASS InfoObject {
      friend class GfxInfoBase;

     public:
      void DefineProperty(const char* name, int value);
      void DefineProperty(const char* name, nsAString& value);
      void DefineProperty(const char* name, const char* value);

     private:
      // We need to ensure that this object lives on the stack so that GC sees it
      // properly
      explicit InfoObject(JSContext* aCx);
      InfoObject(InfoObject&);

      JSContext* mCx;
      JS::Rooted mObj;
      bool mOk;
    };

    /*

       Here's an example usage:

       class Foo {
       Foo::Foo() : mInfoCollector(this, &Foo::GetAweseomeness) {}

       void GetAwesomeness(InfoObject &obj) {
         obj.DefineProperty("awesome", mAwesome);
       }

       int mAwesome;

       GfxInfoCollector mInfoCollector;
       }

       This will define a property on the object
       returned from calling getInfo() on a
       GfxInfo object. e.g.

           gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
           info = gfxInfo.getInfo();
           if (info.awesome)
              alert(info.awesome);

    */

    class GfxInfoCollectorBase {
     public:
      GfxInfoCollectorBase();
      virtual void GetInfo(InfoObject& obj) = 0;
      virtual ~GfxInfoCollectorBase();
    };

    template
    class GfxInfoCollector : public GfxInfoCollectorBase {
     public:
      GfxInfoCollector(T* aPointer, void (T::*aFunc)(InfoObject& obj))
          : mPointer(aPointer), mFunc(aFunc) {}
      virtual void GetInfo(InfoObject& obj) override { (mPointer->*mFunc)(obj); }

     protected:
      T* mPointer;
      void (T::*mFunc)(InfoObject& obj);
    };

    }  // namespace widget
    }  // namespace mozilla