Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support a programmable API #8

Open
simonrenoult opened this issue May 3, 2020 · 1 comment
Open

Support a programmable API #8

simonrenoult opened this issue May 3, 2020 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@simonrenoult
Copy link
Owner

simonrenoult commented May 3, 2020

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 :)

@simonrenoult simonrenoult added enhancement New feature or request help wanted Extra attention is needed labels May 3, 2020
adaliszk added a commit to adaliszk/node-code-complexity that referenced this issue Feb 18, 2024
Exposing the various types and classes for programatical usage
with a shortcut for the complexity calculation. This should
give a decent support for functional or object-oriented support
while keeping the changes low.

refs: simonrenoult#8
adaliszk added a commit to adaliszk/node-code-complexity that referenced this issue Feb 18, 2024
Exposing the various types and classes for programatical usage
with a shortcut for the complexity calculation. This should
give a decent support for functional or object-oriented support
while keeping the changes low.

refs: simonrenoult#8
@adaliszk
Copy link

I made a little improvement on the current export, mainly solving issues on using the package as a dependency in typescript. Adding documentation with JSDoc would likely be something to look at as well. Overall, the code is nicely readable, so for most people who want to use it programmatically, #57 should suffice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants