Use --max-complexity flake8 rule

Bug #1498872 reported by Tom Cammann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Magnum
Fix Released
Undecided
Unassigned

Bug Description

This feature is quite useful to detect over-complex code. According to McCabe, anything that goes beyond 10 is too complex. See https://en.wikipedia.org/wiki/Cyclomatic_complexity.

Currently the max complexity in the magnum code base is 13:

        ./magnum/service/periodic.py:51:1: C901 'MagnumPeriodicTasks.sync_bay_status' is too complex (11)
        ./magnum/conductor/handlers/bay_conductor.py:220:1: C901 'HeatPoller.poll_and_check' is too complex (12)
        ./magnum/common/magnum_keystoneclient.py:97:1: C901 'KeystoneClientV3._v3_client_init' is too complex (10)
        ./magnum/common/exception.py:192:1: C901 'MagnumException.__init__' is too complex (10)
        ./magnum/common/utils.py:335:1: C901 'temporary_mutation' is too complex (12)
        ./magnum/db/sqlalchemy/api.py:125:1: C901 'Connection._add_bays_filters' is too complex (13)
        ./magnum/db/sqlalchemy/api.py:295:1: C901 'Connection._add_baymodels_filters' is too complex (12)

Setting the max complexity to 14 allows us to not produce anything more complex. We can work on reducing our complex functions and reducing this number to 10.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to magnum (master)

Reviewed: https://review.openstack.org/224184
Committed: https://git.openstack.org/cgit/openstack/magnum/commit/?id=d907843ae43a267f4980c0e5b72b305f9d18dcc5
Submitter: Jenkins
Branch: master

commit d907843ae43a267f4980c0e5b72b305f9d18dcc5
Author: Tom Cammann <email address hidden>
Date: Wed Sep 16 17:21:44 2015 +0100

    Use --max-complexity flake8 rule

    This feature is quite useful to detect over-complex code. According to
    McCabe, anything that goes beyond 10 is too complex. See
    https://en.wikipedia.org/wiki/Cyclomatic_complexity.

    Currently the max complexity is 13:

        ./magnum/service/periodic.py:51:1: C901 'MagnumPeriodicTasks.sync_bay_status' is too complex (11)
        ./magnum/conductor/handlers/bay_conductor.py:220:1: C901 'HeatPoller.poll_and_check' is too complex (12)
        ./magnum/common/magnum_keystoneclient.py:97:1: C901 'KeystoneClientV3._v3_client_init' is too complex (10)
        ./magnum/common/exception.py:192:1: C901 'MagnumException.__init__' is too complex (10)
        ./magnum/common/utils.py:335:1: C901 'temporary_mutation' is too complex (12)
        ./magnum/db/sqlalchemy/api.py:125:1: C901 'Connection._add_bays_filters' is too complex (13)
        ./magnum/db/sqlalchemy/api.py:295:1: C901 'Connection._add_baymodels_filters' is too complex (12)

    Setting the max complexity to 14 allows us to not produce anything more
    complex. We can work on reducing our complex functions and reducing this
    number to 10.

    Change-Id: Iaf9c87ecb4873e646d952fd892aafeb7c91fb5e5
    Closes-Bug: #1498872

Changed in magnum:
status: New → Fix Committed
Adrian Otto (aotto)
Changed in magnum:
milestone: none → mitaka-1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.