From 2ef91a7e7788515dd6ed92946e68127bcb8efa41 Mon Sep 17 00:00:00 2001 From: zhangguoqing Date: Fri, 18 Mar 2016 20:29:18 +0800 Subject: [PATCH] hacking log warn LOG.warn is deprecated in Python 3 [1], so add hacking warn. [1]https://docs.python.org/3/library/logging.html#logging.warning Change-Id: I95aa121c2b11437a086d7f8bee25ffa956dd3e4f --- heat/hacking/__init__.py | 0 heat/hacking/checks.py | 29 +++++++++++++++++++++++++++++ tox.ini | 1 + 3 files changed, 30 insertions(+) create mode 100644 heat/hacking/__init__.py create mode 100644 heat/hacking/checks.py diff --git a/heat/hacking/__init__.py b/heat/hacking/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/heat/hacking/checks.py b/heat/hacking/checks.py new file mode 100644 index 0000000000..fb2d1d2d4b --- /dev/null +++ b/heat/hacking/checks.py @@ -0,0 +1,29 @@ +# Copyright (c) 2016 OpenStack Foundation +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +def no_log_warn(logical_line): + """Disallow 'LOG.warn(' + + https://bugs.launchpad.net/tempest/+bug/1508442 + + H001 + """ + if logical_line.startswith('LOG.warn('): + yield(0, 'H001 Use LOG.warning() rather than LOG.warn()') + + +def factory(register): + register(no_log_warn) diff --git a/tox.ini b/tox.ini index 53c657b640..fce08e8935 100644 --- a/tox.ini +++ b/tox.ini @@ -68,6 +68,7 @@ max-complexity=20 [hacking] import_exceptions = heat.common.i18n +local-check-factory = heat.hacking.checks.factory [testenv:debug] commands = oslo_debug_helper {posargs}