Skip to content

Support a programmable API #8

Open
@simonrenoult

Description

@simonrenoult

What problem are you trying to solve?

Since v4.0.0, if one wants to integrate code-complexity with another program, the recommended solution is to use the json flag, example:

const { execSync } = require("fs");
const raw = execSync("npx code-complexity ../foo/bar --format=json");
const result = JSON.parse(raw);

Which is not ideal since it feels a bit hacky and the datastructure is unknown from a user point of view.

Describe the feature

A cool way to do things would be to be able to import code-complexity as a dependency, example:

const codeComplexity = require('code-complexity');
const options = { directory: '../foo/bar' };
const result = await codeComplexity.compute(options);

I initially planned that feature for v4.0.0 but struggled with the TypeScript module system. Help definitely wanted :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions