Diff
Modified: trunk/Tools/ChangeLog (277611 => 277612)
--- trunk/Tools/ChangeLog 2021-05-17 23:03:34 UTC (rev 277611)
+++ trunk/Tools/ChangeLog 2021-05-17 23:12:42 UTC (rev 277612)
@@ -1,3 +1,22 @@
+2021-05-17 Aakash Jain <aakash_j...@apple.com>
+
+ Style checker should check for non-inclusive terminology
+ https://bugs.webkit.org/show_bug.cgi?id=213088
+
+ Reviewed by Jonathan Bedard.
+
+ Style checker should check for non-inclusive terminology so that we can avoid unintentional addition
+ of non-inclusive terminology in our codebase.
+ * Scripts/webkitpy/style/checkers/inclusive_language.py: Added inclusive language checker.
+ (InclusiveLanguageChecker):
+ (InclusiveLanguageChecker.check):
+ * Scripts/webkitpy/style/checkers/changelog.py: Check for inclusive language.
+ * Scripts/webkitpy/style/checkers/cpp.py: Ditto.
+ * Scripts/webkitpy/style/checkers/js.py: Ditto.
+ * Scripts/webkitpy/style/checkers/python.py: Ditto.
+ * Scripts/webkitpy/style/checkers/text.py: Ditto.
+ * Scripts/report-non-inclusive-language: Ignore the newly added inclusive_language.py file.
+
2021-05-17 Alex Christensen <achristen...@webkit.org>
Fix clean build after r277606
Modified: trunk/Tools/Scripts/report-non-inclusive-language (277611 => 277612)
--- trunk/Tools/Scripts/report-non-inclusive-language 2021-05-17 23:03:34 UTC (rev 277611)
+++ trunk/Tools/Scripts/report-non-inclusive-language 2021-05-17 23:12:42 UTC (rev 277612)
@@ -44,7 +44,7 @@
IGNORE_DIRECTORIES = ['.svn', '.git', 'autoinstalled', 'buildstream', 'node_modules']
IGNORE_FILES_STARTING_WITH = ('ChangeLog')
IGNORE_FILES_ENDING_WITH = ('.log', '.order', '.pyc', '.swp', '.xcuserstate', '.db', '.db-shm', '.db-wal')
-IGNORE_FILE_NAMES = ['report-non-inclusive-language']
+IGNORE_FILE_NAMES = ['report-non-inclusive-language', 'inclusive_language.py']
parser = argparse.ArgumentParser(description='Report counts and locations of non-inclusive terms.')
parser.add_argument('--verbose', '-v', action='');
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/changelog.py (277611 => 277612)
--- trunk/Tools/Scripts/webkitpy/style/checkers/changelog.py 2021-05-17 23:03:34 UTC (rev 277611)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/changelog.py 2021-05-17 23:12:42 UTC (rev 277612)
@@ -26,6 +26,7 @@
from sys import maxsize
from webkitpy.common.checkout.changelog import parse_bug_id_from_changelog
from webkitpy.style.checkers.common import TabChecker, match, search, searchIgnorecase
+from webkitpy.style.checkers.inclusive_language import InclusiveLanguageChecker
class ChangeLogChecker(object):
@@ -38,6 +39,7 @@
self.handle_style_error = handle_style_error
self.should_line_be_checked = should_line_be_checked
self._tab_checker = TabChecker(file_path, handle_style_error)
+ self._inclusive_language_checker = InclusiveLanguageChecker(handle_style_error)
def check_entry(self, first_line_checked, entry_lines):
if not entry_lines:
@@ -79,6 +81,7 @@
def check(self, lines):
self._tab_checker.check(lines)
+ self._inclusive_language_checker.check(lines)
first_line_checked = 0
entry_lines = []
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (277611 => 277612)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2021-05-17 23:03:34 UTC (rev 277611)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2021-05-17 23:12:42 UTC (rev 277612)
@@ -48,6 +48,7 @@
from webkitcorepy import unicode, Version
from webkitpy.style.checkers.common import match, search, sub, subn
+from webkitpy.style.checkers.inclusive_language import InclusiveLanguageChecker
from webkitpy.common.memoized import memoized
from webkitpy.common.version_name_map import VersionNameMap
@@ -4701,6 +4702,7 @@
self.file_path = file_path
self.handle_style_error = handle_style_error
self.min_confidence = min_confidence
+ self._inclusive_language_checker = InclusiveLanguageChecker(handle_style_error)
_unit_test_config = unit_test_config
# Useful for unit testing.
@@ -4727,3 +4729,4 @@
return
_process_lines(self.file_path, self.file_extension, lines,
self.handle_style_error, self.min_confidence)
+ self._inclusive_language_checker.check(lines)
Added: trunk/Tools/Scripts/webkitpy/style/checkers/inclusive_language.py (0 => 277612)
--- trunk/Tools/Scripts/webkitpy/style/checkers/inclusive_language.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/inclusive_language.py 2021-05-17 23:12:42 UTC (rev 277612)
@@ -0,0 +1,37 @@
+# Copyright (C) 2021 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+class InclusiveLanguageChecker(object):
+ """Supports checking for inclusive language."""
+
+ NON_INCLUSIVE_TERMS = ['whitelist', 'blacklist', 'slave']
+
+ def __init__(self, handle_style_error):
+ self.handle_style_error = handle_style_error
+
+ def check(self, lines):
+ for line_number, line in enumerate(lines):
+ for non_inclusive_term in self.NON_INCLUSIVE_TERMS:
+ if non_inclusive_term in line.lower():
+ self.handle_style_error(line_number + 1, 'non-inclusive-term', 1,
+ 'Line contains non-inclusive term: {}'.format(non_inclusive_term))
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/js.py (277611 => 277612)
--- trunk/Tools/Scripts/webkitpy/style/checkers/js.py 2021-05-17 23:03:34 UTC (rev 277611)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/js.py 2021-05-17 23:12:42 UTC (rev 277612)
@@ -32,6 +32,7 @@
import re
from webkitpy.style.checkers.common import TabChecker
+from webkitpy.style.checkers.inclusive_language import InclusiveLanguageChecker
class JSChecker(object):
@@ -44,10 +45,12 @@
self._handle_style_error = handle_style_error
self._tab_checker = TabChecker(file_path, handle_style_error)
self._single_quote_checker = SingleQuoteChecker(file_path, handle_style_error)
+ self._inclusive_language_checker = InclusiveLanguageChecker(handle_style_error)
def check(self, lines):
self._tab_checker.check(lines)
self._single_quote_checker.check(lines)
+ self._inclusive_language_checker.check(lines)
class SingleQuoteChecker(object):
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/python.py (277611 => 277612)
--- trunk/Tools/Scripts/webkitpy/style/checkers/python.py 2021-05-17 23:03:34 UTC (rev 277611)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/python.py 2021-05-17 23:12:42 UTC (rev 277612)
@@ -30,6 +30,7 @@
from webkitpy.common.system.filesystem import FileSystem
from webkitpy.common.webkit_finder import WebKitFinder
+from webkitpy.style.checkers.inclusive_language import InclusiveLanguageChecker
import pycodestyle
@@ -40,6 +41,7 @@
def __init__(self, file_path, handle_style_error):
self._file_path = file_path
self._handle_style_error = handle_style_error
+ self._inclusive_language_checker = InclusiveLanguageChecker(handle_style_error)
def check(self, lines):
self._check_pycodestyle(lines)
@@ -47,6 +49,7 @@
# Pylint can't live happily in python 2 and 3 world, we need to pick one
if sys.version_info < (3, 0):
self._check_pylint(lines)
+ self._inclusive_language_checker.check(lines)
def _check_pycodestyle(self, lines):
# Initialize pycodestyle.options, which is necessary for
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/text.py (277611 => 277612)
--- trunk/Tools/Scripts/webkitpy/style/checkers/text.py 2021-05-17 23:03:34 UTC (rev 277611)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/text.py 2021-05-17 23:12:42 UTC (rev 277612)
@@ -30,6 +30,7 @@
"""Checks WebKit style for text files."""
from webkitpy.style.checkers.common import TabChecker
+from webkitpy.style.checkers.inclusive_language import InclusiveLanguageChecker
class TextChecker(object):
@@ -40,6 +41,8 @@
self.file_path = file_path
self.handle_style_error = handle_style_error
self._tab_checker = TabChecker(file_path, handle_style_error)
+ self._inclusive_language_checker = InclusiveLanguageChecker(handle_style_error)
def check(self, lines):
self._tab_checker.check(lines)
+ self._inclusive_language_checker.check(lines)