mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Allow to keep old python style for existing files.
https://webrtc-review.googlesource.com/c/src/+/321081 made PEP-8 mandatory for WebRTC python file. This CL allows to keep the old formatting style for existing python files because switching all methods and functions name from PascalCase to snake_case is non trivial. Change-Id: Id094bbf72ee1c3c32027a49bc9763bc65dfb9ad2 Bug: None Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/323860 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Jeremy Leconte <jleconte@google.com> Reviewed-by: Christoffer Jansson <jansson@google.com> Cr-Commit-Position: refs/heads/main@{#40951}
This commit is contained in:
parent
c2994790a1
commit
3d476f2738
3 changed files with 1291 additions and 1029 deletions
|
@ -10,6 +10,7 @@ per-file .vpython3=mbonadei@webrtc.org,jansson@webrtc.org,jleconte@webrtc.org
|
|||
per-file AUTHORS=*
|
||||
per-file DEPS=*
|
||||
per-file pylintrc=mbonadei@webrtc.org,jansson@webrtc.org,jleconte@webrtc.org
|
||||
per-file pylintrc_old_style=mbonadei@webrtc.org,jansson@webrtc.org,jleconte@webrtc.org
|
||||
per-file WATCHLISTS=*
|
||||
per-file native-api.md=mbonadei@webrtc.org
|
||||
per-file ....lua=titovartem@webrtc.org
|
||||
|
|
211
PRESUBMIT.py
211
PRESUBMIT.py
|
@ -47,6 +47,10 @@ CPPLINT_EXCEPTIONS = [
|
|||
'voice_engine',
|
||||
]
|
||||
|
||||
PYLINT_OLD_STYLE = [
|
||||
"PRESUBMIT.py",
|
||||
]
|
||||
|
||||
# These filters will always be removed, even if the caller specifies a filter
|
||||
# set, as they are problematic or broken in some way.
|
||||
#
|
||||
|
@ -144,8 +148,8 @@ def VerifyNativeApiHeadersListIsValid(input_api, output_api):
|
|||
"""Ensures the list of native API header directories is up to date."""
|
||||
non_existing_paths = []
|
||||
native_api_full_paths = [
|
||||
input_api.os_path.join(input_api.PresubmitLocalPath(), *path.split('/'))
|
||||
for path in API_DIRS
|
||||
input_api.os_path.join(input_api.PresubmitLocalPath(),
|
||||
*path.split('/')) for path in API_DIRS
|
||||
]
|
||||
for path in native_api_full_paths:
|
||||
if not os.path.isdir(path):
|
||||
|
@ -207,8 +211,8 @@ def CheckNoIOStreamInHeaders(input_api, output_api, source_file_filter):
|
|||
files = []
|
||||
pattern = input_api.re.compile(r'^#include\s*<iostream>',
|
||||
input_api.re.MULTILINE)
|
||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and source_file_filter(
|
||||
x))
|
||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and
|
||||
source_file_filter(x))
|
||||
for f in input_api.AffectedSourceFiles(file_filter):
|
||||
if not f.LocalPath().endswith('.h'):
|
||||
continue
|
||||
|
@ -221,7 +225,8 @@ def CheckNoIOStreamInHeaders(input_api, output_api, source_file_filter):
|
|||
output_api.PresubmitError(
|
||||
'Do not #include <iostream> in header files, since it inserts '
|
||||
'static initialization into every file including the header. '
|
||||
'Instead, #include <ostream>. See http://crbug.com/94794', files)
|
||||
'Instead, #include <ostream>. See http://crbug.com/94794',
|
||||
files)
|
||||
]
|
||||
return []
|
||||
|
||||
|
@ -230,8 +235,8 @@ def CheckNoPragmaOnce(input_api, output_api, source_file_filter):
|
|||
"""Make sure that banned functions are not used."""
|
||||
files = []
|
||||
pattern = input_api.re.compile(r'^#pragma\s+once', input_api.re.MULTILINE)
|
||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and source_file_filter(
|
||||
x))
|
||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and
|
||||
source_file_filter(x))
|
||||
for f in input_api.AffectedSourceFiles(file_filter):
|
||||
if not f.LocalPath().endswith('.h'):
|
||||
continue
|
||||
|
@ -258,8 +263,8 @@ def CheckNoFRIEND_TEST(# pylint: disable=invalid-name
|
|||
used instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes."""
|
||||
problems = []
|
||||
|
||||
file_filter = lambda f: (f.LocalPath().endswith(('.cc', '.h')) and
|
||||
source_file_filter(f))
|
||||
file_filter = lambda f: (f.LocalPath().endswith(
|
||||
('.cc', '.h')) and source_file_filter(f))
|
||||
for f in input_api.AffectedFiles(file_filter=file_filter):
|
||||
for line_num, line in f.ChangedContents():
|
||||
if 'FRIEND_TEST(' in line:
|
||||
|
@ -314,7 +319,8 @@ def CheckApprovedFilesLintClean(input_api, output_api,
|
|||
files = []
|
||||
for f in input_api.AffectedSourceFiles(source_file_filter):
|
||||
# Note that moved/renamed files also count as added.
|
||||
if f.Action() == 'A' or not IsLintDisabled(disabled_paths, f.LocalPath()):
|
||||
if f.Action() == 'A' or not IsLintDisabled(disabled_paths,
|
||||
f.LocalPath()):
|
||||
files.append(f.AbsoluteLocalPath())
|
||||
|
||||
for file_name in files:
|
||||
|
@ -342,7 +348,8 @@ def CheckNoSourcesAbove(input_api, gn_files, output_api):
|
|||
for source_block_match in source_pattern.finditer(contents):
|
||||
# Find all source list entries starting with ../ in the source block
|
||||
# (exclude overrides entries).
|
||||
for file_list_match in file_pattern.finditer(source_block_match.group(1)):
|
||||
for file_list_match in file_pattern.finditer(
|
||||
source_block_match.group(1)):
|
||||
source_file = file_list_match.group(1)
|
||||
if 'overrides/' not in source_file:
|
||||
violating_source_entries.append(source_file)
|
||||
|
@ -387,7 +394,8 @@ def CheckAbseilDependencies(input_api, gn_files, output_api):
|
|||
for dep in deps:
|
||||
if re.search(absl_re, dep):
|
||||
errors.append(
|
||||
output_api.PresubmitError(error_msg %
|
||||
output_api.PresubmitError(
|
||||
error_msg %
|
||||
(target_name, gn_file.LocalPath())))
|
||||
break # no need to warn more than once per target
|
||||
return errors
|
||||
|
@ -398,7 +406,6 @@ def CheckNoMixingSources(input_api, gn_files, output_api):
|
|||
|
||||
See bugs.webrtc.org/7743 for more context.
|
||||
"""
|
||||
|
||||
def _MoreThanOneSourceUsed(*sources_lists):
|
||||
sources_used = 0
|
||||
for source_list in sources_lists:
|
||||
|
@ -436,7 +443,8 @@ def CheckNoMixingSources(input_api, gn_files, output_api):
|
|||
c_files = []
|
||||
cc_files = []
|
||||
objc_files = []
|
||||
for file_match in FILE_PATH_RE.finditer(sources_match.group(1)):
|
||||
for file_match in FILE_PATH_RE.finditer(
|
||||
sources_match.group(1)):
|
||||
file_path = file_match.group('file_path')
|
||||
extension = file_match.group('extension')
|
||||
if extension == '.c':
|
||||
|
@ -447,9 +455,12 @@ def CheckNoMixingSources(input_api, gn_files, output_api):
|
|||
objc_files.append(file_path + extension)
|
||||
list_of_sources.append((c_files, cc_files, objc_files))
|
||||
for c_files_list, cc_files_list, objc_files_list in list_of_sources:
|
||||
if _MoreThanOneSourceUsed(c_files_list, cc_files_list, objc_files_list):
|
||||
all_sources = sorted(c_files_list + cc_files_list + objc_files_list)
|
||||
errors[gn_file.LocalPath()].append((target_name, all_sources))
|
||||
if _MoreThanOneSourceUsed(c_files_list, cc_files_list,
|
||||
objc_files_list):
|
||||
all_sources = sorted(c_files_list + cc_files_list +
|
||||
objc_files_list)
|
||||
errors[gn_file.LocalPath()].append(
|
||||
(target_name, all_sources))
|
||||
if errors:
|
||||
return [
|
||||
output_api.PresubmitError(
|
||||
|
@ -467,9 +478,12 @@ def CheckNoMixingSources(input_api, gn_files, output_api):
|
|||
def CheckNoPackageBoundaryViolations(input_api, gn_files, output_api):
|
||||
cwd = input_api.PresubmitLocalPath()
|
||||
with _AddToPath(
|
||||
input_api.os_path.join(cwd, 'tools_webrtc', 'presubmit_checks_lib')):
|
||||
input_api.os_path.join(cwd, 'tools_webrtc',
|
||||
'presubmit_checks_lib')):
|
||||
from check_package_boundaries import CheckPackageBoundaries
|
||||
build_files = [os.path.join(cwd, gn_file.LocalPath()) for gn_file in gn_files]
|
||||
build_files = [
|
||||
os.path.join(cwd, gn_file.LocalPath()) for gn_file in gn_files
|
||||
]
|
||||
errors = CheckPackageBoundaries(cwd, build_files)[:5]
|
||||
if errors:
|
||||
return [
|
||||
|
@ -500,7 +514,8 @@ def CheckNoWarningSuppressionFlagsAreAdded(gn_files,
|
|||
'\n'
|
||||
'Affected files:\n')
|
||||
errors = [] # 2-element tuples with (file, line number)
|
||||
clang_warn_re = input_api.re.compile(r'//build/config/clang:extra_warnings')
|
||||
clang_warn_re = input_api.re.compile(
|
||||
r'//build/config/clang:extra_warnings')
|
||||
# pylint: disable-next=fixme
|
||||
no_presubmit_re = input_api.re.compile(
|
||||
r'# no-presubmit-check TODO\(bugs\.webrtc\.org/\d+\)')
|
||||
|
@ -539,7 +554,8 @@ def CheckNoStreamUsageIsAdded(input_api,
|
|||
source_file_filter,
|
||||
error_formatter=_ReportFileAndLine):
|
||||
"""Make sure that no more dependencies on stringstream are added."""
|
||||
error_msg = ('Usage of <sstream>, <istream> and <ostream> in WebRTC is '
|
||||
error_msg = (
|
||||
'Usage of <sstream>, <istream> and <ostream> in WebRTC is '
|
||||
'deprecated.\n'
|
||||
'This includes the following types:\n'
|
||||
'std::istringstream, std::ostringstream, std::wistringstream, '
|
||||
|
@ -559,18 +575,19 @@ def CheckNoStreamUsageIsAdded(input_api,
|
|||
'Affected files:\n')
|
||||
errors = [] # 2-element tuples with (file, line number)
|
||||
include_re = input_api.re.compile(r'#include <(i|o|s)stream>')
|
||||
usage_re = input_api.re.compile(r'std::(w|i|o|io|wi|wo|wio)(string)*stream')
|
||||
usage_re = input_api.re.compile(
|
||||
r'std::(w|i|o|io|wi|wo|wio)(string)*stream')
|
||||
no_presubmit_re = input_api.re.compile(
|
||||
r'// no-presubmit-check TODO\(webrtc:8982\)')
|
||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and source_file_filter(
|
||||
x))
|
||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and
|
||||
source_file_filter(x))
|
||||
|
||||
def _IsException(file_path):
|
||||
is_test = any(
|
||||
file_path.endswith(x)
|
||||
for x in ['_test.cc', '_tests.cc', '_unittest.cc', '_unittests.cc'])
|
||||
return (file_path.startswith('examples') or file_path.startswith('test')
|
||||
or is_test)
|
||||
file_path.endswith(x) for x in
|
||||
['_test.cc', '_tests.cc', '_unittest.cc', '_unittests.cc'])
|
||||
return (file_path.startswith('examples')
|
||||
or file_path.startswith('test') or is_test)
|
||||
|
||||
for f in input_api.AffectedSourceFiles(file_filter):
|
||||
# Usage of stringstream is allowed under examples/ and in tests.
|
||||
|
@ -604,13 +621,15 @@ def CheckPublicDepsIsNotUsed(gn_files, input_api, output_api):
|
|||
if not surpressed:
|
||||
result.append(
|
||||
output_api.PresubmitError(
|
||||
error_msg % (affected_file.LocalPath(), line_number)))
|
||||
error_msg %
|
||||
(affected_file.LocalPath(), line_number)))
|
||||
return result
|
||||
|
||||
|
||||
def CheckCheckIncludesIsNotUsed(gn_files, input_api, output_api):
|
||||
result = []
|
||||
error_msg = ('check_includes overrides are not allowed since it can cause '
|
||||
error_msg = (
|
||||
'check_includes overrides are not allowed since it can cause '
|
||||
'incorrect dependencies to form. It effectively means that your '
|
||||
'module can include any .h file without depending on its '
|
||||
'corresponding target. There are some exceptional cases when '
|
||||
|
@ -625,8 +644,8 @@ def CheckCheckIncludesIsNotUsed(gn_files, input_api, output_api):
|
|||
if ('check_includes' in affected_line
|
||||
and not no_presubmit_re.search(affected_line)):
|
||||
result.append(
|
||||
output_api.PresubmitError(error_msg %
|
||||
(affected_file.LocalPath(), line_number)))
|
||||
output_api.PresubmitError(
|
||||
error_msg % (affected_file.LocalPath(), line_number)))
|
||||
return result
|
||||
|
||||
|
||||
|
@ -647,10 +666,13 @@ def CheckGnChanges(input_api, output_api):
|
|||
result.extend(CheckAbseilDependencies(input_api, gn_files, output_api))
|
||||
result.extend(
|
||||
CheckNoPackageBoundaryViolations(input_api, gn_files, output_api))
|
||||
result.extend(CheckPublicDepsIsNotUsed(gn_files, input_api, output_api))
|
||||
result.extend(CheckCheckIncludesIsNotUsed(gn_files, input_api, output_api))
|
||||
result.extend(CheckPublicDepsIsNotUsed(gn_files, input_api,
|
||||
output_api))
|
||||
result.extend(
|
||||
CheckNoWarningSuppressionFlagsAreAdded(gn_files, input_api, output_api))
|
||||
CheckCheckIncludesIsNotUsed(gn_files, input_api, output_api))
|
||||
result.extend(
|
||||
CheckNoWarningSuppressionFlagsAreAdded(gn_files, input_api,
|
||||
output_api))
|
||||
return result
|
||||
|
||||
|
||||
|
@ -660,8 +682,8 @@ def CheckGnGen(input_api, output_api):
|
|||
errors.
|
||||
"""
|
||||
with _AddToPath(
|
||||
input_api.os_path.join(input_api.PresubmitLocalPath(), 'tools_webrtc',
|
||||
'presubmit_checks_lib')):
|
||||
input_api.os_path.join(input_api.PresubmitLocalPath(),
|
||||
'tools_webrtc', 'presubmit_checks_lib')):
|
||||
from build_helpers import RunGnCheck
|
||||
errors = RunGnCheck(FindSrcDirPath(input_api.PresubmitLocalPath()))[:5]
|
||||
if errors:
|
||||
|
@ -686,7 +708,8 @@ def CheckUnwantedDependencies(input_api, output_api, source_file_filter):
|
|||
# roundabout construct to import checkdeps because this file is
|
||||
# eval-ed and thus doesn't have __file__.
|
||||
src_path = FindSrcDirPath(input_api.PresubmitLocalPath())
|
||||
checkdeps_path = input_api.os_path.join(src_path, 'buildtools', 'checkdeps')
|
||||
checkdeps_path = input_api.os_path.join(src_path, 'buildtools',
|
||||
'checkdeps')
|
||||
if not os.path.exists(checkdeps_path):
|
||||
return [
|
||||
output_api.PresubmitError(
|
||||
|
@ -743,7 +766,8 @@ def CheckCommitMessageBugEntry(input_api, output_api):
|
|||
"""Check that bug entries are well-formed in commit message."""
|
||||
bogus_bug_msg = (
|
||||
'Bogus Bug entry: %s. Please specify the issue tracker prefix and the '
|
||||
'issue number, separated by a colon, e.g. webrtc:123 or chromium:12345.')
|
||||
'issue number, separated by a colon, e.g. webrtc:123 or chromium:12345.'
|
||||
)
|
||||
results = []
|
||||
for bug in input_api.change.BugsFromDescription():
|
||||
bug = bug.strip()
|
||||
|
@ -756,7 +780,8 @@ def CheckCommitMessageBugEntry(input_api, output_api):
|
|||
prefix_guess = 'chromium'
|
||||
else:
|
||||
prefix_guess = 'webrtc'
|
||||
results.append('Bug entry requires issue tracker prefix, e.g. %s:%s' %
|
||||
results.append(
|
||||
'Bug entry requires issue tracker prefix, e.g. %s:%s' %
|
||||
(prefix_guess, bug))
|
||||
except ValueError:
|
||||
results.append(bogus_bug_msg % bug)
|
||||
|
@ -789,10 +814,9 @@ def CheckChangeHasBugField(input_api, output_api):
|
|||
|
||||
def CheckJSONParseErrors(input_api, output_api, source_file_filter):
|
||||
"""Check that JSON files do not contain syntax errors."""
|
||||
|
||||
def FilterFile(affected_file):
|
||||
return (input_api.os_path.splitext(affected_file.LocalPath())[1] == '.json'
|
||||
and source_file_filter(affected_file))
|
||||
return (input_api.os_path.splitext(affected_file.LocalPath())[1]
|
||||
== '.json' and source_file_filter(affected_file))
|
||||
|
||||
def GetJSONParseError(input_api, filename):
|
||||
try:
|
||||
|
@ -809,7 +833,8 @@ def CheckJSONParseErrors(input_api, output_api, source_file_filter):
|
|||
affected_file.AbsoluteLocalPath())
|
||||
if parse_error:
|
||||
results.append(
|
||||
output_api.PresubmitError('%s could not be parsed: %s' %
|
||||
output_api.PresubmitError(
|
||||
'%s could not be parsed: %s' %
|
||||
(affected_file.LocalPath(), parse_error)))
|
||||
return results
|
||||
|
||||
|
@ -819,8 +844,8 @@ def RunPythonTests(input_api, output_api):
|
|||
return input_api.os_path.join(input_api.PresubmitLocalPath(), *args)
|
||||
|
||||
excluded_files = [
|
||||
# These tests should be run manually after webrtc_dashboard_upload target
|
||||
# has been built.
|
||||
# These tests should be run manually after webrtc_dashboard_upload
|
||||
# target has been built.
|
||||
'catapult_uploader_test.py',
|
||||
'process_perf_results_test.py',
|
||||
]
|
||||
|
@ -852,8 +877,8 @@ def CheckUsageOfGoogleProtobufNamespace(input_api, output_api,
|
|||
files = []
|
||||
pattern = input_api.re.compile(r'google::protobuf')
|
||||
proto_utils_path = os.path.join('rtc_base', 'protobuf_utils.h')
|
||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and source_file_filter(
|
||||
x))
|
||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and
|
||||
source_file_filter(x))
|
||||
for f in input_api.AffectedSourceFiles(file_filter):
|
||||
if f.LocalPath() in [proto_utils_path, 'PRESUBMIT.py']:
|
||||
continue
|
||||
|
@ -865,8 +890,8 @@ def CheckUsageOfGoogleProtobufNamespace(input_api, output_api,
|
|||
return [
|
||||
output_api.PresubmitError(
|
||||
'Please avoid to use namespace `google::protobuf` directly.\n'
|
||||
'Add a using directive in `%s` and include that header instead.' %
|
||||
proto_utils_path, files)
|
||||
'Add a using directive in `%s` and include that header instead.'
|
||||
% proto_utils_path, files)
|
||||
]
|
||||
return []
|
||||
|
||||
|
@ -919,12 +944,18 @@ def CommonChecks(input_api, output_api):
|
|||
for f in input_api.AffectedFiles(include_deletes=False,
|
||||
file_filter=python_file_filter)
|
||||
]
|
||||
|
||||
pylint_new_style = [
|
||||
f for f in python_changed_files if f not in PYLINT_OLD_STYLE
|
||||
]
|
||||
pylint_old_style = [
|
||||
f for f in python_changed_files if f in PYLINT_OLD_STYLE
|
||||
]
|
||||
if pylint_new_style:
|
||||
results.extend(
|
||||
input_api.canned_checks.RunPylint(
|
||||
input_api,
|
||||
output_api,
|
||||
files_to_check=python_changed_files,
|
||||
files_to_check=pylint_new_style,
|
||||
files_to_skip=(
|
||||
r'^base[\\\/].*\.py$',
|
||||
r'^build[\\\/].*\.py$',
|
||||
|
@ -940,11 +971,17 @@ def CommonChecks(input_api, output_api):
|
|||
pylintrc='pylintrc',
|
||||
version='2.7'))
|
||||
|
||||
# TODO(bugs.webrtc.org/13606): talk/ is no more, so make below checks simpler?
|
||||
# WebRTC can't use the presubmit_canned_checks.PanProjectChecks function
|
||||
# since we need to have different license checks
|
||||
# in talk/ and webrtc/directories.
|
||||
# Instead, hand-picked checks are included below.
|
||||
if pylint_old_style:
|
||||
results.extend(
|
||||
input_api.canned_checks.RunPylint(input_api,
|
||||
output_api,
|
||||
files_to_check=pylint_old_style,
|
||||
pylintrc='pylintrc_old_style',
|
||||
version='2.7'))
|
||||
# TODO(bugs.webrtc.org/13606): talk/ is no more, so make below checks
|
||||
# simpler. WebRTC can't use the presubmit_canned_checks.PanProjectChecks
|
||||
# function since we need to have different license checks in talk/ and
|
||||
# webrtc/directories. Instead, hand-picked checks are included below.
|
||||
|
||||
# .m and .mm files are ObjC files. For simplicity we will consider
|
||||
# .h files in ObjC subdirectories ObjC headers.
|
||||
|
@ -1027,7 +1064,8 @@ def CommonChecks(input_api, output_api):
|
|||
CheckNewlineAtTheEndOfProtoFiles(
|
||||
input_api, output_api, source_file_filter=non_third_party_sources))
|
||||
results.extend(
|
||||
CheckNoStreamUsageIsAdded(input_api, output_api, non_third_party_sources))
|
||||
CheckNoStreamUsageIsAdded(input_api, output_api,
|
||||
non_third_party_sources))
|
||||
results.extend(
|
||||
CheckNoTestCaseUsageIsAdded(input_api, output_api,
|
||||
non_third_party_sources))
|
||||
|
@ -1038,7 +1076,8 @@ def CommonChecks(input_api, output_api):
|
|||
results.extend(
|
||||
CheckAssertUsage(input_api, output_api, non_third_party_sources))
|
||||
results.extend(
|
||||
CheckBannedAbslMakeUnique(input_api, output_api, non_third_party_sources))
|
||||
CheckBannedAbslMakeUnique(input_api, output_api,
|
||||
non_third_party_sources))
|
||||
results.extend(
|
||||
CheckObjcApiSymbols(input_api, output_api, non_third_party_sources))
|
||||
return results
|
||||
|
@ -1068,7 +1107,8 @@ def CheckApiDepsFileIsUpToDate(input_api, output_api):
|
|||
path_tokens = [t for t in f.LocalPath().split(os.sep) if t]
|
||||
if len(path_tokens) > 1:
|
||||
if (path_tokens[0] not in dirs_to_skip and os.path.isdir(
|
||||
os.path.join(input_api.PresubmitLocalPath(), path_tokens[0]))):
|
||||
os.path.join(input_api.PresubmitLocalPath(),
|
||||
path_tokens[0]))):
|
||||
dirs_to_check.add(path_tokens[0])
|
||||
|
||||
missing_include_rules = set()
|
||||
|
@ -1100,8 +1140,8 @@ def CheckApiDepsFileIsUpToDate(input_api, output_api):
|
|||
|
||||
|
||||
def CheckBannedAbslMakeUnique(input_api, output_api, source_file_filter):
|
||||
file_filter = lambda f: (f.LocalPath().endswith(('.cc', '.h')) and
|
||||
source_file_filter(f))
|
||||
file_filter = lambda f: (f.LocalPath().endswith(
|
||||
('.cc', '.h')) and source_file_filter(f))
|
||||
|
||||
files = []
|
||||
for f in input_api.AffectedFiles(include_deletes=False,
|
||||
|
@ -1123,12 +1163,12 @@ def CheckBannedAbslMakeUnique(input_api, output_api, source_file_filter):
|
|||
def CheckObjcApiSymbols(input_api, output_api, source_file_filter):
|
||||
rtc_objc_export = re.compile(r'RTC_OBJC_EXPORT(.|\n){26}',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
file_filter = lambda f: (f.LocalPath().endswith(('.h')) and
|
||||
source_file_filter(f))
|
||||
file_filter = lambda f: (f.LocalPath().endswith(
|
||||
('.h')) and source_file_filter(f))
|
||||
|
||||
files = []
|
||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and source_file_filter(
|
||||
x))
|
||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and
|
||||
source_file_filter(x))
|
||||
for f in input_api.AffectedSourceFiles(file_filter):
|
||||
if not f.LocalPath().endswith('.h') or not 'sdk/objc' in f.LocalPath():
|
||||
continue
|
||||
|
@ -1143,8 +1183,8 @@ def CheckObjcApiSymbols(input_api, output_api, source_file_filter):
|
|||
if len(files) > 0:
|
||||
return [
|
||||
output_api.PresubmitError(
|
||||
'RTC_OBJC_EXPORT types must be wrapped into an RTC_OBJC_TYPE() ' +
|
||||
'macro.\n\n' + 'For example:\n' +
|
||||
'RTC_OBJC_EXPORT types must be wrapped into an RTC_OBJC_TYPE() '
|
||||
+ 'macro.\n\n' + 'For example:\n' +
|
||||
'RTC_OBJC_EXPORT @protocol RTC_OBJC_TYPE(RtcFoo)\n\n' +
|
||||
'RTC_OBJC_EXPORT @interface RTC_OBJC_TYPE(RtcFoo)\n\n' +
|
||||
'Please fix the following files:', files)
|
||||
|
@ -1154,8 +1194,8 @@ def CheckObjcApiSymbols(input_api, output_api, source_file_filter):
|
|||
|
||||
def CheckAssertUsage(input_api, output_api, source_file_filter):
|
||||
pattern = input_api.re.compile(r'\bassert\(')
|
||||
file_filter = lambda f: (f.LocalPath().endswith(('.cc', '.h', '.m', '.mm'))
|
||||
and source_file_filter(f))
|
||||
file_filter = lambda f: (f.LocalPath().endswith(
|
||||
('.cc', '.h', '.m', '.mm')) and source_file_filter(f))
|
||||
|
||||
files = []
|
||||
for f in input_api.AffectedFiles(include_deletes=False,
|
||||
|
@ -1177,8 +1217,8 @@ def CheckAssertUsage(input_api, output_api, source_file_filter):
|
|||
def CheckAbslMemoryInclude(input_api, output_api, source_file_filter):
|
||||
pattern = input_api.re.compile(r'^#include\s*"absl/memory/memory.h"',
|
||||
input_api.re.MULTILINE)
|
||||
file_filter = lambda f: (f.LocalPath().endswith(('.cc', '.h')) and
|
||||
source_file_filter(f))
|
||||
file_filter = lambda f: (f.LocalPath().endswith(
|
||||
('.cc', '.h')) and source_file_filter(f))
|
||||
|
||||
files = []
|
||||
for f in input_api.AffectedFiles(include_deletes=False,
|
||||
|
@ -1205,8 +1245,8 @@ def CheckChangeOnUpload(input_api, output_api):
|
|||
results = []
|
||||
results.extend(CommonChecks(input_api, output_api))
|
||||
results.extend(CheckGnGen(input_api, output_api))
|
||||
results.extend(input_api.canned_checks.CheckGNFormatted(
|
||||
input_api, output_api))
|
||||
results.extend(
|
||||
input_api.canned_checks.CheckGNFormatted(input_api, output_api))
|
||||
return results
|
||||
|
||||
|
||||
|
@ -1218,7 +1258,8 @@ def CheckChangeOnCommit(input_api, output_api):
|
|||
results.extend(
|
||||
input_api.canned_checks.CheckChangeWasUploaded(input_api, output_api))
|
||||
results.extend(
|
||||
input_api.canned_checks.CheckChangeHasDescription(input_api, output_api))
|
||||
input_api.canned_checks.CheckChangeHasDescription(
|
||||
input_api, output_api))
|
||||
results.extend(CheckChangeHasBugField(input_api, output_api))
|
||||
results.extend(CheckCommitMessageBugEntry(input_api, output_api))
|
||||
results.extend(
|
||||
|
@ -1238,8 +1279,8 @@ def CheckOrphanHeaders(input_api, output_api, source_file_filter):
|
|||
exempt_paths = [re.escape(os.path.join('tools_webrtc', 'ios', 'SDK'))]
|
||||
|
||||
with _AddToPath(
|
||||
input_api.os_path.join(input_api.PresubmitLocalPath(), 'tools_webrtc',
|
||||
'presubmit_checks_lib')):
|
||||
input_api.os_path.join(input_api.PresubmitLocalPath(),
|
||||
'tools_webrtc', 'presubmit_checks_lib')):
|
||||
from check_orphan_headers import GetBuildGnPathFromFilePath
|
||||
from check_orphan_headers import IsHeaderInBuildGn
|
||||
|
||||
|
@ -1249,13 +1290,14 @@ def CheckOrphanHeaders(input_api, output_api, source_file_filter):
|
|||
if f.LocalPath().endswith('.h'):
|
||||
file_path = os.path.abspath(f.LocalPath())
|
||||
root_dir = os.getcwd()
|
||||
gn_file_path = GetBuildGnPathFromFilePath(file_path, os.path.exists,
|
||||
root_dir)
|
||||
gn_file_path = GetBuildGnPathFromFilePath(file_path,
|
||||
os.path.exists, root_dir)
|
||||
in_build_gn = IsHeaderInBuildGn(file_path, gn_file_path)
|
||||
if not in_build_gn:
|
||||
results.append(
|
||||
output_api.PresubmitError(
|
||||
error_msg.format(f.LocalPath(), os.path.relpath(gn_file_path))))
|
||||
error_msg.format(f.LocalPath(),
|
||||
os.path.relpath(gn_file_path))))
|
||||
return results
|
||||
|
||||
|
||||
|
@ -1271,7 +1313,8 @@ def CheckNewlineAtTheEndOfProtoFiles(input_api, output_api,
|
|||
with open(file_path) as f:
|
||||
lines = f.readlines()
|
||||
if len(lines) > 0 and not lines[-1].endswith('\n'):
|
||||
results.append(output_api.PresubmitError(error_msg.format(file_path)))
|
||||
results.append(
|
||||
output_api.PresubmitError(error_msg.format(file_path)))
|
||||
return results
|
||||
|
||||
|
||||
|
@ -1360,7 +1403,8 @@ def CheckAddedDepsHaveTargetApprovals(input_api, output_api):
|
|||
filename = input_api.os_path.basename(f.LocalPath())
|
||||
if filename == 'DEPS':
|
||||
virtual_depended_on_files.update(
|
||||
_CalculateAddedDeps(input_api.os_path, '\n'.join(f.OldContents()),
|
||||
_CalculateAddedDeps(input_api.os_path,
|
||||
'\n'.join(f.OldContents()),
|
||||
'\n'.join(f.NewContents())))
|
||||
|
||||
if not virtual_depended_on_files:
|
||||
|
@ -1417,7 +1461,8 @@ def CheckAddedDepsHaveTargetApprovals(input_api, output_api):
|
|||
|
||||
if unapproved_dependencies:
|
||||
output_list = [
|
||||
output('You need LGTM from owners of depends-on paths in DEPS that '
|
||||
output(
|
||||
'You need LGTM from owners of depends-on paths in DEPS that '
|
||||
' were modified in this CL:\n %s' %
|
||||
'\n '.join(sorted(unapproved_dependencies)))
|
||||
]
|
||||
|
|
216
pylintrc_old_style
Normal file
216
pylintrc_old_style
Normal file
|
@ -0,0 +1,216 @@
|
|||
# Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
# This file is mostly based on the contents of
|
||||
# https://cs.chromium.org/chromium/tools/depot_tools/pylintrc
|
||||
# and (since the above doesn't properly support naming style checks)
|
||||
# https://cs.chromium.org/chromium/src/third_party/chromite/pylintrc
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
|
||||
# Disable the message, report, category or checker with the given id(s).
|
||||
# TODO(kjellander): Reduce this list to as small as possible.
|
||||
disable=
|
||||
E0611,
|
||||
I0010,
|
||||
I0011,
|
||||
W0232,
|
||||
C0413,
|
||||
bad-continuation,
|
||||
broad-except,
|
||||
duplicate-code,
|
||||
eval-used,
|
||||
exec-used,
|
||||
fixme,
|
||||
import-error,
|
||||
import-outside-toplevel,
|
||||
missing-docstring,
|
||||
no-init,
|
||||
no-member,
|
||||
too-few-public-methods,
|
||||
too-many-ancestors,
|
||||
too-many-arguments,
|
||||
too-many-branches,
|
||||
too-many-function-args,
|
||||
too-many-instance-attributes,
|
||||
too-many-lines,
|
||||
too-many-locals,
|
||||
too-many-public-methods,
|
||||
too-many-return-statements,
|
||||
too-many-statements,
|
||||
|
||||
|
||||
[REPORTS]
|
||||
|
||||
# Don't write out full reports, just messages.
|
||||
reports=no
|
||||
|
||||
|
||||
[VARIABLES]
|
||||
|
||||
# Tells whether we should check for unused import in __init__ files.
|
||||
init-import=no
|
||||
|
||||
# A regular expression matching the beginning of the name of dummy variables
|
||||
# (i.e. not used).
|
||||
dummy-variables-rgx=_|dummy
|
||||
|
||||
|
||||
[TYPECHECK]
|
||||
|
||||
# Tells whether missing members accessed in mixin class should be ignored. A
|
||||
# mixin class is detected if its name ends with "mixin" (case insensitive).
|
||||
ignore-mixin-members=yes
|
||||
|
||||
# List of classes names for which member attributes should not be checked
|
||||
# (useful for classes with attributes dynamically set).
|
||||
ignored-classes=hashlib,numpy
|
||||
|
||||
|
||||
[MISCELLANEOUS]
|
||||
|
||||
# List of note tags to take in consideration, separated by a comma.
|
||||
notes=FIXME,XXX,TODO
|
||||
|
||||
|
||||
[SIMILARITIES]
|
||||
|
||||
# Minimum lines number of a similarity.
|
||||
min-similarity-lines=4
|
||||
|
||||
# Ignore comments when computing similarities.
|
||||
ignore-comments=yes
|
||||
|
||||
# Ignore docstrings when computing similarities.
|
||||
ignore-docstrings=yes
|
||||
|
||||
|
||||
[FORMAT]
|
||||
|
||||
# Maximum number of characters on a single line.
|
||||
max-line-length=80
|
||||
|
||||
# Maximum number of lines in a module
|
||||
max-module-lines=1000
|
||||
|
||||
# Use four spaces for indents.
|
||||
# indent-string=' '
|
||||
|
||||
|
||||
[BASIC]
|
||||
|
||||
# List of builtins function names that should not be used, separated by a comma
|
||||
bad-functions=map,filter,apply,input
|
||||
|
||||
# Regular expression which should only match correct module names
|
||||
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
||||
|
||||
# Regular expression which should only match correct module level names
|
||||
# (CAPS_WITH_UNDER)
|
||||
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
|
||||
|
||||
# Regular expression which should only match correct class names
|
||||
# (CapWords)
|
||||
class-rgx=[A-Z_][a-zA-Z0-9]+$
|
||||
|
||||
# Regular expression which should only match correct function names
|
||||
# The Chromium standard is different than PEP-8, so we need to redefine this to
|
||||
# only allow:
|
||||
# - CapWords
|
||||
# - main: Standard for main function.
|
||||
function-rgx=([A-Z_][a-zA-Z0-9]{2,60}|main)$
|
||||
|
||||
# Regular expression which should only match correct method names
|
||||
# The Chromium standard is different than PEP-8, so we need to redefine this to
|
||||
# only allow:
|
||||
# - CapWords, starting with a capital letter. No underscores in function
|
||||
# names. Can also have a "_" prefix (private method) or a "test" prefix
|
||||
# (unit test).
|
||||
# - Methods that look like __xyz__, which are used to do things like
|
||||
# __init__, __del__, etc.
|
||||
# - setUp, tearDown: For unit tests.
|
||||
method-rgx=((_|test)?[A-Z][a-zA-Z0-9]{2,60}|__[a-z]+__|setUp|tearDown)$
|
||||
|
||||
# Regular expression which should only match correct instance attribute names
|
||||
attr-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression which should only match correct argument names
|
||||
argument-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression which should only match correct variable names
|
||||
variable-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||
|
||||
# Regular expression which should only match correct list comprehension /
|
||||
# generator expression variable names
|
||||
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
|
||||
|
||||
# Good variable names which should always be accepted, separated by a comma
|
||||
good-names=i,j,k,ex,Run,_
|
||||
|
||||
# Bad variable names which should always be refused, separated by a comma
|
||||
bad-names=foo,bar,baz,toto,tutu,tata
|
||||
|
||||
# Regular expression which should only match functions or classes name which do
|
||||
# not require a docstring
|
||||
no-docstring-rgx=__.*__
|
||||
|
||||
|
||||
[DESIGN]
|
||||
|
||||
# Maximum number of arguments for function / method
|
||||
max-args=5
|
||||
|
||||
# Argument names that match this expression will be ignored. Default to name
|
||||
# with leading underscore
|
||||
ignored-argument-names=_.*
|
||||
|
||||
# Maximum number of locals for function / method body
|
||||
max-locals=15
|
||||
|
||||
# Maximum number of return / yield for function / method body
|
||||
max-returns=6
|
||||
|
||||
# Maximum number of branch for function / method body
|
||||
max-branchs=12
|
||||
|
||||
# Maximum number of statements in function / method body
|
||||
max-statements=50
|
||||
|
||||
# Maximum number of parents for a class (see R0901).
|
||||
max-parents=7
|
||||
|
||||
# Maximum number of attributes for a class (see R0902).
|
||||
max-attributes=7
|
||||
|
||||
# Minimum number of public methods for a class (see R0903).
|
||||
min-public-methods=2
|
||||
|
||||
# Maximum number of public methods for a class (see R0904).
|
||||
max-public-methods=20
|
||||
|
||||
|
||||
[CLASSES]
|
||||
|
||||
# List of method names used to declare (i.e. assign) instance attributes.
|
||||
defining-attr-methods=__init__,__new__,setUp
|
||||
|
||||
# List of valid names for the first argument in a class method.
|
||||
valid-classmethod-first-arg=cls
|
||||
|
||||
|
||||
[IMPORTS]
|
||||
|
||||
# Deprecated modules which should not be used, separated by a comma
|
||||
deprecated-modules=regsub,TERMIOS,Bastion,rexec
|
||||
|
||||
|
||||
[EXCEPTIONS]
|
||||
|
||||
# Exceptions that will emit a warning when being caught. Defaults to
|
||||
# "Exception"
|
||||
overgeneral-exceptions=Exception
|
Loading…
Reference in a new issue