PyCQA/mccabe

Trivial function with docstring reports complexity of 2

asottile opened this issue · 2 comments

def f():
    """hi"""
    x = 1


def g():
    """hi"""
$ python3.5 mccabe.py test.py
1:0: 'f' 1
6:0: 'g' 2
$ git rev-parse HEAD
682145a37fee41fe7b6640244faa0c3f58e3b496

I suspect this is related to the computation needing both nodes and edges to calculate the complexity.

I have a fix for this in #47, mccabe wasn't considering the Expr node as a statement (despite being a statement type). I've adjusted the logic to just handle all statements generically