New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

escomplex-plugin-metrics-module

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.0.2 to 0.0.3

60

dist/PluginMetricsModule.js

@@ -11,7 +11,11 @@ 'use strict';

var _MethodReport = require('typhonjs-escomplex-commons/dist/module/report/MethodReport.js');
var _HalsteadArray = require('typhonjs-escomplex-commons/dist/module/traits/HalsteadArray');
var _HalsteadArray2 = _interopRequireDefault(_HalsteadArray);
var _MethodReport = require('typhonjs-escomplex-commons/dist/module/report/MethodReport');
var _MethodReport2 = _interopRequireDefault(_MethodReport);
var _safeName = require('typhonjs-escomplex-commons/dist/module/traits/safeName.js');
var _safeName = require('typhonjs-escomplex-commons/dist/module/traits/safeName');

@@ -69,30 +73,32 @@ var _safeName2 = _interopRequireDefault(_safeName);

var parent = ev.data.parent;
var syntax = this.syntaxes[node.type];
// Process node syntax.
if (syntax !== null && (typeof syntax === 'undefined' ? 'undefined' : _typeof(syntax)) === 'object') {
// Process node.
for (var key in syntax) {
switch (syntax[key].metric) {
case 'cyclomatic':
report.incrementCyclomatic(syntax[key].valueOf(node, parent));
break;
// Process LLOC.
report.incrementLogicalSloc(syntax.lloc.valueOf(node, parent));
case 'dependencies':
report.addDependencies(syntax[key].valueOf(node, parent));
break;
// Process Cyclomatic.
report.incrementCyclomatic(syntax.cyclomatic.valueOf(node, parent));
case 'lloc':
report.incrementLogicalSloc(syntax[key].valueOf(node, parent));
break;
}
// Process operators HalsteadArray.
syntax.operators.process(report, node, parent);
// Process operands / operators HalsteadArray entries
if (syntax[key] instanceof _HalsteadArray2.default) {
report.processHalsteadItems(syntax[key].metric, syntax[key].valueOf(node, parent));
}
}
// Process operands HalsteadArray.
syntax.operands.process(report, node, parent);
// Process any dependencies.
report.addDependencies(syntax.dependencies.valueOf(node, parent));
// Handle creating new scope if applicable.
if (syntax.newScope) {
var newScope = syntax.newScope.valueOf(node, parent);
switch (newScope) {
switch (syntax.newScope.valueOf(node, parent)) {
case 'class':
report.createScope(newScope, (0, _safeName2.default)(node.id), node.loc.start.line, node.loc.end.line);
report.createScope('class', (0, _safeName2.default)(node.id), node.loc.start.line, node.loc.end.line);
break;

@@ -108,3 +114,3 @@

report.createScope(newScope, name, node.loc.start.line, node.loc.end.line, paramCount);
report.createScope('method', name, node.loc.start.line, node.loc.end.line, paramCount);

@@ -116,3 +122,4 @@ break;

ev.data.ignoreKeys = syntax.ignoreKeys.valueOf(node, parent);
// Return any child keys to ignore in AST walking or an empty array.
ev.data.ignoreKeys = syntax.ignoreKeys ? syntax.ignoreKeys.valueOf(node, parent) : [];
}

@@ -137,10 +144,9 @@ }

if (syntax !== null && (typeof syntax === 'undefined' ? 'undefined' : _typeof(syntax)) === 'object' && syntax.newScope) {
var newScope = syntax.newScope.valueOf(node, parent);
switch (newScope) {
switch (syntax.newScope.valueOf(node, parent)) {
case 'class':
report.popScope(newScope);
report.popScope('class');
break;
case 'method':
report.popScope(newScope);
report.popScope('method');
break;

@@ -147,0 +153,0 @@ }

{
"name": "escomplex-plugin-metrics-module",
"version": "0.0.2",
"version": "0.0.3",
"homepage": "https://github.com/typhonjs-node-escomplex/escomplex-plugin-metrics-module/",

@@ -23,6 +23,6 @@ "description": "Provides the core module metric / report generation plugin for typhonjs-escomplex module processing.",

"dependencies": {
"typhonjs-escomplex-commons": "^0.0.5"
"typhonjs-escomplex-commons": "^0.0.7"
},
"devDependencies": {
"escomplex-plugin-syntax-babylon": "^0.0.2",
"escomplex-plugin-syntax-babylon": "^0.0.3",
"typhonjs-ast-walker": "^0.1.0",

@@ -29,0 +29,0 @@ "typhonjs-config-eslint": "^0.4.0",

'use strict';
import MethodReport from 'typhonjs-escomplex-commons/src/module/report/MethodReport.js';
import HalsteadArray from 'typhonjs-escomplex-commons/src/module/traits/HalsteadArray';
import MethodReport from 'typhonjs-escomplex-commons/src/module/report/MethodReport';
import safeName from 'typhonjs-escomplex-commons/src/module/traits/safeName.js';
import safeName from 'typhonjs-escomplex-commons/src/module/traits/safeName';

@@ -44,33 +45,38 @@ /**

const parent = ev.data.parent;
const syntax = this.syntaxes[node.type];
// Process node syntax.
if (syntax !== null && typeof syntax === 'object')
{
// Process node.
for (const key in syntax)
{
switch (syntax[key].metric)
{
case 'cyclomatic':
report.incrementCyclomatic(syntax[key].valueOf(node, parent));
break;
// Process LLOC.
report.incrementLogicalSloc(syntax.lloc.valueOf(node, parent));
case 'dependencies':
report.addDependencies(syntax[key].valueOf(node, parent));
break;
// Process Cyclomatic.
report.incrementCyclomatic(syntax.cyclomatic.valueOf(node, parent));
case 'lloc':
report.incrementLogicalSloc(syntax[key].valueOf(node, parent));
break;
}
// Process operators HalsteadArray.
syntax.operators.process(report, node, parent);
// Process operands / operators HalsteadArray entries
if (syntax[key] instanceof HalsteadArray)
{
report.processHalsteadItems(syntax[key].metric, syntax[key].valueOf(node, parent));
}
}
// Process operands HalsteadArray.
syntax.operands.process(report, node, parent);
// Process any dependencies.
report.addDependencies(syntax.dependencies.valueOf(node, parent));
// Handle creating new scope if applicable.
if (syntax.newScope)
{
const newScope = syntax.newScope.valueOf(node, parent);
switch (newScope)
switch (syntax.newScope.valueOf(node, parent))
{
case 'class':
report.createScope(newScope, safeName(node.id), node.loc.start.line, node.loc.end.line);
report.createScope('class', safeName(node.id), node.loc.start.line, node.loc.end.line);
break;

@@ -83,7 +89,7 @@

const name = parent && parent.type === 'MethodDefinition' ? safeName(parent.key) :
safeName(node.id || node.key);
safeName(node.id || node.key);
const paramCount = node.params.length;
report.createScope(newScope, name, node.loc.start.line, node.loc.end.line, paramCount);
report.createScope('method', name, node.loc.start.line, node.loc.end.line, paramCount);

@@ -95,3 +101,4 @@ break;

ev.data.ignoreKeys = syntax.ignoreKeys.valueOf(node, parent);
// Return any child keys to ignore in AST walking or an empty array.
ev.data.ignoreKeys = syntax.ignoreKeys ? syntax.ignoreKeys.valueOf(node, parent) : [];
}

@@ -115,11 +122,10 @@ }

{
const newScope = syntax.newScope.valueOf(node, parent);
switch (newScope)
switch (syntax.newScope.valueOf(node, parent))
{
case 'class':
report.popScope(newScope);
report.popScope('class');
break;
case 'method':
report.popScope(newScope);
report.popScope('method');
break;

@@ -126,0 +132,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc