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

Incorrect nloc for Python function declarations spanning multiple lines #292

Open trouvant opened 4 years ago

trouvant commented 4 years ago

For example, analysis of the following function

def func(a,
         b):
    print(a)
    print(b)

yields nloc: 2.

def func(a,
         b,
         c):
    print(a)
    print(b)
    print(c)

yields nloc: 3.

I've tested both Python and C++, but it seems specific to Python.

sthagen commented 4 years ago

@trouvant the second example given really has three lines of code, right? Three print statements ...

alyssawangqq commented 3 years ago

Encountered the same issue as well. This seems to be a bug in Lizard python. When function declarations take more than 1 line, all metrics(LOC, CCN etc) will be calculated only on the declaration part but not implementation

@terryyin Hi Terry, can you help confirm is this is a bug unique to Python?