diff --git a/tools/check-imports.py b/tools/check-imports.py index b71b4a9271dfc4..8bcefc757c3ec2 100755 --- a/tools/check-imports.py +++ b/tools/check-imports.py @@ -5,10 +5,13 @@ import re import sys +def check_negative_cases(line, imported): + return re.match('using \w+::{0};'.format(imported), line) or re.match('^( )*(\t)*(\/\/)', line) + def do_exist(file_name, lines, imported): - if not any(not re.match('using \w+::{0};'.format(imported), line) and - re.search(imported, line) for line in lines): + if not any((not check_negative_cases(line, imported)) and + re.search(r'(\b{0}\b)'.format(imported), line) for line in lines): print('File "{0}" does not use "{1}"'.format(file_name, imported)) return False return True @@ -39,4 +42,4 @@ def is_valid(file_name): else: return valid -sys.exit(0 if all(map(is_valid, glob.iglob('src/*.cc'))) else 1) +sys.exit(0 if all(map(is_valid, glob.iglob('../src/*.cc'))) else 1)