1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix no-underscore-variable test. (#54137)

* Ignore lines with comments.
* Detect variables at the start of the line.
This commit is contained in:
Matt Clay 2019-03-20 16:08:25 -07:00 committed by Matt Davis
parent c431d18e28
commit 47f2101e8d

View file

@ -127,7 +127,7 @@ def main():
with open(path, 'r') as path_fd: with open(path, 'r') as path_fd:
for line, text in enumerate(path_fd.readlines()): for line, text in enumerate(path_fd.readlines()):
match = re.search(r'(?: |[^C]\()(_)(?:[ ,)])', text) match = re.search(r'^[^#]*(?:^| |[^C]\()(_)(?:[ ,)])', text)
if match: if match:
print('%s:%d:%d: use `dummy` instead of `_` for a variable name' % ( print('%s:%d:%d: use `dummy` instead of `_` for a variable name' % (