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

Lizard script doesn't working with jython in springboot applicatoion #367

Open pawan-panwar opened 1 year ago

pawan-panwar commented 1 year ago

public void result() { StringWriter output = new StringWriter(); PythonInterpreter pyInterp = new PythonInterpreter(); pyInterp.setOut(output); pyInterp.exec("import sys"); pyInterp.exec("sys.path.append('/Users/abcd/Desktop/lizard_code/lizard-1.17.10/')"); pyInterp.exec("import lizard"); pyInterp.exec("i = lizard.analyze_file(\"/Users/abcd/Desktop/lizardcdb_code/test.java\")"); pyInterp.exec("s = i.dict.getitem(\"function_list\")"); PyObject x = pyInterp.get("s"); System.out.println(x.getitem(0).getDict().finditem("cyclomatic_complexity"));

}

While using the above code in normal java class its working fine and when we run this code using spring boot application its throw below error-

Traceback (most recent call last): File "script.py", line 4, in i = lizard.analyze_file("/Users/abcd/Desktop/lizard_code/test.java") File "/Users/abcd/Desktop/lizard_code/lizard-1.17.10/lizard.py", line 546, in call return self.analyze_source_code( File "/Users/abcd/Desktop/lizard_code/lizard-1.17.10/lizard.py", line 546, in call return self.analyze_source_code( File "/Users/abcd/Desktop/lizard_code/lizard-1.17.10/lizard_ext/auto_open.py", line 0, in auto_read File "/Users/abcd/Desktop/lizard_code/lizard-1.17.10/lizard_ext/auto_open.py", line 0, in auto_read File "/Users/abcd/Desktop/lizard_code/lizard-1.17.10/lizard_ext/auto_open.py", line 21, in auto_open size = min(32, os.path.getsize(args[0])) AttributeError: 'javapackage' object has no attribute 'open'

Jython dependency -

org.python jython-standalone 2.7.3