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

Maintainability index calculation (Cyclomatic complexity) #14

Open
abdullahkady opened this issue May 27, 2019 · 0 comments
Open

Maintainability index calculation (Cyclomatic complexity) #14

abdullahkady opened this issue May 27, 2019 · 0 comments

Comments

@abdullahkady
Copy link

abdullahkady commented May 27, 2019

Hi there,

First things first, nice work!
I have found a small problem with the calculation of the Maintainability Index formula used in: https://github.com/typhonjs-node-escomplex/escomplex-plugin-metrics-module
The following line:
(0.23 * averageCyclomatic === 0 ? 0 : Math.log(averageCyclomatic))
The ternary expression used does not evaluate as intended. It evaluates to 0.23 * averageCyclomatic rather than 0.23 * Math.log(averageCyclomatic) whenever the averageCyclomatic is not a zero, as stated in the documentation:
https://github.com/typhonjs-node-escomplex/escomplex-plugin-metrics-module/blob/7a4ddb6a0def5c90b8aa2f06c3e0867ba10eacd6/src/ModuleMetricPostAverage.js#L45-L49

A quick fix is to update the expression, by wrapping the ternary expression with brackets, leading to proper evaluation of the expression.

I have fixed it in a PR here if suitable: typhonjs-node-escomplex/escomplex-plugin-metrics-module#1

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant