[openstack-dev] [nova] Complexity check and v2 API

Pasquale Porreca pasquale.porreca at dektech.com.au
Wed Dec 17 16:18:10 UTC 2014


Hello

I am working on an API extension that adds a parameter on create server
call; to implement the v2 API I added few lines of code to
nova/api/openstack/compute/servers.py

In particular just adding something like

|new_param = None||
||if self.ext_mgr.is_loaded('os-new-param'):||
||    new_param = server_dict.get('new_param')|

leads to a pep8 fail with message 'Controller.create' is too complex (47)
(Note that in tox.ini the max complexity is fixed to 47 and there is a
note specifying 46 is the max complexity present at the moment).

It is quite easy to make this test pass creating a new method just to
execute these lines of code, anyway all other extensions are handled in
that way and one of most important stylish rule states to be consistent
with surrounding code, so I don't think a separate function is the way
to go (unless it implies a change in how all other extensions are
handled too).

My thoughts on this situation:

1) New extensions should not consider v2 but only v2.1, so that file
should not be touched
2) Ignore this error and go on: if and when the extension will be merged
the complexity in tox.ini will be changed too
3) The complexity in tox.ini should be raised to allow new v2 extensions
4) The code of that module should be refactored to lower the complexity
(i.e. move the load of each extension in a separate function)

I would like to know if any of my point is close to the correct solution.

-- 
Pasquale Porreca

DEK Technologies
Via dei Castelli Romani, 22
00040 Pomezia (Roma)

Mobile +39 3394823805
Skype paskporr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20141217/fd9ffbe6/attachment.html>


More information about the OpenStack-dev mailing list