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.82k stars 248 forks source link

bug-fixed: handle RecursionError #338

Closed cyw3 closed 2 years ago

cyw3 commented 2 years ago

I want to fix the question below:

$ python lizard.py --csv --sort cyclomatic_complexity --CCN 20 --working_threads 8 -l javascript -l python test.js
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/data/Python-v3.7.2/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "lizard.py", line 545, in __call__
    filename, auto_read(filename))
  File "lizard.py", line 565, in analyze_source_code
    for _ in reader(tokens, reader):
  File "/data/lizard-1.17.5/lizard_languages/code_reader.py", line 161, in __call__
    state(token)
  File "/data/lizard-1.17.5/lizard_languages/code_reader.py", line 45, in __call__
    if self._state(token):
  File "/data/lizard-1.17.5/lizard_languages/code_reader.py", line 45, in __call__
    if self._state(token):
  File "/data/lizard-1.17.5/lizard_languages/code_reader.py", line 45, in __call__
    if self._state(token):
  [Previous line repeated 485 more times]
  File "/data/lizard-1.17.5/lizard_languages/js_style_language_states.py", line 41, in _state_global
    self.statemachine_return()
  File "/data/lizard-1.17.5/lizard_languages/code_reader.py", line 37, in statemachine_return
    self.statemachine_before_return()
RecursionError: maximum recursion depth exceeded
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "lizard.py", line 1062, in <module>
    main()
  File "lizard.py", line 1045, in main
    warning_count = printer(result, options, schema, AllResult)
  File "/data/lizard-1.17.5/lizard_ext/__init__.py", line 17, in print_csv
    csv_output(total_factory(list(results)), options.verbose)
  File "/data/Python-v3.7.2/lib/python3.7/multiprocessing/pool.py", line 748, in next
    raise value
RecursionError: maximum recursion depth exceeded
terryyin commented 2 years ago

Thanks for fixing this long term problem.