From c80c5c4f4cc1f64bc48f02c7e49a67951fd24920 Mon Sep 17 00:00:00 2001 From: "Jay S. Bryant" Date: Mon, 6 Apr 2015 14:02:31 -0500 Subject: Correct cinder hacking check numbering We have a couple of hacking checks that are specific to Cinder that were written a while back. Unfortunately, when they were written the numbering scheme for hacking checks was not understood. We used N3xx when we should have used C3xx. This patch corrects that mistake. Change-Id: Ia17797005d444ab53a45b47b80b97799114001ee Closes-bug: 1440833 --- HACKING.rst | 4 ++-- cinder/hacking/checks.py | 48 ++++++++++++++++++++++++------------------------ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index 066b4eb18..54dcecdb2 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -11,16 +11,16 @@ Cinder Specific Commandments - [N319] Validate that debug level logs are not translated - [N322] Ensure default arguments are not mutable. - [N323] Add check for explicit import of _() to ensure proper translation. -- [N324] Enforce no use of LOG.audit messages. LOG.info should be used instead. - [N327] assert_called_once is not a valid Mock method. - [N328] LOG.info messages require translations `_LI()`. - [N329] LOG.exception and LOG.error messages require translations `_LE()`. - [N330] LOG.warning messages require translations `_LW()`. - [N333] Ensure that oslo namespaces are used for namespaced libraries. -- [N339] Prevent use of deprecated contextlib.nested. - [C301] timeutils.utcnow() from oslo_utils should be used instead of datetime.now(). - [C302] six.text_type should be used instead of unicode - [C303] Ensure that there are no 'print()' statements in code that is being committed. +- [C304] Enforce no use of LOG.audit messages. LOG.info should be used instead. +- [C305] Prevent use of deprecated contextlib.nested. General diff --git a/cinder/hacking/checks.py b/cinder/hacking/checks.py index e33ebf970..d677deb72 100644 --- a/cinder/hacking/checks.py +++ b/cinder/hacking/checks.py @@ -115,19 +115,6 @@ def check_explicit_underscore_import(logical_line, filename): yield(0, "N323: Found use of _() without explicit import of _ !") -def check_no_log_audit(logical_line): - """Ensure that we are not using LOG.audit messages - - Plans are in place going forward as discussed in the following - spec (https://review.openstack.org/#/c/91446/) to take out - LOG.audit messages. Given that audit was a concept invented - for OpenStack we can enforce not using it. - """ - - if no_audit_log.match(logical_line): - yield(0, "N324: Found LOG.audit. Use LOG.info instead.") - - def check_assert_called_once(logical_line, filename): msg = ("N327: assert_called_once is a no-op. please use assert_called_" "once_with to test with explicit parameters or an assertEqual with" @@ -179,15 +166,6 @@ def check_oslo_namespace_imports(logical_line): yield(0, msg) -def check_no_contextlib_nested(logical_line): - msg = ("N339: contextlib.nested is deprecated. With Python 2.7 and later " - "the with-statement supports multiple nested objects. See https://" - "docs.python.org/2/library/contextlib.html#contextlib.nested " - "for more information.") - if no_contextlib_nested.match(logical_line): - yield(0, msg) - - def check_datetime_now(logical_line, noqa): if noqa: return @@ -220,16 +198,38 @@ def check_no_print_statements(logical_line, filename, noqa): yield(0, msg) +def check_no_log_audit(logical_line): + """Ensure that we are not using LOG.audit messages + + Plans are in place going forward as discussed in the following + spec (https://review.openstack.org/#/c/91446/) to take out + LOG.audit messages. Given that audit was a concept invented + for OpenStack we can enforce not using it. + """ + + if no_audit_log.match(logical_line): + yield(0, "C304: Found LOG.audit. Use LOG.info instead.") + + +def check_no_contextlib_nested(logical_line): + msg = ("C305: contextlib.nested is deprecated. With Python 2.7 and later " + "the with-statement supports multiple nested objects. See https://" + "docs.python.org/2/library/contextlib.html#contextlib.nested " + "for more information.") + if no_contextlib_nested.match(logical_line): + yield(0, msg) + + def factory(register): register(no_vi_headers) register(no_translate_debug_logs) register(no_mutable_default_args) register(check_explicit_underscore_import) - register(check_no_log_audit) register(check_assert_called_once) register(check_oslo_namespace_imports) - register(check_no_contextlib_nested) register(check_datetime_now) register(validate_log_translations) register(check_unicode_usage) register(check_no_print_statements) + register(check_no_log_audit) + register(check_no_contextlib_nested) -- cgit v1.2.1