Skip to content

Commit

Permalink
Use more inclusive terms in lint script. (KhronosGroup#3123)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenrussell authored Jul 24, 2020
1 parent 3610875 commit 803227b
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 58 deletions.
26 changes: 13 additions & 13 deletions conformance-suites/2.0.0/py/lint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WebGL/sdk/tests working directory like this:
You can use the lint tool to check submitted pull request and fix the errors reported by the tool.
Reviewers will not merge branches with tests that have lint errors, so you must either
[fix all lint errors](#fixing-lint-errors) or update
[white-list test files] (#updating-the-whitelist) to suppress the errors.
[allow-list test files] (#updating-the-allowlist) to suppress the errors.

## Usage of lint tool

Expand All @@ -46,7 +46,7 @@ WebGL/sdk/tests:</br>
You must fix any errors the lint tool reports, unless an error is for
something essential to a certain test or that for some other exceptional
reason shouldn't prevent the test from being merged. In those cases you can
update [white-list test files](#updating-the-whiteslist) to suppress the errors.
update [allow-list test files](#updating-the-allowlist) to suppress the errors.
Otherwise, use the details in this section to fix all errors reported.

* **CR AT EOL**: Test-file line ends with CR (U+000D) character; **fix**:
Expand All @@ -65,32 +65,32 @@ Otherwise, use the details in this section to fix all errors reported.
* **FILENAME WHITESPACE**: Test file name contains white space; **fix**:
remove white space from test file name.

## Updating the whitelist
## Updating the allowlist

Normally you must [fix all lint errors](#fixing-lint-errors). But in the
unusual case of error reports for things essential to certain tests or that
for other exceptional reasons shouldn't prevent a merge of a test, you can
update and commit the `lint.whitelist` file in the WebGL/sdk/tests/py/lint/
update and commit the `lint.allowlist` file in the WebGL/sdk/tests/py/lint/
directory to suppress errors the lint tool would report for a test file.

To add a test file or directory to the whitelist, use the following format:
To add a test file or directory to the allowlist, use the following format:

```
ERROR TYPE:file/name/pattern
```

For example, to whitelist the file `example/file.html` such that all
For example, to allowlist the file `example/file.html` such that all
`TRAILING WHITESPACE` errors the lint tool would report for it are
suppressed, add the following line to the `lint.whitelist` file.
suppressed, add the following line to the `lint.allowlist` file.

```
TRAILING WHITESPACE:example/file.html
```

To whitelist an entire directory rather than just one file, use the `*`
wildcard. For example, to whitelist the `example` directory such that all
To allowlist an entire directory rather than just one file, use the `*`
wildcard. For example, to allowlist the `example` directory such that all
`TRAILING WHITESPACE` errors the lint tool would report for any files in it
are suppressed, add the following line to the `lint.whitelist` file.
are suppressed, add the following line to the `lint.allowlist` file.

```
TRAILING WHITESPACE:example/*
Expand All @@ -100,15 +100,15 @@ If needed, you can also use the `*` wildcard to express other filename
patterns or directory-name patterns (just as you would when, e.g.,
executing shell commands from the command line).

Finally, to whitelist just one line in a file, use the following format:
Finally, to allowlist just one line in a file, use the following format:

```
ERROR TYPE:file/name/pattern:line_number
```

For example, to whitelist just line 128 of the file `example/file.html`
For example, to allowlist just line 128 of the file `example/file.html`
such that any `TRAILING WHITESPACE` error the lint tool would report for
that line is suppressed, add the following to the `lint.whitelist` file.
that line is suppressed, add the following to the `lint.allowlist` file.

```
TRAILING WHITESPACE:example/file.html:128
Expand Down
32 changes: 16 additions & 16 deletions conformance-suites/2.0.0/py/lint/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def check_permission(path):
return []


def parse_whitelist_file(filename):
def parse_allowlist_file(filename):
data = defaultdict(lambda:defaultdict(set))

with open(filename) as f:
Expand All @@ -80,29 +80,29 @@ def parse_whitelist_file(filename):
data[file_match][error_type].add(line_number)

def inner(path, errors):
whitelisted = [False for item in xrange(len(errors))]
allowlisted = [False for item in xrange(len(errors))]

for file_match, whitelist_errors in data.iteritems():
for file_match, allowlist_errors in data.iteritems():
if fnmatch.fnmatch(path, file_match):
for i, (error_type, msg, line) in enumerate(errors):
if "*" in whitelist_errors:
whitelisted[i] = True
elif error_type in whitelist_errors:
allowed_lines = whitelist_errors[error_type]
if "*" in allowlist_errors:
allowlisted[i] = True
elif error_type in allowlist_errors:
allowed_lines = allowlist_errors[error_type]
if None in allowed_lines or line in allowed_lines:
whitelisted[i] = True
allowlisted[i] = True

return [item for i, item in enumerate(errors) if not whitelisted[i]]
return [item for i, item in enumerate(errors) if not allowlisted[i]]
return inner


_whitelist_fn = None
def whitelist_errors(path, errors):
global _whitelist_fn
_allowlist_fn = None
def allowlist_errors(path, errors):
global _allowlist_fn

if _whitelist_fn is None:
_whitelist_fn = parse_whitelist_file(os.path.join(lint_root, "lint.whitelist"))
return _whitelist_fn(path, errors)
if _allowlist_fn is None:
_allowlist_fn = parse_allowlist_file(os.path.join(lint_root, "lint.allowlist"))
return _allowlist_fn(path, errors)


class Regexp(object):
Expand Down Expand Up @@ -189,7 +189,7 @@ def main():
repo_root = repo_root.replace("WebGL/sdk/tests", options.repo)

def run_lint(path, fn, *args):
errors = whitelist_errors(path, fn(path, *args))
errors = allowlist_errors(path, fn(path, *args))
output_errors(errors)
for error_type, error, line in errors:
error_count[error_type] += 1
Expand Down
26 changes: 13 additions & 13 deletions sdk/tests/py/lint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WebGL/sdk/tests working directory like this:
You can use the lint tool to check submitted pull request and fix the errors reported by the tool.
Reviewers will not merge branches with tests that have lint errors, so you must either
[fix all lint errors](#fixing-lint-errors) or update
[white-list test files] (#updating-the-whitelist) to suppress the errors.
[allow-list test files] (#updating-the-allowlist) to suppress the errors.

## Usage of lint tool

Expand All @@ -46,7 +46,7 @@ WebGL/sdk/tests:</br>
You must fix any errors the lint tool reports, unless an error is for
something essential to a certain test or that for some other exceptional
reason shouldn't prevent the test from being merged. In those cases you can
update [white-list test files](#updating-the-whiteslist) to suppress the errors.
update [allow-list test files](#updating-the-allowlist) to suppress the errors.
Otherwise, use the details in this section to fix all errors reported.

* **CR AT EOL**: Test-file line ends with CR (U+000D) character; **fix**:
Expand All @@ -65,32 +65,32 @@ Otherwise, use the details in this section to fix all errors reported.
* **FILENAME WHITESPACE**: Test file name contains white space; **fix**:
remove white space from test file name.

## Updating the whitelist
## Updating the allowlist

Normally you must [fix all lint errors](#fixing-lint-errors). But in the
unusual case of error reports for things essential to certain tests or that
for other exceptional reasons shouldn't prevent a merge of a test, you can
update and commit the `lint.whitelist` file in the WebGL/sdk/tests/py/lint/
update and commit the `lint.allowlist` file in the WebGL/sdk/tests/py/lint/
directory to suppress errors the lint tool would report for a test file.

To add a test file or directory to the whitelist, use the following format:
To add a test file or directory to the allowlist, use the following format:

```
ERROR TYPE:file/name/pattern
```

For example, to whitelist the file `example/file.html` such that all
For example, to allowlist the file `example/file.html` such that all
`TRAILING WHITESPACE` errors the lint tool would report for it are
suppressed, add the following line to the `lint.whitelist` file.
suppressed, add the following line to the `lint.allowlist` file.

```
TRAILING WHITESPACE:example/file.html
```

To whitelist an entire directory rather than just one file, use the `*`
wildcard. For example, to whitelist the `example` directory such that all
To allowlist an entire directory rather than just one file, use the `*`
wildcard. For example, to allowlist the `example` directory such that all
`TRAILING WHITESPACE` errors the lint tool would report for any files in it
are suppressed, add the following line to the `lint.whitelist` file.
are suppressed, add the following line to the `lint.allowlist` file.

```
TRAILING WHITESPACE:example/*
Expand All @@ -100,15 +100,15 @@ If needed, you can also use the `*` wildcard to express other filename
patterns or directory-name patterns (just as you would when, e.g.,
executing shell commands from the command line).

Finally, to whitelist just one line in a file, use the following format:
Finally, to allowlist just one line in a file, use the following format:

```
ERROR TYPE:file/name/pattern:line_number
```

For example, to whitelist just line 128 of the file `example/file.html`
For example, to allowlist just line 128 of the file `example/file.html`
such that any `TRAILING WHITESPACE` error the lint tool would report for
that line is suppressed, add the following to the `lint.whitelist` file.
that line is suppressed, add the following to the `lint.allowlist` file.

```
TRAILING WHITESPACE:example/file.html:128
Expand Down
File renamed without changes.
32 changes: 16 additions & 16 deletions sdk/tests/py/lint/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def check_permission(path):
return []


def parse_whitelist_file(filename):
def parse_allowlist_file(filename):
data = defaultdict(lambda:defaultdict(set))

with open(filename) as f:
Expand All @@ -79,29 +79,29 @@ def parse_whitelist_file(filename):
data[file_match][error_type].add(line_number)

def inner(path, errors):
whitelisted = [False for item in range(len(errors))]
allowlisted = [False for item in range(len(errors))]

for file_match, whitelist_errors in data.items():
for file_match, allowlist_errors in data.items():
if fnmatch.fnmatch(path, file_match):
for i, (error_type, msg, line) in enumerate(errors):
if "*" in whitelist_errors:
whitelisted[i] = True
elif error_type in whitelist_errors:
allowed_lines = whitelist_errors[error_type]
if "*" in allowlist_errors:
allowlisted[i] = True
elif error_type in allowlist_errors:
allowed_lines = allowlist_errors[error_type]
if None in allowed_lines or line in allowed_lines:
whitelisted[i] = True
allowlisted[i] = True

return [item for i, item in enumerate(errors) if not whitelisted[i]]
return [item for i, item in enumerate(errors) if not allowlisted[i]]
return inner


_whitelist_fn = None
def whitelist_errors(path, errors):
global _whitelist_fn
_allowlist_fn = None
def allowlist_errors(path, errors):
global _allowlist_fn

if _whitelist_fn is None:
_whitelist_fn = parse_whitelist_file(os.path.join(lint_root, "lint.whitelist"))
return _whitelist_fn(path, errors)
if _allowlist_fn is None:
_allowlist_fn = parse_allowlist_file(os.path.join(lint_root, "lint.allowlist"))
return _allowlist_fn(path, errors)


class Regexp(object):
Expand Down Expand Up @@ -191,7 +191,7 @@ def main():
repo_root = repo_root.replace("WebGL/sdk/tests", options.repo)

def run_lint(path, fn, *args):
errors = whitelist_errors(path, fn(path, *args))
errors = allowlist_errors(path, fn(path, *args))
output_errors(errors)
for error_type, error, line in errors:
error_count[error_type] += 1
Expand Down

0 comments on commit 803227b

Please sign in to comment.