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.87k stars 252 forks source link

[Bug] In linux, missing symbolic link file raise error #177

Open salphaon opened 7 years ago

salphaon commented 7 years ago

Hi.

If origin file of symbolic link is missing, then the following exception occurs.

Traceback (most recent call last): File "/usr/local/bin/lizard", line 9, in load_entry_point('lizard==1.12.9', 'console_scripts', 'lizard')() File "/usr/local/lib/python2.7/dist-packages/lizard.py", line 977, in main warning_count = printer(result, options, schema) File "/usr/local/lib/python2.7/dist-packages/lizard.py", line 791, in print_result result = print_and_save_modules(result, option.extensions, scheme) File "/usr/local/lib/python2.7/dist-packages/lizard.py", line 751, in print_and_save_modules for module_info in all_fileinfos: File "/usr/local/lib/python2.7/dist-packages/lizard.py", line 875, in _validate_file _not_duplicate(pathname))) File "/usr/local/lib/python2.7/dist-packages/lizard.py", line 878, in _not_duplicate fhash = md5_hash_file(full_path_name) File "/usr/local/lib/python2.7/dist-packages/lizard.py", line 845, in md5_hash_file with auto_open(full_path_name, mode='r') as source_file: File "/usr/local/lib/python2.7/dist-packages/lizard_ext/auto_open.py", line 21, in auto_open size = min(32, os.path.getsize(args[0])) File "/usr/lib/python2.7/genericpath.py", line 49, in getsize return os.stat(filename).st_size OSError: [Errno 2] No such file or directory: './a.py'

terryyin commented 7 years ago

Yeah, that's a known problem. I always delete that link so that it won't block me.

I will try to fix this in the code. Thanks for reporting.