Complete updates of remaining code-smell tests. (#37743)

* Add text/binary file support to code smell tests.
* Enhance line-endings code smell test.
* Enhance no-smart-quotes code-smell test.
* Enhance shebang code-smell test.
This commit is contained in:
Matt Clay 2018-03-21 12:02:06 -07:00 committed by GitHub
parent 7c311ad615
commit 05220d693d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 157 additions and 63 deletions

View file

@ -17,6 +17,7 @@ from lib.util import (
load_plugins,
parse_to_dict,
ABC,
is_binary_file,
)
from lib.ansible_util import (
@ -240,6 +241,7 @@ class SanityCodeSmellTest(SanityTest):
prefixes = config.get('prefixes')
files = config.get('files')
always = config.get('always')
text = config.get('text')
if output == 'path-line-column-message':
pattern = '^(?P<path>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+): (?P<message>.*)$'
@ -257,6 +259,12 @@ class SanityCodeSmellTest(SanityTest):
if sys.version_info[0] == 2:
paths = [p.decode('utf-8') for p in paths]
if text is not None:
if text:
paths = [p for p in paths if not is_binary_file(p)]
else:
paths = [p for p in paths if is_binary_file(p)]
if extensions:
paths = [p for p in paths if os.path.splitext(p)[1] in extensions or (p.startswith('bin/') and '.py' in extensions)]