Add no-unwanted-characters sanity test for core (#82557)

pull/82562/head
Matt Clay 10 months ago committed by GitHub
parent 30169c76de
commit 71d81e4a60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,4 @@
{
"text": true,
"output": "path-line-column-message"
}

@ -0,0 +1,27 @@
"""Disallow use of unwanted Unicode characters."""
from __future__ import annotations
import re
import sys
def main():
"""Main entry point."""
for path in sys.argv[1:] or sys.stdin.read().splitlines():
with open(path, 'rb') as path_fd:
for line, text in enumerate(path_fd.readlines()):
try:
text = text.decode('utf-8')
except UnicodeDecodeError as ex:
print('%s:%d:%d: UnicodeDecodeError: %s' % (path, line + 1, ex.start + 1, ex))
continue
match = re.search('(\u00a0)', text)
if match:
print('%s:%d:%d: use an ASCII space instead of a Unicode no-break space' % (
path, line + 1, match.start(1) + 1))
if __name__ == '__main__':
main()

@ -114,15 +114,19 @@ test/integration/targets/incidental_win_reboot/templates/post_reboot.ps1 pslint!
test/integration/targets/json_cleanup/library/bad_json shebang
test/integration/targets/lookup_csvfile/files/crlf.csv line-endings
test/integration/targets/lookup_ini/lookup-8859-15.ini no-smart-quotes
test/integration/targets/lookup_ini/lookup-8859-15.ini no-unwanted-characters
test/integration/targets/module_precedence/lib_with_extension/a.ini shebang
test/integration/targets/module_precedence/lib_with_extension/ping.ini shebang
test/integration/targets/module_precedence/roles_with_extension/foo/library/a.ini shebang
test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.ini shebang
test/integration/targets/old_style_modules_posix/library/helloworld.sh shebang
test/integration/targets/template/files/encoding_1252_utf-8.expected no-smart-quotes
test/integration/targets/template/files/encoding_1252_utf-8.expected no-unwanted-characters
test/integration/targets/template/files/encoding_1252_windows-1252.expected no-smart-quotes
test/integration/targets/template/files/encoding_1252_windows-1252.expected no-unwanted-characters
test/integration/targets/template/files/foo.dos.txt line-endings
test/integration/targets/template/templates/encoding_1252.j2 no-smart-quotes
test/integration/targets/template/templates/encoding_1252.j2 no-unwanted-characters
test/integration/targets/unicode/unicode.yml no-smart-quotes
test/integration/targets/windows-minimal/library/win_ping_syntax_error.ps1 pslint!skip
test/integration/targets/win_exec_wrapper/library/test_fail.ps1 pslint:PSCustomUseLiteralPath

Loading…
Cancel
Save