Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: fixed check-imports.py to ignore commented lines #3

Merged
merged 2 commits into from
Nov 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tools/check-imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)