Skip to content

Commit ce84890

Browse files
committed
fix: clean files and add docs
1 parent 8bddecf commit ce84890

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,21 @@ function main(a) {
1414

1515
As code grows, and I'm sure we've all seen it, algorithms can take on a life of their own and grow to contain numerous linear paths that all have to be maintained and amount to the cognitive overhead of a given algorithm.
1616

17-
This library provides any JS library the ability to analyze the Cyclomatic Complexity of their functions with a dependency solely on the [abstract-syntax-tree](https://www.npmjs.com/package/abstract-syntax-tree)
17+
This library provides any JS library the ability to analyze the Cyclomatic Complexity of their functions with a dependency solely on the [abstract-syntax-tree](https://www.npmjs.com/package/abstract-syntax-tree)
18+
19+
# How to Use
20+
21+
CyclomaticJS has one named export: `calculateComplexity`
22+
23+
This function takes a `filename` and calculates the logical complexity of a file's contents.
24+
25+
```javascript
26+
import { calculateComplexity } from 'cyclomatic-js'
27+
28+
const complexity = calculateComplexity('somefile.js')
29+
30+
```
31+
32+
# Supported Source Code
33+
34+
CyclomaticJS supports both CommonJS and ESModules. Please raise an issue if there are problems with either module loading systems.

src/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,11 @@ function determineLogicalComplexity(bodyInput) {
8585
}
8686
}
8787
}
88-
function findDeclarations(node, complexity) {
88+
function findDeclarations(node) {
8989
if (node.declaration) return processNodes([node.declaration])
9090
if (!node.declarations) return
9191

9292
for (const declaration of node.declarations) {
93-
const isFunction = !!declaration.init?.body?.body
9493
if (declaration.init?.body?.body) {
9594
processNodes(declaration.init.body.body)
9695
}

0 commit comments

Comments
 (0)