Update hacking to 0.10

Release notes:
http://git.openstack.org/cgit/openstack-dev/hacking/tag/?id=0.10.0

* Remove references in tox.ini to removed rules.
* Remove custom @author check since it's now implemented in hacking.
* Move N323 to N322 that is freed due to @author check removal.
* Temporarily skip W292 (no newline at the end of file).
* Temporarily skip H238 (old style classes).

Change-Id: I6d990a564df6a312bd09b2a152315bbdba732082
This commit is contained in:
Ihar Hrachyshka 2015-01-12 17:04:14 +01:00
parent f83b08abf5
commit 1de25088b4
5 changed files with 6 additions and 33 deletions

View File

@ -11,9 +11,7 @@ Neutron Specific Commandments
- [N319] Validate that debug level logs are not translated
- [N320] Validate that LOG messages, except debug ones, have translations
- [N321] Validate that jsonutils module is used instead of json
- [N322] We do not use @authors tags in source files. We have git to track
authorship.
- [N323] Detect common errors with assert_called_once_with
- [N322] Detect common errors with assert_called_once_with
Creating Unit Tests
-------------------

View File

@ -28,8 +28,6 @@ import pep8
# - Add test cases for each new rule to
# neutron/tests/unit/test_hacking.py
author_tag_re = re.compile(r"^\s*#\s*@?[aA]uthor|^\.\.\s+moduleauthor::")
_all_log_levels = {
# NOTE(yamamoto): Following nova which uses _() for audit.
'audit': '_',
@ -88,15 +86,6 @@ def use_jsonutils(logical_line, filename):
yield (pos, msg % {'fun': f[:-1]})
def no_author_tags(physical_line):
if author_tag_re.match(physical_line):
physical_line = physical_line.lower()
pos = physical_line.find('moduleauthor')
if pos < 0:
pos = physical_line.find('author')
return pos, "N322: Don't use author tags"
def no_translate_debug_logs(logical_line, filename):
"""Check for 'LOG.debug(_(' and 'LOG.debug(_Lx('
@ -120,7 +109,7 @@ def check_assert_called_once_with(logical_line, filename):
if '.assert_called_once_with(' in logical_line:
return
if '.assertcalledonce' in logical_line.lower().replace('_', ''):
msg = ("N323: Possible use of no-op mock method. "
msg = ("N322: Possible use of no-op mock method. "
"please use assert_called_once_with.")
yield (0, msg)
@ -128,6 +117,5 @@ def check_assert_called_once_with(logical_line, filename):
def factory(register):
register(validate_log_translations)
register(use_jsonutils)
register(no_author_tags)
register(check_assert_called_once_with)
register(no_translate_debug_logs)

View File

@ -80,18 +80,6 @@ class HackingTestCase(base.BaseTestCase):
"./neutron/plugins/openvswitch/agent/xenapi/etc/xapi.d/"
"plugins/netwrap"))))
def test_no_author_tags(self):
self.assertIsInstance(checks.no_author_tags("# author: pele"), tuple)
self.assertIsInstance(checks.no_author_tags("# @author: pele"), tuple)
self.assertIsInstance(checks.no_author_tags("# @Author: pele"), tuple)
self.assertIsInstance(checks.no_author_tags("# Author: pele"), tuple)
self.assertIsInstance(checks.no_author_tags("# Author pele"), tuple)
self.assertIsInstance(checks.no_author_tags(".. moduleauthor:: pele"),
tuple)
self.assertEqual(2, checks.no_author_tags("# author: pele")[0])
self.assertEqual(2, checks.no_author_tags("# Author: pele")[0])
self.assertEqual(3, checks.no_author_tags(".. moduleauthor:: pele")[0])
def test_assert_called_once_with(self):
fail_code1 = """
mock = Mock()

View File

@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking>=0.9.2,<0.10
hacking>=0.10.0,<0.11
cliff>=1.7.0 # Apache-2.0
coverage>=3.6

View File

@ -75,13 +75,12 @@ commands = python setup.py build_sphinx
# E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line
# E265 block comment should start with #
# H238 old style class declaration, use new style
# H305 imports not grouped correctly
# H307 like imports should be grouped together
# H402 one line docstring needs punctuation
# H404 multi line docstring should start with a summary
# H405 multi line docstring summary not separated with an empty line
# H904 Wrap long lines in parentheses instead of a backslash
ignore = E125,E126,E128,E129,E265,H305,H307,H402,H404,H405,H904
# W292 no newline at end of file
ignore = E125,E126,E128,E129,E265,H238,H305,H404,H405,W292
show-source = true
builtins = _
# TODO(dougw) neutron/tests/unit/vmware exclusion is a temporary services split hack