[openstack-dev] [nova] Proposal new hacking rules
Sahid Orentino Ferdjaoui
sahid.ferdjaoui at redhat.com
Thu Nov 20 17:49:48 UTC 2014
This is something we can call nitpiking or low priority.
I would like we introduce 3 new hacking rules to enforce the cohesion
and consistency in the base code.
Using boolean assertions
------------------------
Some tests are written with equality assertions to validate boolean
conditions which is something not clean:
assertFalse([]) asserts an empty list
assertEqual(False, []) asserts an empty list is equal to the boolean
value False which is something not correct.
Some changes has been started here but still needs to be appreciated
by community:
* https://review.openstack.org/#/c/133441/
* https://review.openstack.org/#/c/119366/
Using same order of arguments in equality assertions
----------------------------------------------------
Most of the code is written with assertEqual(Expected, Observed) but
some part are still using the opposite. Even if they provide any real
optimisation using the same convention help reviewing and keep a
better consistency in the code.
assertEqual(Expected, Observed) OK
assertEqual(Observed, Expected) KO
A change has been started here but still needs to be appreciated by
community:
* https://review.openstack.org/#/c/119366/
Using LOG.warn instead of LOG.warning
-------------------------------------
We can see many time reviewers -1ed a patch to ask developer to use
'warn' instead of 'warning'. This will provide no optimisation
but let's finally have something clear about what we have to use.
LOG.warning: 74
LOG.warn: 319
We probably want to use 'warn'
Nothing has been started from what I know.
Thanks,
s.
More information about the OpenStack-dev
mailing list