From e9de4d136fc436590ecd226c34e39fe331b35d91 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 24 Nov 2015 10:26:30 -0600 Subject: [PATCH] Better tab checking, since we care about any tabs in the line, not just in initial indentation --- ansible_testing/modules.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ansible_testing/modules.py b/ansible_testing/modules.py index 033eadc4d8c..8bc344c34b3 100644 --- a/ansible_testing/modules.py +++ b/ansible_testing/modules.py @@ -27,7 +27,7 @@ from StringIO import StringIO BLACKLIST_DIRS = frozenset(('.git',)) -INDENT_REGEX = re.compile(r'(^[ \t]*)') +INDENT_REGEX = re.compile(r'([\t]*)') BASIC_RESERVED = frozenset((r for r in dir(module_utils_basic) if r[0] != '_')) @@ -176,11 +176,10 @@ class ModuleValidator(Validator): def _check_for_tabs(self): 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('\t') - self.errors.append('indentation contains tabs. line %d ' - 'column %d' % (line_no + 1, index)) + if indent and '\t' in line: + index = line.index('\t') + self.errors.append('indentation contains tabs. line %d ' + 'column %d' % (line_no + 1, index)) def _find_json_import(self): for child in self.ast.body: