From 21213ee91cdbe5917fb93d4165c74ae6341bfa0b Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 6 Feb 2014 12:06:48 +0000 Subject: [PATCH] Renumber some nova hacking checks Most of the nova hacking checks had picked numbers starting from approx N300 onwards. Two recent additions randomly picked N123 and N500. Renumber these to N313 and N314 and make sure they're documented in HACKING.rst. Mention the guidelines in the hacking source file for benefit of future authors Change-Id: Ia3eb4cb9a4ac7409db7eba9e1689f4a5780b8795 --- HACKING.rst | 4 +++- nova/hacking/checks.py | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index d2d9d51ab8..0a6119d855 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -19,7 +19,9 @@ Nova Specific Commandments - [N312] using config vars from other virt drivers forbidden Config parameters that need to be shared between virt drivers should be moved into a common module -- [N123] vim configuration should not be kept in source files. +- [N313] capitalize help string + Config parameter help strings should have a capitalized first letter +- [N314] vim configuration should not be kept in source files. Creating Unit Tests ------------------- diff --git a/nova/hacking/checks.py b/nova/hacking/checks.py index e37da86673..22a4cf4e8f 100644 --- a/nova/hacking/checks.py +++ b/nova/hacking/checks.py @@ -15,6 +15,20 @@ import re +""" +Guidelines for writing new hacking checks + + - Use only for Nova specific tests. OpenStack general tests + should be submitted to the common 'hacking' module. + - Pick numbers in the range N3xx. Find the current test with + the highest allocated number and then pick the next value. + - Keep the test method code in the source file ordered based + on the N3xx value. + - List the new rule in the top level HACKING.rst file + - Add test cases for each new rule to nova/tests/test_hacking.py + +""" + session_check = re.compile("\w*def [a-zA-Z0-9].*[(].*session.*[)]") cfg_re = re.compile(".*\scfg\.") vi_header_re = re.compile("^#\s+vim?:.+") @@ -106,7 +120,7 @@ def import_no_virt_driver_config_deps(physical_line, filename): def capital_cfg_help(logical_line, tokens): - msg = "N500: capitalize help string" + msg = "N313: capitalize help string" if cfg_re.match(logical_line): for t in range(len(tokens)): @@ -122,12 +136,12 @@ def no_vi_headers(physical_line, line_number, lines): By default vi modelines can only appear in the first or last 5 lines of a source file. - N123 + N314 """ # NOTE(gilliard): line_number is 1-indexed if line_number <= 5 or line_number > len(lines) - 5: if vi_header_re.match(physical_line): - return 0, "N123: Don't put vi configuration in source files" + return 0, "N314: Don't put vi configuration in source files" def factory(register):