From 95c9e11cbad75458c24b1cf36b1176b303135879 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 5 Oct 2015 11:10:30 -0500 Subject: [PATCH] Give line no and column for indentation --- ansible_testing/modules.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ansible_testing/modules.py b/ansible_testing/modules.py index 8293c4677f..640c00885e 100644 --- a/ansible_testing/modules.py +++ b/ansible_testing/modules.py @@ -21,7 +21,7 @@ except ImportError: BLACKLIST_DIRS = frozenset(('.git',)) -INDENT_REGEX = re.compile(r'(^[ \t]*)', flags=re.M) +INDENT_REGEX = re.compile(r'(^[ \t]*)') class Validator(object): @@ -170,11 +170,13 @@ class ModuleValidator(Validator): self.errors.append('GPLv3 license header not found') def _check_for_tabs(self): - indent = INDENT_REGEX.findall(self.text) - for i in indent: - if '\t' in i: - self.errors.append('indentation contains tabs') - break + for line_no, line in enumerate(self.text.splitlines()): + indent = INDENT_REGEX.search(line) + for i in indent.groups(): + if '\t' in i: + index = line.index(i) + self.errors.append('indentation contains tabs. line %d ' + 'column %d' % (line_no, index)) def _find_json_import(self): for child in self.ast.body: