Inclusive language in PRESUBMIT.py.
Bug: webrtc:11680 Change-Id: I6eb1f34580174cc8b043bc0811edf2d68f28f26b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178387 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31592}
This commit is contained in:

committed by
Commit Bot

parent
f79bfc65e5
commit
fc17a788fe
53
PRESUBMIT.py
53
PRESUBMIT.py
@ -14,7 +14,7 @@ from collections import defaultdict
|
|||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
# Files and directories that are *skipped* by cpplint in the presubmit script.
|
# Files and directories that are *skipped* by cpplint in the presubmit script.
|
||||||
CPPLINT_BLACKLIST = [
|
CPPLINT_EXCEPTIONS = [
|
||||||
'api/video_codecs/video_decoder.h',
|
'api/video_codecs/video_decoder.h',
|
||||||
'common_types.cc',
|
'common_types.cc',
|
||||||
'common_types.h',
|
'common_types.h',
|
||||||
@ -45,13 +45,13 @@ CPPLINT_BLACKLIST = [
|
|||||||
#
|
#
|
||||||
# Justifications for each filter:
|
# Justifications for each filter:
|
||||||
# - build/c++11 : Rvalue ref checks are unreliable (false positives),
|
# - build/c++11 : Rvalue ref checks are unreliable (false positives),
|
||||||
# include file and feature blacklists are
|
# include file and feature blocklists are
|
||||||
# google3-specific.
|
# google3-specific.
|
||||||
# - runtime/references : Mutable references are not banned by the Google
|
# - runtime/references : Mutable references are not banned by the Google
|
||||||
# C++ style guide anymore (starting from May 2020).
|
# C++ style guide anymore (starting from May 2020).
|
||||||
# - whitespace/operators: Same as above (doesn't seem sufficient to eliminate
|
# - whitespace/operators: Same as above (doesn't seem sufficient to eliminate
|
||||||
# all move-related errors).
|
# all move-related errors).
|
||||||
BLACKLIST_LINT_FILTERS = [
|
DISABLED_LINT_FILTERS = [
|
||||||
'-build/c++11',
|
'-build/c++11',
|
||||||
'-runtime/references',
|
'-runtime/references',
|
||||||
'-whitespace/operators',
|
'-whitespace/operators',
|
||||||
@ -176,7 +176,7 @@ def CheckNativeApiHeaderChanges(input_api, output_api):
|
|||||||
"""Checks to remind proper changing of native APIs."""
|
"""Checks to remind proper changing of native APIs."""
|
||||||
files = []
|
files = []
|
||||||
source_file_filter = lambda x: input_api.FilterSourceFile(
|
source_file_filter = lambda x: input_api.FilterSourceFile(
|
||||||
x, white_list=[r'.+\.(gn|gni|h)$'])
|
x, allow_list=[r'.+\.(gn|gni|h)$'])
|
||||||
for f in input_api.AffectedSourceFiles(source_file_filter):
|
for f in input_api.AffectedSourceFiles(source_file_filter):
|
||||||
for path in API_DIRS:
|
for path in API_DIRS:
|
||||||
dn = os.path.dirname(f.LocalPath())
|
dn = os.path.dirname(f.LocalPath())
|
||||||
@ -262,9 +262,9 @@ def CheckNoFRIEND_TEST(input_api, output_api, # pylint: disable=invalid-name
|
|||||||
'use FRIEND_TEST_ALL_PREFIXES() instead.\n' + '\n'.join(problems))]
|
'use FRIEND_TEST_ALL_PREFIXES() instead.\n' + '\n'.join(problems))]
|
||||||
|
|
||||||
|
|
||||||
def IsLintBlacklisted(blacklist_paths, file_path):
|
def IsLintDisabled(disabled_paths, file_path):
|
||||||
""" Checks if a file is blacklisted for lint check."""
|
""" Checks if a file is disabled for lint check."""
|
||||||
for path in blacklist_paths:
|
for path in disabled_paths:
|
||||||
if file_path == path or os.path.dirname(file_path).startswith(path):
|
if file_path == path or os.path.dirname(file_path).startswith(path):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -272,7 +272,7 @@ def IsLintBlacklisted(blacklist_paths, file_path):
|
|||||||
|
|
||||||
def CheckApprovedFilesLintClean(input_api, output_api,
|
def CheckApprovedFilesLintClean(input_api, output_api,
|
||||||
source_file_filter=None):
|
source_file_filter=None):
|
||||||
"""Checks that all new or non-blacklisted .cc and .h files pass cpplint.py.
|
"""Checks that all new or non-exempt .cc and .h files pass cpplint.py.
|
||||||
This check is based on CheckChangeLintsClean in
|
This check is based on CheckChangeLintsClean in
|
||||||
depot_tools/presubmit_canned_checks.py but has less filters and only checks
|
depot_tools/presubmit_canned_checks.py but has less filters and only checks
|
||||||
added files."""
|
added files."""
|
||||||
@ -285,22 +285,22 @@ def CheckApprovedFilesLintClean(input_api, output_api,
|
|||||||
cpplint._cpplint_state.ResetErrorCounts()
|
cpplint._cpplint_state.ResetErrorCounts()
|
||||||
|
|
||||||
lint_filters = cpplint._Filters()
|
lint_filters = cpplint._Filters()
|
||||||
lint_filters.extend(BLACKLIST_LINT_FILTERS)
|
lint_filters.extend(DISABLED_LINT_FILTERS)
|
||||||
cpplint._SetFilters(','.join(lint_filters))
|
cpplint._SetFilters(','.join(lint_filters))
|
||||||
|
|
||||||
# Create a platform independent blacklist for cpplint.
|
# Create a platform independent exempt list for cpplint.
|
||||||
blacklist_paths = [input_api.os_path.join(*path.split('/'))
|
disabled_paths = [input_api.os_path.join(*path.split('/'))
|
||||||
for path in CPPLINT_BLACKLIST]
|
for path in CPPLINT_EXCEPTIONS]
|
||||||
|
|
||||||
# Use the strictest verbosity level for cpplint.py (level 1) which is the
|
# Use the strictest verbosity level for cpplint.py (level 1) which is the
|
||||||
# default when running cpplint.py from command line. To make it possible to
|
# default when running cpplint.py from command line. To make it possible to
|
||||||
# work with not-yet-converted code, we're only applying it to new (or
|
# work with not-yet-converted code, we're only applying it to new (or
|
||||||
# moved/renamed) files and files not listed in CPPLINT_BLACKLIST.
|
# moved/renamed) files and files not listed in CPPLINT_EXCEPTIONS.
|
||||||
verbosity_level = 1
|
verbosity_level = 1
|
||||||
files = []
|
files = []
|
||||||
for f in input_api.AffectedSourceFiles(source_file_filter):
|
for f in input_api.AffectedSourceFiles(source_file_filter):
|
||||||
# Note that moved/renamed files also count as added.
|
# Note that moved/renamed files also count as added.
|
||||||
if f.Action() == 'A' or not IsLintBlacklisted(blacklist_paths,
|
if f.Action() == 'A' or not IsLintDisabled(disabled_paths,
|
||||||
f.LocalPath()):
|
f.LocalPath()):
|
||||||
files.append(f.AbsoluteLocalPath())
|
files.append(f.AbsoluteLocalPath())
|
||||||
|
|
||||||
@ -605,8 +605,8 @@ def CheckCheckIncludesIsNotUsed(gn_files, input_api, output_api):
|
|||||||
|
|
||||||
def CheckGnChanges(input_api, output_api):
|
def CheckGnChanges(input_api, output_api):
|
||||||
file_filter = lambda x: (input_api.FilterSourceFile(
|
file_filter = lambda x: (input_api.FilterSourceFile(
|
||||||
x, white_list=(r'.+\.(gn|gni)$',),
|
x, allow_list=(r'.+\.(gn|gni)$',),
|
||||||
black_list=(r'.*/presubmit_checks_lib/testdata/.*',)))
|
block_list=(r'.*/presubmit_checks_lib/testdata/.*',)))
|
||||||
|
|
||||||
gn_files = []
|
gn_files = []
|
||||||
for f in input_api.AffectedSourceFiles(file_filter):
|
for f in input_api.AffectedSourceFiles(file_filter):
|
||||||
@ -796,7 +796,7 @@ def RunPythonTests(input_api, output_api):
|
|||||||
input_api,
|
input_api,
|
||||||
output_api,
|
output_api,
|
||||||
directory,
|
directory,
|
||||||
whitelist=[r'.+_test\.py$']))
|
allowlist=[r'.+_test\.py$']))
|
||||||
return input_api.RunTests(tests, parallel=True)
|
return input_api.RunTests(tests, parallel=True)
|
||||||
|
|
||||||
|
|
||||||
@ -850,17 +850,18 @@ def CommonChecks(input_api, output_api):
|
|||||||
results = []
|
results = []
|
||||||
# Filter out files that are in objc or ios dirs from being cpplint-ed since
|
# Filter out files that are in objc or ios dirs from being cpplint-ed since
|
||||||
# they do not follow C++ lint rules.
|
# they do not follow C++ lint rules.
|
||||||
black_list = input_api.DEFAULT_BLACK_LIST + (
|
exception_list = input_api.DEFAULT_BLACK_LIST + (
|
||||||
r".*\bobjc[\\\/].*",
|
r".*\bobjc[\\\/].*",
|
||||||
r".*objc\.[hcm]+$",
|
r".*objc\.[hcm]+$",
|
||||||
)
|
)
|
||||||
source_file_filter = lambda x: input_api.FilterSourceFile(x, None, black_list)
|
source_file_filter = lambda x: input_api.FilterSourceFile(x, None,
|
||||||
|
exception_list)
|
||||||
results.extend(CheckApprovedFilesLintClean(
|
results.extend(CheckApprovedFilesLintClean(
|
||||||
input_api, output_api, source_file_filter))
|
input_api, output_api, source_file_filter))
|
||||||
results.extend(input_api.canned_checks.CheckLicense(
|
results.extend(input_api.canned_checks.CheckLicense(
|
||||||
input_api, output_api, _LicenseHeader(input_api)))
|
input_api, output_api, _LicenseHeader(input_api)))
|
||||||
results.extend(input_api.canned_checks.RunPylint(input_api, output_api,
|
results.extend(input_api.canned_checks.RunPylint(input_api, output_api,
|
||||||
black_list=(r'^base[\\\/].*\.py$',
|
block_list=(r'^base[\\\/].*\.py$',
|
||||||
r'^build[\\\/].*\.py$',
|
r'^build[\\\/].*\.py$',
|
||||||
r'^buildtools[\\\/].*\.py$',
|
r'^buildtools[\\\/].*\.py$',
|
||||||
r'^infra[\\\/].*\.py$',
|
r'^infra[\\\/].*\.py$',
|
||||||
@ -887,12 +888,12 @@ def CommonChecks(input_api, output_api):
|
|||||||
# Also we will skip most checks for third_party directory.
|
# Also we will skip most checks for third_party directory.
|
||||||
third_party_filter_list = (r'^third_party[\\\/].+',)
|
third_party_filter_list = (r'^third_party[\\\/].+',)
|
||||||
eighty_char_sources = lambda x: input_api.FilterSourceFile(x,
|
eighty_char_sources = lambda x: input_api.FilterSourceFile(x,
|
||||||
black_list=build_file_filter_list + objc_filter_list +
|
block_list=build_file_filter_list + objc_filter_list +
|
||||||
third_party_filter_list)
|
third_party_filter_list)
|
||||||
hundred_char_sources = lambda x: input_api.FilterSourceFile(x,
|
hundred_char_sources = lambda x: input_api.FilterSourceFile(x,
|
||||||
white_list=objc_filter_list)
|
allow_list=objc_filter_list)
|
||||||
non_third_party_sources = lambda x: input_api.FilterSourceFile(x,
|
non_third_party_sources = lambda x: input_api.FilterSourceFile(x,
|
||||||
black_list=third_party_filter_list)
|
block_list=third_party_filter_list)
|
||||||
|
|
||||||
results.extend(input_api.canned_checks.CheckLongLines(
|
results.extend(input_api.canned_checks.CheckLongLines(
|
||||||
input_api, output_api, maxlen=80, source_file_filter=eighty_char_sources))
|
input_api, output_api, maxlen=80, source_file_filter=eighty_char_sources))
|
||||||
@ -1073,7 +1074,7 @@ def CheckOrphanHeaders(input_api, output_api, source_file_filter):
|
|||||||
# eval-ed and thus doesn't have __file__.
|
# eval-ed and thus doesn't have __file__.
|
||||||
error_msg = """{} should be listed in {}."""
|
error_msg = """{} should be listed in {}."""
|
||||||
results = []
|
results = []
|
||||||
orphan_blacklist = [
|
exempt_paths = [
|
||||||
os.path.join('tools_webrtc', 'ios', 'SDK'),
|
os.path.join('tools_webrtc', 'ios', 'SDK'),
|
||||||
]
|
]
|
||||||
with _AddToPath(input_api.os_path.join(
|
with _AddToPath(input_api.os_path.join(
|
||||||
@ -1082,7 +1083,7 @@ def CheckOrphanHeaders(input_api, output_api, source_file_filter):
|
|||||||
from check_orphan_headers import IsHeaderInBuildGn
|
from check_orphan_headers import IsHeaderInBuildGn
|
||||||
|
|
||||||
file_filter = lambda x: input_api.FilterSourceFile(
|
file_filter = lambda x: input_api.FilterSourceFile(
|
||||||
x, black_list=orphan_blacklist) and source_file_filter(x)
|
x, block_list=exempt_paths) and source_file_filter(x)
|
||||||
for f in input_api.AffectedSourceFiles(file_filter):
|
for f in input_api.AffectedSourceFiles(file_filter):
|
||||||
if f.LocalPath().endswith('.h'):
|
if f.LocalPath().endswith('.h'):
|
||||||
file_path = os.path.abspath(f.LocalPath())
|
file_path = os.path.abspath(f.LocalPath())
|
||||||
@ -1101,7 +1102,7 @@ def CheckNewlineAtTheEndOfProtoFiles(input_api, output_api, source_file_filter):
|
|||||||
error_msg = 'File {} must end with exactly one newline.'
|
error_msg = 'File {} must end with exactly one newline.'
|
||||||
results = []
|
results = []
|
||||||
file_filter = lambda x: input_api.FilterSourceFile(
|
file_filter = lambda x: input_api.FilterSourceFile(
|
||||||
x, white_list=(r'.+\.proto$',)) and source_file_filter(x)
|
x, allow_list=(r'.+\.proto$',)) and source_file_filter(x)
|
||||||
for f in input_api.AffectedSourceFiles(file_filter):
|
for f in input_api.AffectedSourceFiles(file_filter):
|
||||||
file_path = f.LocalPath()
|
file_path = f.LocalPath()
|
||||||
with open(file_path) as f:
|
with open(file_path) as f:
|
||||||
|
Reference in New Issue
Block a user