You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
then npx cyclomatic-complexity complexity.ts will output:
complexity.ts: 4 (OK)
anonymous: 2 (OK)
anonymous: 1 (OK)
iAmAFunction: 1 (OK)
global: 0 (OK)
No issues found
Technically this is correct, as the functions are indeed anonymous functions, however it is difficult to determine which of the complexities applies to which function, especially if your file consists of many anonymous functions.
Feature Request / Idea for solving above mentioned problem
This feature requests asks to name anonymous functions assigned to variables/consts (such as iAmAnArrowFunction) by the name of this variable.
The output of npx cyclomatic-complexity complexity.ts would then look like this:
complexity.ts: 4 (OK)
anonymous: 2 (OK)
iAmAnArrowFunction: 1 (OK)
iAmAFunction: 1 (OK)
global: 0 (OK)
No issues found
One could argue to add a note that this function is anonymous, for example by adding a (anonymous) to the function name. However I don't think, this is quite necessary:
complexity.ts: 4 (OK)
anonymous: 2 (OK)
iAmAnArrowFunction (anonymous): 1 (OK)
iAmAFunction: 1 (OK)
global: 0 (OK)
No issues found
Possible difficulties
I am not into Esprima, so I am not sure, if one could easily adjust the following line or if a more complex logic would have to be introduced (such as remembering if this is a variable/const assignment and if yes, remember the variable/const name):
Problem description
Having for example the following code:
then
npx cyclomatic-complexity complexity.ts
will output:Technically this is correct, as the functions are indeed anonymous functions, however it is difficult to determine which of the complexities applies to which function, especially if your file consists of many anonymous functions.
Feature Request / Idea for solving above mentioned problem
This feature requests asks to name anonymous functions assigned to variables/consts (such as
iAmAnArrowFunction
) by the name of this variable.The output of
npx cyclomatic-complexity complexity.ts
would then look like this:One could argue to add a note that this function is anonymous, for example by adding a
(anonymous)
to the function name. However I don't think, this is quite necessary:Possible difficulties
I am not into Esprima, so I am not sure, if one could easily adjust the following line or if a more complex logic would have to be introduced (such as remembering if this is a variable/const assignment and if yes, remember the variable/const name):
cyclomatic-complexity/src/complexity.ts
Line 41 in 0d51251
The text was updated successfully, but these errors were encountered: