You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

escomplex-plugin-metrics-project

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

escomplex-plugin-metrics-project - npm Package Compare versions

Comparing version

to
0.0.13

dist/ProjectMetricAverage.js

29

dist/PluginMetricsProject.js

@@ -9,2 +9,6 @@ 'use strict';

var _ProjectMetricAverage = require('./ProjectMetricAverage');
var _ProjectMetricAverage2 = _interopRequireDefault(_ProjectMetricAverage);
var _ProjectMetricCalculate = require('./ProjectMetricCalculate');

@@ -40,4 +44,3 @@

* ```
* (boolean) newmi - Boolean indicating whether the maintainability index should be rebased on a scale from
* 0 to 100; defaults to false.
* (boolean) noCoreSize - Boolean indicating whether the visibility list is not calculated; default (false).
* ```

@@ -50,3 +53,3 @@ */

/**
* Performs final calculations based on collected project report data.
* Performs average calculations based on collected report data.
*

@@ -57,9 +60,17 @@ * @param {object} ev - escomplex plugin event data.

}, {
key: 'onProjectEnd',
value: function onProjectEnd(ev) {
var projectReport = ev.data.projectReport;
var pathModule = ev.data.pathModule;
var settings = ev.data.settings;
key: 'onProjectAverage',
value: function onProjectAverage(ev) {
_ProjectMetricAverage2.default.calculate(ev.data.projectReport);
}
_ProjectMetricCalculate2.default.calculate(projectReport, pathModule, settings);
/**
* Performs initial calculations based on collected report data.
*
* @param {object} ev - escomplex plugin event data.
*/
}, {
key: 'onProjectCalculate',
value: function onProjectCalculate(ev) {
_ProjectMetricCalculate2.default.calculate(ev.data.projectReport, ev.data.pathModule, ev.data.settings);
}

@@ -66,0 +77,0 @@ }]);

@@ -13,6 +13,2 @@ 'use strict';

var _ObjectUtil = require('typhonjs-escomplex-commons/dist/utils/ObjectUtil');
var _ObjectUtil2 = _interopRequireDefault(_ObjectUtil);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -36,4 +32,2 @@

}
ProjectMetricCalculate.calculateAverages(projectReport);
}

@@ -47,3 +41,3 @@

*
* @param {object} projectReport - The ProjectResult being processed.
* @param {object} projectReport - The project report being processed.
* @param {object} pathModule - A module that conforms to the Node path API.

@@ -83,35 +77,6 @@ *

/**
* Calculates average ModuleReport metrics that are applicable to ProjectResult.
*
* @param {object} projectReport - The ProjectResult being processed.
*
* @private
*/
}, {
key: 'calculateAverages',
value: function calculateAverages(projectReport) {
var divisor = projectReport.modules.length === 0 ? 1 : projectReport.modules.length;
var moduleAverage = projectReport.moduleAverage;
var moduleAverageKeys = _ObjectUtil2.default.getAccessorList(moduleAverage);
// Defer to ModuleReport to sum all relevant module metrics applicable to ProjectResult.
projectReport.modules.forEach(function (module) {
moduleAverageKeys.forEach(function (averageKey) {
var targetValue = _ObjectUtil2.default.safeAccess(module, averageKey, 0);
_ObjectUtil2.default.safeSet(moduleAverage, averageKey, targetValue, 'add');
});
});
moduleAverageKeys.forEach(function (averageKey) {
_ObjectUtil2.default.safeSet(moduleAverage, averageKey, divisor, 'div');
});
}
/**
* Calculates core size which is the percentage of modules / files that are both widely depended on and themselves
* depend on other modules. Lower is better.
*
* @param {object} projectReport - The ProjectResult being processed.
* @param {object} projectReport - The project report being processed.
* @param {Array<Array<number>>} visibilityMatrix - The calculated visibilityMatrix.

@@ -172,3 +137,3 @@ *

*
* @param {object} projectReport - The ProjectResult being processed.
* @param {object} projectReport - The project report being processed.
* @param {Array<Array<number>>} adjacencyMatrix - The calculated adjacencyMatrix.

@@ -175,0 +140,0 @@ *

{
"name": "escomplex-plugin-metrics-project",
"version": "0.0.12",
"version": "0.0.13",
"homepage": "https://github.com/typhonjs-node-escomplex/escomplex-plugin-metrics-project/",

@@ -5,0 +5,0 @@ "description": "Provides the core project metric / report generation plugin for typhonjs-escomplex project processing.",

@@ -0,1 +1,2 @@

import ProjectMetricAverage from './ProjectMetricAverage';
import ProjectMetricCalculate from './ProjectMetricCalculate';

@@ -19,4 +20,3 @@

* ```
* (boolean) newmi - Boolean indicating whether the maintainability index should be rebased on a scale from
* 0 to 100; defaults to false.
* (boolean) noCoreSize - Boolean indicating whether the visibility list is not calculated; default (false).
* ```

@@ -31,14 +31,20 @@ */

/**
* Performs final calculations based on collected project report data.
* Performs average calculations based on collected report data.
*
* @param {object} ev - escomplex plugin event data.
*/
onProjectEnd(ev)
onProjectAverage(ev)
{
const projectReport = ev.data.projectReport;
const pathModule = ev.data.pathModule;
const settings = ev.data.settings;
ProjectMetricAverage.calculate(ev.data.projectReport);
}
ProjectMetricCalculate.calculate(projectReport, pathModule, settings);
/**
* Performs initial calculations based on collected report data.
*
* @param {object} ev - escomplex plugin event data.
*/
onProjectCalculate(ev)
{
ProjectMetricCalculate.calculate(ev.data.projectReport, ev.data.pathModule, ev.data.settings);
}
}

@@ -1,3 +0,2 @@

import MathUtil from 'typhonjs-escomplex-commons/src/utils/MathUtil';
import ObjectUtil from 'typhonjs-escomplex-commons/src/utils/ObjectUtil';
import MathUtil from 'typhonjs-escomplex-commons/src/utils/MathUtil';

@@ -15,4 +14,2 @@ export default class ProjectMetricCalculate

}
ProjectMetricCalculate.calculateAverages(projectReport);
}

@@ -26,3 +23,3 @@

*
* @param {object} projectReport - The ProjectResult being processed.
* @param {object} projectReport - The project report being processed.
* @param {object} pathModule - A module that conforms to the Node path API.

@@ -61,36 +58,6 @@ *

/**
* Calculates average ModuleReport metrics that are applicable to ProjectResult.
*
* @param {object} projectReport - The ProjectResult being processed.
*
* @private
*/
static calculateAverages(projectReport)
{
const divisor = projectReport.modules.length === 0 ? 1 : projectReport.modules.length;
const moduleAverage = projectReport.moduleAverage;
const moduleAverageKeys = ObjectUtil.getAccessorList(moduleAverage);
// Defer to ModuleReport to sum all relevant module metrics applicable to ProjectResult.
projectReport.modules.forEach((module) =>
{
moduleAverageKeys.forEach((averageKey) =>
{
const targetValue = ObjectUtil.safeAccess(module, averageKey, 0);
ObjectUtil.safeSet(moduleAverage, averageKey, targetValue, 'add');
});
});
moduleAverageKeys.forEach((averageKey) =>
{
ObjectUtil.safeSet(moduleAverage, averageKey, divisor, 'div');
});
}
/**
* Calculates core size which is the percentage of modules / files that are both widely depended on and themselves
* depend on other modules. Lower is better.
*
* @param {object} projectReport - The ProjectResult being processed.
* @param {object} projectReport - The project report being processed.
* @param {Array<Array<number>>} visibilityMatrix - The calculated visibilityMatrix.

@@ -148,3 +115,3 @@ *

*
* @param {object} projectReport - The ProjectResult being processed.
* @param {object} projectReport - The project report being processed.
* @param {Array<Array<number>>} adjacencyMatrix - The calculated adjacencyMatrix.

@@ -151,0 +118,0 @@ *