I'm doing research on software engineering.
I need to measure how many lines each function or class has in each file.
Another interesting metric would be the number of functions and the cyclomatic complexity of each one.
I'm doing research on software engineering.
I need to measure how many lines each function or class has in each file.
Another interesting metric would be the number of functions and the cyclomatic complexity of each one.
You can do something like this
import inspect
def test(param1, param2):
print(param1, param2)
print(1+1)
inspect.getsource(test)
# 'def test(param1, param2):\n print(param1, param2)\n print(1+1)\n'
inspect.getsource(test).count("\n")
# 3