Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

off by two #5

Closed
bukzor opened this issue Apr 3, 2014 · 4 comments · Fixed by #6
Closed

off by two #5

bukzor opened this issue Apr 3, 2014 · 4 comments · Fixed by #6

Comments

@bukzor
Copy link
Contributor

bukzor commented Apr 3, 2014

The minimum complexity on the mccabe scale is one.
The simplest function should pass flake8 when max-complexity is 1.

There's two reasons this doesn't work:

  • "max complexity" in fact specifies the minimum complexity which is not acceptable. Please note the difference in adjectives between the field's name and its description.
  • The simplest function has a measured complexity of two. Using a definition from Wikipedia ( M = π − s + 2 where π is the number of decision points in the program, and s is the number of exit points), I count zero decision points and one exit point, resulting in M==1.
$ cat trivial.py 
def trivial():
    return None

$ flake8 --max-complexity 1 trivial.py 
trivial.py:1:1: C901 'trivial' is too complex (2)
@sigmavirus24
Copy link
Member

That means that we're off by one, not by two.

@bukzor
Copy link
Contributor Author

bukzor commented Apr 18, 2014

If you say so, but you'll find that there needs to be two off-by-one fixes to get the above scenario working properly:

  1. Adjust the complexity measure to properly get a value of 1.
  2. Adjust the max-complexity logic to accept a complexity of 1.

sigmavirus24 added a commit to sigmavirus24/mccabe that referenced this issue Apr 18, 2014
@schlamar
Copy link
Contributor

schlamar commented May 8, 2014

@sigmavirus24 any ETA for a release? This bug is really annyoing...

@sigmavirus24
Copy link
Member

@schlamar I never received the ability to ship a release from @florentx . You'll have to redirect that question to him.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants