kisstkondoros / codemetrics

VSCode extension which shows the complexity information for TypeScript class members
Other
404 stars 20 forks source link

[Question] Provide details on how complexity is calculated #26

Closed peterschussheim closed 7 years ago

peterschussheim commented 7 years ago

Hi,

Recently started using this extension and it is neat however a brief explanation would be useful to myself and perhaps other users.

thanks, Peter

kisstkondoros commented 7 years ago

Hi,

It is a pretty straight forward process (it is inspired by Cyclomatic complexity).

  1. take the source code
  2. transform it to abstract syntax tree
  3. traverse the tree
  4. use assigned complexity values / visibility settings from the configuration (see package.json for available settings under codemetrics.nodeconfiguration)
  5. accumulate the subtotals for each node
  6. display the result
  7. be happy 😄

I hope this answered your question. If not feel free to reopen the issue / file a new one and I'll further elaborate it.

peterschussheim commented 7 years ago

@kisstkondoros Thank you for the explanation, this helps! 🥇