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

Doesn't work when python file has no functions #188

Open philliparente opened 7 years ago

philliparente commented 7 years ago

When I run the analysis in a python file without any function inside, it is not be able to get the cyclomatic complexity. Is that some limitation?

rakhimov commented 7 years ago

try '-Eoutside'

philliparente commented 7 years ago

Thanks, but there is a way to run with extension as a python module? (ex: i = lizard.analyze_file("../cpputest/tests/AllTests.py"))?

rakhimov commented 7 years ago

Hmm, There's also 'analyze' function that takes a list of extensions, or you can call 'FileAnalyzer(get_extensions(['outside']))(filename)'. I didn't test test this, just a wild guess.

philliparente commented 7 years ago

Thanks, but when I run FileAnalyzer(get_extensions(['outside']))(filename) I get 'unicode' object is not callable. When I run without extension and with this aproach "FileAnalyzer(get_extensions([]))(filename)" the lizard runs, but can't get de cyclomatic complexity. There is a way to pass this extension as a python module?

terryyin commented 7 years ago

Hi @philliparente , use get_extensions(['outside']) to translate the string list to python modules.

philliparente commented 7 years ago

Oh, maybe my mistake. The get_extensions(['outside']) function doesn't work when you have "from future import unicode_literals" in the code. I removed the import and set unicode where i really need them. Thanks

terryyin commented 7 years ago

Which version of Python are you using? Let me try if I can reproduce this.

philliparente commented 7 years ago

2.7.12

terryyin commented 7 years ago

Can I close this issue now?

philliparente commented 7 years ago

Oh thanks for replying. Did you reproduce the environment error?