Global Metrics

path: .metrics.halstead.n2
old: 225.0
new: 70.0

path: .metrics.halstead.purity_ratio
old: 1.717635026549021
new: 1.983484710902527

path: .metrics.halstead.difficulty
old: 8.042222222222222
new: 9.428571428571429

path: .metrics.halstead.effort
old: 65407.47640914336
new: 14266.34669836298

path: .metrics.halstead.volume
old: 8133.010329957036
new: 1513.097377099104

path: .metrics.halstead.N2
old: 517.0
new: 110.0

path: .metrics.halstead.level
old: 0.12434374136501795
new: 0.10606060606060606

path: .metrics.halstead.estimated_program_length
old: 1777.7522524782366
new: 472.0693611948015

path: .metrics.halstead.length
old: 1035.0
new: 238.0

path: .metrics.halstead.vocabulary
old: 232.0
new: 82.0

path: .metrics.halstead.N1
old: 518.0
new: 128.0

path: .metrics.halstead.n1
old: 7.0
new: 12.0

path: .metrics.halstead.time
old: 3633.7486893968535
new: 792.5748165757211

path: .metrics.halstead.bugs
old: 0.5411242631501212
new: 0.1960742644998949

path: .metrics.loc.ploc
old: 263.0
new: 72.0

path: .metrics.loc.sloc
old: 296.0
new: 159.0

path: .metrics.loc.blank
old: 0.0
new: 21.0

path: .metrics.loc.cloc
old: 271.0
new: 66.0

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

path: .metrics.mi.mi_visual_studio
old: 18.442694454279387
new: 28.77181213430511

path: .metrics.mi.mi_original
old: 31.537007516817752
new: 49.19979874966174

path: .metrics.mi.mi_sei
old: 19.805535025481753
new: 38.01464683787641

Spaces Data

Minimal test - lines (15, 157)

path: .spaces[0].metrics.mi.mi_visual_studio
old: 19.279702394436125
new: 30.032462787172648

path: .spaces[0].metrics.mi.mi_original
old: 32.96829109448578
new: 51.35551136606523

path: .spaces[0].metrics.mi.mi_sei
old: 21.78422580631794
new: 40.70884597313859

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

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

path: .spaces[0].metrics.loc.sloc
old: 275.0
new: 143.0

path: .spaces[0].metrics.loc.ploc
old: 262.0
new: 65.0

path: .spaces[0].metrics.loc.cloc
old: 253.0
new: 58.0

path: .spaces[0].metrics.halstead.vocabulary
old: 231.0
new: 77.0

path: .spaces[0].metrics.halstead.volume
old: 8118.708508824203
new: 1453.894477441217

path: .spaces[0].metrics.halstead.bugs
old: 0.5413978536123474
new: 0.19323308695335148

path: .spaces[0].metrics.halstead.N2
old: 516.0
new: 104.0

path: .spaces[0].metrics.halstead.time
old: 3636.504852910841
new: 775.410387968649

path: .spaces[0].metrics.halstead.level
old: 0.12403100775193798
new: 0.10416666666666669

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.7103471827807606
new: 1.8727304217909628

path: .spaces[0].metrics.halstead.difficulty
old: 8.0625
new: 9.6

path: .spaces[0].metrics.halstead.estimated_program_length
old: 1768.4989869953065
new: 434.4734578555034

path: .spaces[0].metrics.halstead.effort
old: 65457.08735239514
new: 13957.386983435685

path: .spaces[0].metrics.halstead.length
old: 1034.0
new: 232.0

path: .spaces[0].metrics.halstead.N1
old: 518.0
new: 128.0

path: .spaces[0].metrics.halstead.n1
old: 7.0
new: 12.0

path: .spaces[0].metrics.halstead.n2
old: 224.0
new: 65.0

Code

namespace mozilla {

/**
 * A module implements one or more XPCOM components. This structure is used
 * for both binary and script modules, but the registration members
 * (cids/contractids/categoryentries) are unused for modules which are loaded
 * via a module loader.
 */
struct Module {
  static const unsigned int kVersion = 88;

  struct CIDEntry;

  typedef already_AddRefed (*GetFactoryProcPtr)(
      const Module& module, const CIDEntry& entry);

  typedef nsresult (*ConstructorProcPtr)(nsISupports* aOuter, const nsIID& aIID,
                                         void** aResult);

  typedef nsresult (*LoadFuncPtr)();
  typedef void (*UnloadFuncPtr)();

  /**
   * This selector allows CIDEntrys to be marked so that they're only loaded
   * into certain kinds of processes. Selectors can be combined.
   */
  // Note: This must be kept in sync with the selector matching in
  // nsComponentManager.cpp.
  enum ProcessSelector {
    ANY_PROCESS = 0x0,
    MAIN_PROCESS_ONLY = 0x1,
    CONTENT_PROCESS_ONLY = 0x2,

    /**
     * By default, modules are not loaded in the GPU process, even if
     * ANY_PROCESS is specified. This flag enables a module in the
     * GPU process.
     */
    ALLOW_IN_GPU_PROCESS = 0x4,
    ALLOW_IN_VR_PROCESS = 0x8,
    ALLOW_IN_SOCKET_PROCESS = 0x10,
    ALLOW_IN_RDD_PROCESS = 0x20,
    ALLOW_IN_GPU_AND_MAIN_PROCESS = ALLOW_IN_GPU_PROCESS | MAIN_PROCESS_ONLY,
    ALLOW_IN_GPU_AND_VR_PROCESS = ALLOW_IN_GPU_PROCESS | ALLOW_IN_VR_PROCESS,
    ALLOW_IN_GPU_AND_SOCKET_PROCESS =
        ALLOW_IN_GPU_PROCESS | ALLOW_IN_SOCKET_PROCESS,
    ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS =
        ALLOW_IN_GPU_PROCESS | ALLOW_IN_VR_PROCESS | ALLOW_IN_SOCKET_PROCESS,
    ALLOW_IN_RDD_AND_SOCKET_PROCESS =
        ALLOW_IN_RDD_PROCESS | ALLOW_IN_SOCKET_PROCESS,
    ALLOW_IN_GPU_RDD_AND_SOCKET_PROCESS =
        ALLOW_IN_GPU_PROCESS | ALLOW_IN_RDD_PROCESS | ALLOW_IN_SOCKET_PROCESS,
    ALLOW_IN_GPU_RDD_VR_AND_SOCKET_PROCESS =
        ALLOW_IN_GPU_PROCESS | ALLOW_IN_RDD_PROCESS | ALLOW_IN_VR_PROCESS |
        ALLOW_IN_SOCKET_PROCESS
  };

  static constexpr size_t kMaxProcessSelector =
      size_t(ProcessSelector::ALLOW_IN_GPU_RDD_VR_AND_SOCKET_PROCESS);

  /**
   * This allows category entries to be marked so that they are or are
   * not loaded when in backgroundtask mode.
   */
  // Note: This must be kept in sync with the selector matching in
  // StaticComponents.cpp.in.
  enum BackgroundTasksSelector {
    NO_TASKS = 0x0,
    ALL_TASKS = 0xFFFF,
  };

  /**
   * The constructor callback is an implementation detail of the default binary
   * loader and may be null.
   */
  struct CIDEntry {
    const nsCID* cid;
    bool service;
    GetFactoryProcPtr getFactoryProc;
    ConstructorProcPtr constructorProc;
    ProcessSelector processSelector;
  };

  struct ContractIDEntry {
    const char* contractid;
    nsID const* cid;
    ProcessSelector processSelector;
  };

  struct CategoryEntry {
    const char* category;
    const char* entry;
    const char* value;
  };

  /**
   * Binary compatibility check, should be kModuleVersion.
   */
  unsigned int mVersion;

  /**
   * An array of CIDs (class IDs) implemented by this module. The final entry
   * should be { nullptr }.
   */
  const CIDEntry* mCIDs;

  /**
   * An array of mappings from contractid to CID. The final entry should
   * be { nullptr }.
   */
  const ContractIDEntry* mContractIDs;

  /**
   * An array of category manager entries. The final entry should be
   * { nullptr }.
   */
  const CategoryEntry* mCategoryEntries;

  /**
   * When the component manager tries to get the factory for a CID, it first
   * checks for this module-level getfactory callback. If this function is
   * not implemented, it checks the CIDEntry getfactory callback. If that is
   * also nullptr, a generic factory is generated using the CIDEntry
   * constructor callback which must be non-nullptr.
   */
  GetFactoryProcPtr getFactoryProc;

  /**
   * Optional Function which are called when this module is loaded and
   * at shutdown. These are not C++ constructor/destructors to avoid
   * calling them too early in startup or too late in shutdown.
   */
  LoadFuncPtr loadProc;
  UnloadFuncPtr unloadProc;

  /**
   * Optional flags which control whether the module loads on a process-type
   * basis.
   */
  ProcessSelector selector;
};

}  // namespace mozilla