From 18938d283c5f87ab2e55f9f75626f313e8724bf9 Mon Sep 17 00:00:00 2001 From: Sahid Orentino Ferdjaoui Date: Tue, 29 Apr 2014 14:38:06 +0200 Subject: [PATCH] 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 --- nova/api/metadata/__init__.py | 1 - nova/console/__init__.py | 1 - nova/hacking/checks.py | 13 +++++++++---- nova/scheduler/__init__.py | 3 --- nova/tests/test_hacking.py | 4 ++++ 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/nova/api/metadata/__init__.py b/nova/api/metadata/__init__.py index 964707ba79ba..e4715a91c51e 100644 --- a/nova/api/metadata/__init__.py +++ b/nova/api/metadata/__init__.py @@ -19,5 +19,4 @@ .. automodule:: nova.api.metadata :platform: Unix :synopsis: Metadata Server for Nova -.. moduleauthor:: Vishvananda Ishaya """ diff --git a/nova/console/__init__.py b/nova/console/__init__.py index f7fabcd5feda..2f9cc4d00812 100644 --- a/nova/console/__init__.py +++ b/nova/console/__init__.py @@ -19,5 +19,4 @@ :platform: Unix :synopsis: Wrapper around console proxies such as xvp to set up multitenant VM console access -.. moduleauthor:: Monsyne Dragon """ diff --git a/nova/hacking/checks.py b/nova/hacking/checks.py index 9bb974e5ea1d..d68aa65c5799 100644 --- a/nova/hacking/checks.py +++ b/nova/hacking/checks.py @@ -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,9 +159,13 @@ def no_vi_headers(physical_line, line_number, lines): def no_author_tags(physical_line): - if author_tag_re.match(physical_line): - pos = physical_line.find('author') - return pos, "N315: Don't use author tags" + 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" def assert_true_instance(logical_line): diff --git a/nova/scheduler/__init__.py b/nova/scheduler/__init__.py index ff2609381f9e..7b776afe3bed 100644 --- a/nova/scheduler/__init__.py +++ b/nova/scheduler/__init__.py @@ -19,7 +19,4 @@ .. automodule:: nova.scheduler :platform: Unix :synopsis: Module that picks a compute node to run a VM instance. -.. moduleauthor:: Sandy Walsh -.. moduleauthor:: Ed Leafe -.. moduleauthor:: Chris Behrens """ diff --git a/nova/tests/test_hacking.py b/nova/tests/test_hacking.py index ca3ae9734377..f7a746d3caf4 100644 --- a/nova/tests/test_hacking.py +++ b/nova/tests/test_hacking.py @@ -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(