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

support Lua #251

Closed avancinirodrigo closed 4 years ago

avancinirodrigo commented 5 years ago

Hello,

Thank you for this good job.

It would be great if it were added support for Lua language (https://www.lua.org). Is it possible?

Thanks!

terryyin commented 5 years ago

Should be easy. Let me try.

terryyin commented 5 years ago

I've added the support for Lua in the code and also create a pip install release. Could you please try it?

avancinirodrigo commented 5 years ago

Thank you so much for doing that.

I don't know if it is working as expected. I've tried to get the function names in the attached file below and the result is this:

(
(
(
(
(
(
(
(
(
*global*
(
(
(
(
(
(
Cell

Cell.txt --> change extension to .lua

avancinirodrigo commented 5 years ago

@terryyin is there some news?

terryyin commented 4 years ago

sorry for the super late reply. This is working now.

avancinirodrigo commented 4 years ago

Thank you @terryyin.

Unfortunately, the problem has not been solved.

I think that it is not working because the functions are within a table.

Could you check that?

My test:

info = lizard.analyze_file('Cell.lua')
for func in info.function_list:
    print(func.__dict__)

Output:

{'cyclomatic_complexity': 5, 'nloc': 10, 'token_count': 68, 'name': '(', 'long_name': '(', 'start_line': 41, 'end_line': 52, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 12, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 2, 'nloc': 7, 'token_count': 66, 'name': '(', 'long_name': '(', 'start_line': 60, 'end_line': 68, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 9, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 1, 'nloc': 3, 'token_count': 16, 'name': '(', 'long_name': '(', 'start_line': 85, 'end_line': 87, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 3, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 5, 'nloc': 15, 'token_count': 94, 'name': '(', 'long_name': '(', 'start_line': 103, 'end_line': 118, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 16, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 1, 'nloc': 3, 'token_count': 12, 'name': '(', 'long_name': '(', 'start_line': 124, 'end_line': 126, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 3, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 5, 'nloc': 14, 'token_count': 63, 'name': '(', 'long_name': '(', 'start_line': 137, 'end_line': 152, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 16, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 1, 'nloc': 2, 'token_count': 3, 'name': '(', 'long_name': '(', 'start_line': 169, 'end_line': 170, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 2, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 1, 'nloc': 3, 'token_count': 8, 'name': '(', 'long_name': '(', 'start_line': 187, 'end_line': 189, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 3, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 2, 'nloc': 6, 'token_count': 54, 'name': '(', 'long_name': '(', 'start_line': 211, 'end_line': 217, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 7, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 1, 'nloc': 29, 'token_count': 118, 'name': '*global*', 'long_name': '*global*', 'start_line': 0, 'end_line': 343, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': -1, 'length': 344, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 1, 'nloc': 2, 'token_count': 3, 'name': '(', 'long_name': '(', 'start_line': 232, 'end_line': 233, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 2, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 3, 'nloc': 10, 'token_count': 61, 'name': '(', 'long_name': '(', 'start_line': 246, 'end_line': 257, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 12, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 1, 'nloc': 4, 'token_count': 22, 'name': '(', 'long_name': '(', 'start_line': 264, 'end_line': 267, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 4, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 4, 'nloc': 11, 'token_count': 55, 'name': '(', 'long_name': '(', 'start_line': 278, 'end_line': 289, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 12, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 3, 'nloc': 11, 'token_count': 37, 'name': '(', 'long_name': '(', 'start_line': 293, 'end_line': 304, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 12, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 1, 'nloc': 3, 'token_count': 11, 'name': '(', 'long_name': '(', 'start_line': 316, 'end_line': 318, 'parameters': [], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 3, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}
{'cyclomatic_complexity': 8, 'nloc': 39, 'token_count': 221, 'name': 'Cell', 'long_name': 'Cell data )', 'start_line': 343, 'end_line': 390, 'parameters': ['data'], 'filename': 'Cell.lua', 'top_nesting_level': 0, 'length': 48, 'fan_in': 0, 'fan_out': 0, 'general_fan_out': 0}