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

lizardio fails to work simultaneously with other extensions #129

Closed mehrdad89 closed 8 years ago

mehrdad89 commented 8 years ago

Hi!

I am trying to run lizardio extensions (fan-in and fan-out) with other extensions, however, it is failing to calculate the fan-in and fan-out in the following example:

from lizard import FileAnalyzer, get_extensions

if __name__ == '__main__':
    lizard_object = FileAnalyzer(
        get_extensions(["io", "ns", "nd"])).analyze_source_code("a.cpp", """int foo(){bar();
                                            if(a){ b;}
                                            }
                                            int bar(){foo();};""")
    print lizard_object.function_list[0].__dict__
    print lizard_object.function_list[1].__dict__

the output:

{'max_nested_structures': 1, 'token_count': 17, 'long_name': 'foo()', 'paren_count': 0, 'start_line': 1, 'parameters': [], 'filename': 'a.cpp', 'bracket_loop': False, 'cyclomatic_complexity': 2, 'brace_count': 0, 'top_nesting_level': 0, 'tokens': set(['a', 'b', 'bar', ')', '(', '{', '}', ';', 'if']), 'fan_in': 0, 'hidden_bracket': 0, 'name': 'foo', 'nesting_depth': 0, 'nloc': 3, 'fan_out': 0, 'length': 3, 'end_line': 3, 'structure_stack': [], 'max_nesting_depth': 1}
{'max_nested_structures': 0, 'token_count': 5, 'long_name': 'bar()', 'paren_count': 0, 'start_line': 4, 'parameters': [], 'filename': 'a.cpp', 'bracket_loop': False, 'cyclomatic_complexity': 1, 'brace_count': 0, 'top_nesting_level': 0, 'tokens': set([')', '(', '{', '}']), 'fan_in': 0, 'hidden_bracket': 0, 'name': 'bar', 'nesting_depth': 0, 'nloc': 1, 'fan_out': 0, 'length': 1, 'end_line': 4, 'structure_stack': [], 'max_nesting_depth': 0}

It seems that lizardio cannot be activated with the help of get_extensions while other extensions are working correctly. Is there any alternative to run the lizardio with other via analyze_source_code?

mehrdad89 commented 8 years ago

I fixed the issue by calling the reduce method inside the lizard_ext.lizardio module Anyway, I will close this issue now.