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

Hang on some python files #55

Closed tholin closed 9 years ago

tholin commented 9 years ago

Lizard gets stuck on some python files. Sample https://www.dropbox.com/s/wjl70kodhb3qtlu/cp037.py

$ ~/repository/lizard/lizard cp037.py 
========================================
  NLOC    CCN   token  PARAM  location  
----------------------------------------
^C
Traceback (most recent call last):
  File "/home/cocobo/repository/lizard/lizard", line 6, in <module>
    lizard_main(sys.argv)
  File "/home/cocobo/repository/lizard/lizard.py", line 944, in lizard_main
    printer(result, options)
  File "/home/cocobo/repository/lizard/lizard.py", line 821, in print_result
    code_infos, option.extensions, scheme)
  File "/home/cocobo/repository/lizard/lizard.py", line 789, in print_and_save_modules
    for module_info in all_modules:
  File "/home/cocobo/repository/lizard/lizard.py", line 644, in __call__
    filename, open(filename, 'rU').read())
  File "/home/cocobo/repository/lizard/lizard.py", line 653, in analyze_source_code
    tokens = reader.generate_tokens(code)
  File "/home/cocobo/repository/lizard/lizard_ext/python.py", line 23, in generate_tokens
    r"|\'\'\'.*?\'\'\'" + r'|\"\"\".*?\"\"\"')
  File "/home/cocobo/repository/lizard/lizard.py", line 367, in generate_tokens
    return [t for t in _generate_tokens(source_code, addition)]
  File "/home/cocobo/repository/lizard/lizard.py", line 352, in _generate_tokens
    for token in token_pattern.findall(source_code):
KeyboardInterrupt
terryyin commented 9 years ago

@tholin thanks for all these report. I will get them fixed.

terryyin commented 9 years ago

This one is fixed! Now I know a better way of parsing strings.