Enable automatic validation of many HACKING rules.
* Add hacking to the tox build - a set of flake8 plugins that perform automatic validation of many HACKING.rst rules. * This patch configures hacking in the tox build and performs the mechanical cleanup required to allow the checks to pass. * See https://pypi.python.org/pypi/hacking Change-Id: Ie9b3eb5627a9b6dd181f79225abae422e6cf3777
This commit is contained in:
parent
5fbddaff84
commit
deb1e019f3
@ -21,7 +21,7 @@ import sys
|
||||
|
||||
|
||||
def is_localized(node):
|
||||
""" Check message wrapped by _() """
|
||||
"""Check message wrapped by _()"""
|
||||
if isinstance(node.parent, compiler.ast.CallFunc):
|
||||
if isinstance(node.parent.node, compiler.ast.Name):
|
||||
if node.parent.node.name == '_':
|
||||
@ -119,7 +119,7 @@ if __name__ == '__main__':
|
||||
cfg_path = sys.argv[2]
|
||||
try:
|
||||
cfg_mod = imp.load_source('', cfg_path)
|
||||
except:
|
||||
except Exception:
|
||||
print >> sys.stderr, "Load cfg module failed"
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -3,7 +3,7 @@ import re
|
||||
|
||||
|
||||
def is_log_callfunc(n):
|
||||
""" LOG.xxx('hello %s' % xyz) and LOG('hello') """
|
||||
"""LOG.xxx('hello %s' % xyz) and LOG('hello')"""
|
||||
if isinstance(n.parent, compiler.ast.Mod):
|
||||
n = n.parent
|
||||
if isinstance(n.parent, compiler.ast.CallFunc):
|
||||
@ -16,7 +16,7 @@ def is_log_callfunc(n):
|
||||
|
||||
|
||||
def is_log_i18n_msg_with_mod(n):
|
||||
""" LOG.xxx("Hello %s" % xyz) should be LOG.xxx("Hello %s", xyz) """
|
||||
"""LOG.xxx("Hello %s" % xyz) should be LOG.xxx("Hello %s", xyz)"""
|
||||
if not isinstance(n.parent.parent, compiler.ast.Mod):
|
||||
return False
|
||||
n = n.parent.parent
|
||||
@ -30,7 +30,7 @@ def is_log_i18n_msg_with_mod(n):
|
||||
|
||||
|
||||
def is_wrong_i18n_format(n):
|
||||
""" Check _('hello %s' % xyz) """
|
||||
"""Check _('hello %s' % xyz)"""
|
||||
if isinstance(n.parent, compiler.ast.Mod):
|
||||
n = n.parent
|
||||
if isinstance(n.parent, compiler.ast.CallFunc):
|
||||
|
@ -5,6 +5,7 @@ discover
|
||||
distribute>=0.6.24
|
||||
fixtures>=0.3.12
|
||||
flake8
|
||||
hacking
|
||||
mock>=1.0b1
|
||||
mox==0.5.3
|
||||
nose
|
||||
|
8
tox.ini
8
tox.ini
@ -38,8 +38,12 @@ commands = {posargs}
|
||||
# E711/E712 comparison to False should be 'if cond is False:' or 'if not cond:'
|
||||
# query = query.filter(Component.disabled == False)
|
||||
# E125 continuation line does not distinguish itself from next logical line
|
||||
# H hacking.py - automatic checks of rules in HACKING.rst
|
||||
ignore = E711,E712,E125,H
|
||||
# H301 one import per line
|
||||
# H302 import only modules
|
||||
# TODO(marun) H404 multi line docstring should start with a summary
|
||||
# TODO(marun) H901,902 use the not operator inline for clarity
|
||||
# TODO(markmcclain) H202 assertRaises Exception too broad
|
||||
ignore = E711,E712,E125,H301,H302,H404,H901,H902,H202
|
||||
show-source = true
|
||||
builtins = _
|
||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools
|
||||
|
Loading…
x
Reference in New Issue
Block a user