Skip to content

Commit

Permalink
tools: Commented lines with spaces/tabs will also be ignored now
Browse files Browse the repository at this point in the history
    The script check-imports.py will now ignore commented lines with
spaces/tabs, and this fix also pointed the check to the correct src
folder.

    Fixes: nodejs#29226
  • Loading branch information
ayushmandey97 committed Nov 11, 2019
1 parent 3f7f560 commit 6f673dc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/check-imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import sys

def check_negative_cases(line, imported):
return re.match('using \w+::{0};'.format(imported), line) or re.match('^(\/\/)', line)
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 check_negative_cases(line, imported) and
re.search('(\b{0}\b)'.format(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 @@ -42,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)

0 comments on commit 6f673dc

Please sign in to comment.