Some methods are too complex

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

Bug Description

This list of methods fails the cyclomatic complexity check when "flake8 --max-complexity 10" is run. Magnum should endeavour to have all method complexity at 10 or below.

./magnum/service/periodic.py:81:1: C901 'MagnumPeriodicTasks.sync_bay_status' is too complex (11)
./magnum/conductor/handlers/bay_conductor.py:222: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:193: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 (13)
./magnum/tests/functional/common/config.py:20:1: C901 'Config.setUp' is too complex (11)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on magnum (master)

Change abandoned by Tom Cammann (<email address hidden>) on branch: master
Review: https://review.openstack.org/229418
Reason: wrong change-id

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

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

commit f3b6ada57ba27eb8035e68a19e3e7fc579a03aa0
Author: Tom Cammann <email address hidden>
Date: Tue Sep 29 18:17:10 2015 +0100

    Reduce complexity of filter methods

    Two filtering methods had very high cyclomatic complexity, this change
    reduces their complexity.

    Partial-Bug: #1501331
    Change-Id: Idf5dcf83225c35e91cd0fe71eaa7abe32f7f2c6d

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

commit 41d41d640911929e0d99904672335b87d4463b63
Author: Tom Cammann <email address hidden>
Date: Wed Sep 30 14:07:21 2015 +0100

    Remove unnecessary util method temporary_mutation

    Util method temporary_mutation was introduced when copying the ironic
    code base. See: I14afd02f5791c74a2d5daf55681ae7047083037a. This method
    has never been used and can safely be removed. This method has a high
    cyclomatic complexity and was picked up by flake8.

    Change-Id: I5f62a7c9dfa79d697aac775f43e25a6cf68dfe23
    Partial-Bug: #1501331

Revision history for this message
Manav (manav-kiit) wrote :

i have checked the CC of all above listed functions. it shows only 'MagnumPeriodicTasks.sync_bay_status and 'HeatPoller.poll_and_check ' have CC more than 10

Changed in magnum:
assignee: nobody → Manav (manav-kiit)
status: New → Confirmed
Changed in magnum:
assignee: Manav (manav-kiit) → Tom Cammann (tom-cammann)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to magnum (master)

Fix proposed to branch: master
Review: https://review.openstack.org/235897

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/235898

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/235899

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

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

commit 64cc1413795b3d7bc011c3bd6a849960812c64de
Author: Tom Cammann <email address hidden>
Date: Wed Sep 30 14:09:58 2015 +0100

    Reduce complexity of poll_and_check method

    This is method is overly complex and should be broken down. When
    reducing the max complexity allowed by flake8 this method was flagged.
    Reducing the complexity of this method will allow better testing and
    maintenance.

    Partial-Bug: #1501331
    Change-Id: Id0bdb2d03614ba31de0d96ed09c33695d933b9f7

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

commit d2e05d4e9b6f54dacf201b51ef1de1f7939045b7
Author: Tom Cammann <email address hidden>
Date: Fri Oct 16 12:56:42 2015 +0100

    Refactor periodic task sync_bay_status

    The cyclomatic complexity of sync_bay_status was greater than 10 and
    very hard to comprehend. This patch reduces the complexity and makes the
    task more open to refactoring and maintence.

    Partial-Bug: #1501331
    Change-Id: If415aa7710b586b0429ed1bc5077976791b424d1

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

commit 82003a56e5dcf10abeddcd37721366798961550a
Author: Tom Cammann <email address hidden>
Date: Fri Oct 16 13:13:22 2015 +0100

    Refactor config setup to reduce complexity

    The cyclomatic complexity of the setup method was greater than 10 and
    reducing this complexity allows for easier understanding of the method.

    Change-Id: I45d085d0943fd18a4207fc7a9ba64f2c0f8074ea
    Partial-Bug: #1501331

Changed in magnum:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

commit ee52fbbcba2b61fa2347bdff0aae6de63bac24ef
Author: Tom Cammann <email address hidden>
Date: Fri Oct 16 13:28:05 2015 +0100

    Refactor MagnumException to reduce complexity

    Reduce cyclomatic complexity of MagnumException to below 10. Remove
    exception handling and optimise the logging when the kwargs does not
    match the message.

    Change-Id: I4fd6ba96be9dff485cdd8bde9750f2d584c1ec63
    Closes-Bug: #1501331

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.