From 47f2101e8d56e644f6f99207a06f480d13260f32 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 20 Mar 2019 16:08:25 -0700 Subject: [PATCH] Fix no-underscore-variable test. (#54137) * Ignore lines with comments. * Detect variables at the start of the line. --- test/sanity/code-smell/no-underscore-variable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sanity/code-smell/no-underscore-variable.py b/test/sanity/code-smell/no-underscore-variable.py index 9640d976c9..2a56865f75 100755 --- a/test/sanity/code-smell/no-underscore-variable.py +++ b/test/sanity/code-smell/no-underscore-variable.py @@ -127,7 +127,7 @@ def main(): with open(path, 'r') as path_fd: for line, text in enumerate(path_fd.readlines()): - match = re.search(r'(?: |[^C]\()(_)(?:[ ,)])', text) + match = re.search(r'^[^#]*(?:^| |[^C]\()(_)(?:[ ,)])', text) if match: print('%s:%d:%d: use `dummy` instead of `_` for a variable name' % (