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

Check for sys.exit. Fixes #5

This commit is contained in:
Matt Martz 2015-05-19 11:25:11 -05:00 committed by John Barker
parent 823e3c72d3
commit 4c8c0b035f

View file

@ -111,6 +111,10 @@ class ModuleValidator(Validator):
if not self.text.startswith('#!/usr/bin/python'):
self.errors.append('Interpreter line is not "#!/usr/bin/python"')
def _check_for_sys_exit(self):
if 'sys.exit(' in self.text:
self.errors.append('sys.exit() call found')
def _find_json_import(self):
for child in self.ast.body:
if isinstance(child, ast.Import):
@ -230,6 +234,7 @@ class ModuleValidator(Validator):
if not self._just_docs():
self._check_interpreter()
self._check_for_sys_exit()
self._find_json_import()
module_utils = self._find_module_utils()
main = self._find_main_call()