kisstkondoros / codemetrics

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

Calculation always +1 #50

Closed andretf closed 6 years ago

andretf commented 6 years ago

I'm not sure if it's an issue or it's expected from your algorithm calculations. Final sum is always added 1 point, seems it's putting function statement into account instead of just its body ("codemetrics.luaconfiguration.FunctionDeclaration": 1).

Please see image below, I think it's self explanatory. screenshot_20180220_223224

text example:

function a() { return 1 }
function b(p) {
  return p ? 1 : 2
}
function c(p) { }

AFAIK, their cyclomatic complexity should be 1 for a, 2 for b, and 0 for c.

kisstkondoros commented 6 years ago

It is the expected behavior, but you can change the mentioned config property to 0, then it should behave as you described. If not please create a new issue.

(The description in #14 might be useful)

andretf commented 6 years ago

Thank you for you quick response. I'd like to mention that I was thinking your extension do a simple Cyclomatic Complexity (McAbes'). It's nice to cover aspects where CC fails in readability. Although it would be awesome to see in future releases CC (to help writing unit tests), Maintainability Index, etc.