2012-05-03 10:48:26 -07:00
|
|
|
Cinder Style Commandments
|
2013-07-12 16:47:01 +01:00
|
|
|
=========================
|
2012-05-03 10:48:26 -07:00
|
|
|
|
2013-07-12 16:47:01 +01:00
|
|
|
- Step 1: Read the OpenStack Style Commandments
|
2017-09-06 15:14:27 +08:00
|
|
|
https://docs.openstack.org/hacking/latest/
|
2013-07-12 16:47:01 +01:00
|
|
|
- Step 2: Read on
|
2012-05-03 10:48:26 -07:00
|
|
|
|
2013-07-12 16:47:01 +01:00
|
|
|
Cinder Specific Commandments
|
|
|
|
----------------------------
|
2014-08-03 12:46:45 -05:00
|
|
|
- [N322] Ensure default arguments are not mutable.
|
2014-08-02 18:06:38 -05:00
|
|
|
- [N323] Add check for explicit import of _() to ensure proper translation.
|
2019-02-19 16:51:56 -06:00
|
|
|
- [C301] timeutils.utcnow() from oslo_utils should be used instead of
|
|
|
|
datetime.now().
|
2020-04-01 15:48:09 -05:00
|
|
|
- [C303] Ensure that there are no 'print()' statements are used in code that
|
|
|
|
should be using LOG calls.
|
2015-03-19 13:24:00 +01:00
|
|
|
- [C306] timeutils.strtime() must not be used (deprecated).
|
2015-05-16 14:39:23 +02:00
|
|
|
- [C308] timeutils.isotime() must not be used (deprecated).
|
2015-07-01 15:14:57 -05:00
|
|
|
- [C309] Unit tests should not perform logging.
|
2015-09-03 12:07:19 -05:00
|
|
|
- [C310] Check for improper use of logging format arguments.
|
2015-09-14 20:37:00 -05:00
|
|
|
- [C311] Check for proper naming and usage in option registration.
|
2017-06-29 04:04:26 -04:00
|
|
|
- [C312] Validate that logs are not translated.
|
2015-11-17 12:39:58 -06:00
|
|
|
- [C313] Check that assertTrue(value) is used and not assertEqual(True, value).
|
2020-04-01 15:48:09 -05:00
|
|
|
- [C336] Must use a dict comprehension instead of a dict constructor with a
|
|
|
|
sequence of key-value pairs.
|
|
|
|
- [C337] Ensure the standard library mock modules is used and not the third
|
|
|
|
party mock library that was needed for Python 2 support.
|
2021-11-29 14:18:00 +09:00
|
|
|
- [C338] Log.warn is deprecated. Enforce use of LOG.warning.
|
2014-08-01 15:43:51 -05:00
|
|
|
|
2012-05-03 10:48:26 -07:00
|
|
|
General
|
|
|
|
-------
|
2019-02-19 16:51:56 -06:00
|
|
|
- Use 'raise' instead of 'raise e' to preserve original traceback or exception
|
|
|
|
being reraised::
|
2013-06-24 15:19:50 +04:00
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
...
|
|
|
|
raise e # BAD
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
...
|
|
|
|
raise # OKAY
|
2012-05-03 10:48:26 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Creating Unit Tests
|
|
|
|
-------------------
|
|
|
|
For every new feature, unit tests should be created that both test and
|
|
|
|
(implicitly) document the usage of said feature. If submitting a patch for a
|
|
|
|
bug that had no unit test, a new passing unit test should be added. If a
|
|
|
|
submitted bug fix does have a unit test, be sure to add a new one that fails
|
|
|
|
without the patch and passes with the patch.
|
|
|
|
|
|
|
|
For more information on creating unit tests and utilizing the testing
|
2016-07-01 15:08:43 +05:30
|
|
|
infrastructure in OpenStack Cinder, please see
|
2017-08-26 06:51:26 -07:00
|
|
|
https://docs.openstack.org/cinder/latest/contributor/testing.html
|