mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-16 01:45:25 -07:00
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:
parent
7c311ad615
commit
05220d693d
10 changed files with 157 additions and 63 deletions
|
@ -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)]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue