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

escomplex

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

escomplex

Software complexity analysis of Mozilla-format abstract syntax trees.

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.8K
increased by3.12%
Maintainers
1
Weekly downloads
 
Created
Source

escomplex

THIS PROJECT IS (kind of) BRAND NEW AND NOT SAFE TO USE YET! :)

Build status

Software complexity analysis of JavaScript-family abstract syntax trees.

  • [Metrics][#metrics]
  • [Abstract syntax trees][#abstract-syntax-trees]
  • [Installation][#installation]
  • [Usage][#usage]
  • [Related projects][#related-projects]
  • [Development][#development]
  • [License][#license]

Metrics

Currently the library reports on:

  • lines of code;
  • number of parameters;
  • cyclomatic complexity;
  • Halstead metrics;
  • maintainability index;
  • dependencies (CommonJS and AMD);
  • first-order density.

Abstract syntax trees

Abstract syntax tree walkers

Installation

The library is published on npm under the name escomplex. To install, you can add it to the dependencies in your package.json file or simply run:

npm install escomplex

Usage

You can load escomplex in your own code by calling require:

var escomplex = require('escomplex');

It exports one function, called analyse:

var result = escomplex.analyse(ast, options);

The first argument, ast, must be either an abstract syntax tree as defined by Mozilla's Parser API or an array of said syntax trees.

The second argument, options, is an optional object containing properties that modify some of the complexity calculations:

  • options.logicalor: Boolean indicating whether operator || should be considered a source of cyclomatic complexity, defaults to true.
  • options.switchcase: Boolean indicating whether switch statements should be considered a source of cyclomatic complexity, defaults to true.
  • options.forin: Boolean indicating whether for...in loops should be considered a source of cyclomatic complexity, defaults to false.
  • options.trycatch: Boolean indicating whether catch clauses should be considered a source of cyclomatic complexity, defaults to false.
  • options.newmi: Boolean indicating whether the maintainability index should be rebased on a scale from 0 to 100, defaults to false.

If a single abstract syntax tree object is passed in the ast argument, the result will be a report object detailing the complexity of that syntax tree. If ast is an array, the result will be an array of complexity reports.

TODO: Properties on the returned object

TODO

Development

TODO

What license is it released under?

MIT

Keywords

FAQs

Package last updated on 20 Oct 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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