Improve hacking rule to avoid author markers

The case with the tag "moduleauthor" is not handled when
checking to avoid author makers.
Also fix the position when the tag Author is used.

Change-Id: I17b07b9f5448f9cbb4c5705f655c5392316a6239
Closes-Bug: #1314176
This commit is contained in:
Sahid Orentino Ferdjaoui 2014-04-29 14:38:06 +02:00
parent 2acd7fbe85
commit 18938d283c
5 changed files with 13 additions and 9 deletions

View File

@ -19,5 +19,4 @@
.. automodule:: nova.api.metadata
:platform: Unix
:synopsis: Metadata Server for Nova
.. moduleauthor:: Vishvananda Ishaya <vishvananda@gmail.com>
"""

View File

@ -19,5 +19,4 @@
:platform: Unix
:synopsis: Wrapper around console proxies such as xvp to set up
multitenant VM console access
.. moduleauthor:: Monsyne Dragon <mdragon@rackspace.com>
"""

View File

@ -37,7 +37,8 @@ virt_import_re = re.compile(
r"^\s*(?:import|from) nova\.(?:tests\.)?virt\.(\w+)")
virt_config_re = re.compile(
r"CONF\.import_opt\('.*?', 'nova\.virt\.(\w+)('|.)")
author_tag_re = re.compile("^\s*#\s*@?(a|A)uthor:")
author_tag_re = (re.compile("^\s*#\s*@?(a|A)uthor:"),
re.compile("^\.\.\s+moduleauthor::"))
asse_trueinst_re = re.compile(
r"(.)*assertTrue\(isinstance\((\w|\.|\'|\"|\[|\])+, "
"(\w|\.|\'|\"|\[|\])+\)\)")
@ -158,7 +159,11 @@ def no_vi_headers(physical_line, line_number, lines):
def no_author_tags(physical_line):
if author_tag_re.match(physical_line):
for regex in author_tag_re:
if regex.match(physical_line):
physical_line = physical_line.lower()
pos = physical_line.find('moduleauthor')
if pos < 0:
pos = physical_line.find('author')
return pos, "N315: Don't use author tags"

View File

@ -19,7 +19,4 @@
.. automodule:: nova.scheduler
:platform: Unix
:synopsis: Module that picks a compute node to run a VM instance.
.. moduleauthor:: Sandy Walsh <sandy.walsh@rackspace.com>
.. moduleauthor:: Ed Leafe <ed@leafe.com>
.. moduleauthor:: Chris Behrens <cbehrens@codestud.com>
"""

View File

@ -54,7 +54,11 @@ class HackingTestCase(test.NoDBTestCase):
self.assertTrue(checks.no_author_tags("# @author: jogo"))
self.assertTrue(checks.no_author_tags("# @Author: jogo"))
self.assertTrue(checks.no_author_tags("# Author: jogo"))
self.assertTrue(checks.no_author_tags(".. moduleauthor:: jogo"))
self.assertFalse(checks.no_author_tags("# authorization of this"))
self.assertEqual(2, checks.no_author_tags("# author: jogo")[0])
self.assertEqual(2, checks.no_author_tags("# Author: jogo")[0])
self.assertEqual(3, checks.no_author_tags(".. moduleauthor:: jogo")[0])
def test_assert_true_instance(self):
self.assertEqual(len(list(checks.assert_true_instance(