Skip to content

Commit

Permalink
tools: fixed check-imports.py to ignore commented lines
Browse files Browse the repository at this point in the history
The script check-imports.py will now ignore the usage of module names in
commented lines. Additionally, while searching for the usage,
word boundaries will be used. Eg: 'Just' would not be considered in a
sentence containing 'FromJust'.

Fixes: nodejs#29226
  • Loading branch information
ayushmandey97 committed Sep 29, 2019
1 parent ce62e96 commit 3f7f560
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 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('^(\/\/)', 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('(\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

0 comments on commit 3f7f560

Please sign in to comment.