From da3ce668fa223f351fa0329f3b5f8d813f74115d Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 30 Jun 2015 13:51:01 -0500 Subject: [PATCH] Check for tabbed indentation --- ansible_testing/modules.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ansible_testing/modules.py b/ansible_testing/modules.py index 69737449757..f16a9f53466 100644 --- a/ansible_testing/modules.py +++ b/ansible_testing/modules.py @@ -3,6 +3,7 @@ from __future__ import print_function import os +import re import abc import ast import sys @@ -15,6 +16,7 @@ from ansible.utils.module_docs import get_docstring, BLACKLIST_MODULES BLACKLIST_DIRS = frozenset(('.git',)) +INDENT_REGEX = re.compile(r'(^[ \t]*)', flags=re.M) class Validator(object): @@ -144,6 +146,13 @@ class ModuleValidator(Validator): 'version 3' not in self.text): 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 + def _find_json_import(self): for child in self.ast.body: if isinstance(child, ast.Import): @@ -294,6 +303,7 @@ class ModuleValidator(Validator): main = self._find_main_call() self._find_module_utils(main) self._find_has_import() + self._check_for_tabs() if self._powershell_module(): self._find_ps_replacers()