terryyin / lizard

A simple code complexity analyser without caring about the C/C++ header files or Java imports, supports most of the popular languages.
Other
1.85k stars 250 forks source link

negative modified cyclomatic complexity with McCabe on #97

Closed vicgonzalez closed 7 years ago

vicgonzalez commented 8 years ago

Hi, thank you for implementing the McCabe extension. I've been testing it and I found some functions throw negative values of modified cyclomatic complexity if McCabe extension is on. For instance next function has a modified CC of 2 but with McCabe seems to have -2: void ccm_minus_2(void) { switch(var){ case CTE1: func1(); break; case CTE2: func2(); break; case CTE3: func3(); break; case CTE4: func4(); break; case CTE5: func5(); break; case CTE61: case CTE62: case CTE63: func6(); break; case CTE71: case CTE72: case CTE73: func7(); break; case CTE8: func8(); break; default: printf("default"); break;}}

and this one has a modified CC of 2 but throws -3 if McCabe is on: void ccm_minus_3(void) { switch(var){ case CTE1: case CTE2: case CTE3: case CTE4: case CTE5: case CTE6: func(); break; default: break;}} Thanks and sorry for the poor code formatting.

terryyin commented 8 years ago

Hi @vicgonzalez sorry for the delayed reply, I had a long Chinese new year break.

Have you also added the -m option for modified CC? They cannot be used together.

vicgonzalez commented 8 years ago

Happy new year, I'm glad that was the reason of the delay:-) Of course you are right, how fool of me... Anyway, it wouldn't harm to ignore the McCabe flag in that case or issue an flag incompatibility error for people like me;-)