priv-kweihmann / multimetric

Calculate code metrics in various languages
zlib License
36 stars 13 forks source link

Cyclomatic complexity = 0 ? #18

Closed ruimaranhao closed 3 years ago

ruimaranhao commented 3 years ago

I've just run multimetric for the example in https://github.com/priv-kweihmann/multimetric/blob/master/testfiles/test.c, and I get 0 for cyclomatic complxity. Is this correct ?

priv-kweihmann commented 3 years ago

I would say yes. The used formula is https://github.com/priv-kweihmann/multimetric/blob/c3a7cb472d995ecfe4f1ee8f2b08cd8f26af7bde/multimetric/cls/metric/cyclomatic.py#L45. The used file has 3 exit points (the return statements) and 2 used conditionals, which will make it max(2 - (3 + 2), 0) = 0. And the used code isn't really complex so the result looks reasonable to me