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

Implement Nested Structure counting for C++ #119

Closed rakhimov closed 8 years ago

rakhimov commented 8 years ago

The description of the metric is in Issue #69 and in the documentation.


This change is Reviewable

mehrdad89 commented 8 years ago

Great addition! let's see what @terryyin think about the changes!

terryyin commented 8 years ago

great! @rakhimov , I like it very much.

So far this implementation works only for "C-like" languages. I have implemented some more general data for nesting. At any time, you can get the current nesting level via context. self.current_nesting_level and context.current_function.top_nesting_level keeps the top nesting level of the current function. Perhaps you can refactor the code to use these two values to calculate the NS result. Then it will become a general implementation for all supported languages.

I like the theory very much. I or somebody else should add CCN to it.

rakhimov commented 8 years ago

Hi @terryyin , you have merged this PR too early. It is quite annoying to submit patches to patches. I would commit additional patches within this PR to get your reviews into code, which makes it more coherent. I wish GitHub had 'unmerge' feature.

rakhimov commented 8 years ago

context.current_nesting_level and current_function.top_nesting_level are undocumented. It is not clear what nesting level means. For example, the current_nesting_level produce different nesting for the following code:

if (x) while(y) continue;

if (x) { while(y) { continue; } }

In the first line of code, all if, while, continue get nesting 1. In the second line of code, the nesting output is: (if, 1), (while, 2), (continue, 3). Is it just brace counting for C++?