Merge "Use python3 specifically for envsetup.sh"
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index 8f0702b..393053d 100644
--- a/core/dex_preopt_libart.mk
+++ b/core/dex_preopt_libart.mk
@@ -68,7 +68,7 @@
endif
LOCAL_MODULE_CLASS := ETC
include $(BUILD_PREBUILT)
- $(LOCAL_BUILT_MODULE): $(my_unstripped_installed)
+ $(LOCAL_BUILT_MODULE): | $(my_unstripped_installed)
# Installing boot.art causes all boot image bits to be installed.
# Keep this old behavior in case anyone still needs it.
$(LOCAL_INSTALLED_MODULE): $(my_installed)
diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk
index 48072b3..5120e7e 100644
--- a/core/dynamic_binary.mk
+++ b/core/dynamic_binary.mk
@@ -87,9 +87,14 @@
###########################################################
## Strip
###########################################################
-strip_input := $(symbolic_output)
+strip_input := $(inject_module)
strip_output := $(LOCAL_BUILT_MODULE)
+# Use an order-only dependency to ensure the unstripped file in the symbols
+# directory is copied when the module is built, but does not force the
+# module to be rebuilt when the symbols directory is cleaned by installclean.
+$(strip_output): | $(symbolic_output)
+
my_strip_module := $(firstword \
$(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
$(LOCAL_STRIP_MODULE))
diff --git a/core/soong_app_prebuilt.mk b/core/soong_app_prebuilt.mk
index b7c21b8..82fb413 100644
--- a/core/soong_app_prebuilt.mk
+++ b/core/soong_app_prebuilt.mk
@@ -147,7 +147,7 @@
# install symbol files of JNI libraries
my_jni_lib_symbols_copy_files := $(foreach f,$(LOCAL_SOONG_JNI_LIBS_SYMBOLS),\
$(call word-colon,1,$(f)):$(patsubst $(PRODUCT_OUT)/%,$(TARGET_OUT_UNSTRIPPED)/%,$(call word-colon,2,$(f))))
-$(LOCAL_BUILT_MODULE): $(call copy-many-files, $(my_jni_lib_symbols_copy_files))
+$(LOCAL_BUILT_MODULE): | $(call copy-many-files, $(my_jni_lib_symbols_copy_files))
# embedded JNI will already have been handled by soong
my_embed_jni :=
diff --git a/core/soong_cc_prebuilt.mk b/core/soong_cc_prebuilt.mk
index a12ef66..4d7b614 100644
--- a/core/soong_cc_prebuilt.mk
+++ b/core/soong_cc_prebuilt.mk
@@ -170,7 +170,7 @@
my_unstripped_path := $(patsubst $(TARGET_OUT_UNSTRIPPED)/root/%,$(TARGET_OUT_UNSTRIPPED)/%, $(my_unstripped_path))
symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem)
$(eval $(call copy-one-file,$(LOCAL_SOONG_UNSTRIPPED_BINARY),$(symbolic_output)))
- $(call add-dependency,$(LOCAL_BUILT_MODULE),$(symbolic_output))
+ $(LOCAL_BUILT_MODULE): | $(symbolic_output)
ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
my_breakpad_path := $(TARGET_OUT_BREAKPAD)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_symbol_path))
diff --git a/core/soong_rust_prebuilt.mk b/core/soong_rust_prebuilt.mk
index c382f6a..26c099b 100644
--- a/core/soong_rust_prebuilt.mk
+++ b/core/soong_rust_prebuilt.mk
@@ -119,7 +119,7 @@
my_unstripped_path := $(patsubst $(TARGET_OUT_UNSTRIPPED)/root/%,$(TARGET_OUT_UNSTRIPPED)/%, $(my_unstripped_path))
symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem)
$(eval $(call copy-one-file,$(LOCAL_SOONG_UNSTRIPPED_BINARY),$(symbolic_output)))
- $(call add-dependency,$(LOCAL_BUILT_MODULE),$(symbolic_output))
+ $(LOCAL_BUILT_MODULE): | $(symbolic_output)
endif
endif
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 83425cc..b397fd0 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -138,6 +138,7 @@
# existing search paths.
RAMDISK_BUILD_PROP_REL_PATHS = ['system/etc/ramdisk/build.prop']
+
class ErrorCode(object):
"""Define error_codes for failures that happen during the actual
update package installation.
@@ -226,6 +227,7 @@
def SetHostToolLocation(tool_name, location):
OPTIONS.host_tools[tool_name] = location
+
def FindHostToolPath(tool_name):
"""Finds the path to the host tool.
@@ -246,6 +248,7 @@
return tool_name
+
def Run(args, verbose=None, **kwargs):
"""Creates and returns a subprocess.Popen object.
@@ -434,6 +437,13 @@
return self._fingerprint
@property
+ def is_vabc(self):
+ vendor_prop = self.info_dict.get("vendor.build.prop")
+ vabc_enabled = vendor_prop and \
+ vendor_prop.GetProp("ro.virtual_ab.compression.enabled") == "true"
+ return vabc_enabled
+
+ @property
def oem_props(self):
return self._oem_props
@@ -461,7 +471,7 @@
"""Returns the inquired build property for the provided partition."""
# Boot image uses ro.[product.]bootimage instead of boot.
- prop_partition = "bootimage" if partition == "boot" else partition
+ prop_partition = "bootimage" if partition == "boot" else partition
# If provided a partition for this property, only look within that
# partition's build.prop.
@@ -652,10 +662,12 @@
raise KeyError(fn)
return file
+
class RamdiskFormat(object):
LZ4 = 1
GZ = 2
+
def _GetRamdiskFormat(info_dict):
if info_dict.get('lz4_ramdisks') == 'true':
ramdisk_format = RamdiskFormat.LZ4
@@ -663,6 +675,7 @@
ramdisk_format = RamdiskFormat.GZ
return ramdisk_format
+
def LoadInfoDict(input_file, repacking=False):
"""Loads the key/value pairs from the given input target_files.
@@ -781,7 +794,8 @@
for partition in PARTITIONS_WITH_BUILD_PROP:
fingerprint = build_info.GetPartitionFingerprint(partition)
if fingerprint:
- d["avb_{}_salt".format(partition)] = sha256(fingerprint.encode()).hexdigest()
+ d["avb_{}_salt".format(partition)] = sha256(
+ fingerprint.encode()).hexdigest()
try:
d["ab_partitions"] = read_helper("META/ab_partitions.txt").split("\n")
except KeyError:
@@ -789,7 +803,6 @@
return d
-
def LoadListFromFile(file_path):
with open(file_path) as f:
return f.read().splitlines()
@@ -859,7 +872,8 @@
"""Loads the build.prop file and builds the attributes."""
if name == "boot":
- data = PartitionBuildProps._ReadBootPropFile(input_file, ramdisk_format=ramdisk_format)
+ data = PartitionBuildProps._ReadBootPropFile(
+ input_file, ramdisk_format=ramdisk_format)
else:
data = PartitionBuildProps._ReadPartitionPropFile(input_file, name)
@@ -1106,7 +1120,7 @@
return " ".join(sorted(combined))
if (framework_dict.get("use_dynamic_partitions") !=
- "true") or (vendor_dict.get("use_dynamic_partitions") != "true"):
+ "true") or (vendor_dict.get("use_dynamic_partitions") != "true"):
raise ValueError("Both dictionaries must have use_dynamic_partitions=true")
merged_dict = {"use_dynamic_partitions": "true"}
@@ -1371,7 +1385,8 @@
# Checks key_path exists, before appending --gki_signing_* args.
if not os.path.exists(key_path):
- raise ExternalError('gki_signing_key_path: "{}" not found'.format(key_path))
+ raise ExternalError(
+ 'gki_signing_key_path: "{}" not found'.format(key_path))
algorithm = OPTIONS.info_dict.get("gki_signing_algorithm")
if key_path and algorithm:
@@ -1588,7 +1603,7 @@
RunAndCheckOutput(cmd)
if (info_dict.get("boot_signer") == "true" and
- info_dict.get("verity_key")):
+ info_dict.get("verity_key")):
# Hard-code the path as "/boot" for two-step special recovery image (which
# will be loaded into /boot during the two-step OTA).
if two_step_image:
@@ -1753,14 +1768,17 @@
if os.access(fn, os.F_OK):
ramdisk_fragments = shlex.split(open(fn).read().rstrip("\n"))
for ramdisk_fragment in ramdisk_fragments:
- fn = os.path.join(sourcedir, "RAMDISK_FRAGMENTS", ramdisk_fragment, "mkbootimg_args")
+ fn = os.path.join(sourcedir, "RAMDISK_FRAGMENTS",
+ ramdisk_fragment, "mkbootimg_args")
cmd.extend(shlex.split(open(fn).read().rstrip("\n")))
- fn = os.path.join(sourcedir, "RAMDISK_FRAGMENTS", ramdisk_fragment, "prebuilt_ramdisk")
+ fn = os.path.join(sourcedir, "RAMDISK_FRAGMENTS",
+ ramdisk_fragment, "prebuilt_ramdisk")
# Use prebuilt image if found, else create ramdisk from supplied files.
if os.access(fn, os.F_OK):
ramdisk_fragment_pathname = fn
else:
- ramdisk_fragment_root = os.path.join(sourcedir, "RAMDISK_FRAGMENTS", ramdisk_fragment)
+ ramdisk_fragment_root = os.path.join(
+ sourcedir, "RAMDISK_FRAGMENTS", ramdisk_fragment)
ramdisk_fragment_img = _MakeRamdisk(ramdisk_fragment_root,
ramdisk_format=ramdisk_format)
ramdisk_fragment_imgs.append(ramdisk_fragment_img)
@@ -3533,7 +3551,7 @@
for g in tgt_groups:
for p in shlex.split(info_dict.get(
- "super_%s_partition_list" % g, "").strip()):
+ "super_%s_partition_list" % g, "").strip()):
assert p in self._partition_updates, \
"{} is in target super_{}_partition_list but no BlockDifference " \
"object is provided.".format(p, g)
@@ -3541,7 +3559,7 @@
for g in src_groups:
for p in shlex.split(source_info_dict.get(
- "super_%s_partition_list" % g, "").strip()):
+ "super_%s_partition_list" % g, "").strip()):
assert p in self._partition_updates, \
"{} is in source super_{}_partition_list but no BlockDifference " \
"object is provided.".format(p, g)
@@ -3650,7 +3668,7 @@
if u.src_size is not None and u.tgt_size is None:
append('remove_group %s' % g)
if (u.src_size is not None and u.tgt_size is not None and
- u.src_size > u.tgt_size):
+ u.src_size > u.tgt_size):
comment('Shrink group %s from %d to %d' % (g, u.src_size, u.tgt_size))
append('resize_group %s %d' % (g, u.tgt_size))
@@ -3659,7 +3677,7 @@
comment('Add group %s with maximum size %d' % (g, u.tgt_size))
append('add_group %s %d' % (g, u.tgt_size))
if (u.src_size is not None and u.tgt_size is not None and
- u.src_size < u.tgt_size):
+ u.src_size < u.tgt_size):
comment('Grow group %s from %d to %d' % (g, u.src_size, u.tgt_size))
append('resize_group %s %d' % (g, u.tgt_size))
@@ -3693,7 +3711,8 @@
"""
tmp_dir = MakeTempDir('boot_', suffix='.img')
try:
- RunAndCheckOutput(['unpack_bootimg', '--boot_img', boot_img, '--out', tmp_dir])
+ RunAndCheckOutput(['unpack_bootimg', '--boot_img',
+ boot_img, '--out', tmp_dir])
ramdisk = os.path.join(tmp_dir, 'ramdisk')
if not os.path.isfile(ramdisk):
logger.warning('Unable to get boot image timestamp: no ramdisk in boot')
@@ -3704,7 +3723,8 @@
elif ramdisk_format == RamdiskFormat.GZ:
with open(ramdisk, 'rb') as input_stream:
with open(uncompressed_ramdisk, 'wb') as output_stream:
- p2 = Run(['minigzip', '-d'], stdin=input_stream.fileno(), stdout=output_stream.fileno())
+ p2 = Run(['minigzip', '-d'], stdin=input_stream.fileno(),
+ stdout=output_stream.fileno())
p2.wait()
else:
logger.error('Only support lz4 or minigzip ramdisk format.')
@@ -3715,13 +3735,14 @@
# Use "toybox cpio" instead of "cpio" because the latter invokes cpio from
# the host environment.
RunAndCheckOutput(['toybox', 'cpio', '-F', abs_uncompressed_ramdisk, '-i'],
- cwd=extracted_ramdisk)
+ cwd=extracted_ramdisk)
for search_path in RAMDISK_BUILD_PROP_REL_PATHS:
prop_file = os.path.join(extracted_ramdisk, search_path)
if os.path.isfile(prop_file):
return prop_file
- logger.warning('Unable to get boot image timestamp: no %s in ramdisk', search_path)
+ logger.warning(
+ 'Unable to get boot image timestamp: no %s in ramdisk', search_path)
return None
@@ -3754,7 +3775,8 @@
timestamp = props.GetProp('ro.bootimage.build.date.utc')
if timestamp:
return int(timestamp)
- logger.warning('Unable to get boot image timestamp: ro.bootimage.build.date.utc is undefined')
+ logger.warning(
+ 'Unable to get boot image timestamp: ro.bootimage.build.date.utc is undefined')
return None
except ExternalError as e:
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index 02b2b4d..abbcfa0 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -1051,15 +1051,18 @@
"META/ab_partitions.txt is required for ab_update."
target_info = common.BuildInfo(OPTIONS.target_info_dict, OPTIONS.oem_dicts)
source_info = common.BuildInfo(OPTIONS.source_info_dict, OPTIONS.oem_dicts)
- vendor_prop = source_info.info_dict.get("vendor.build.prop")
- vabc_used = vendor_prop and \
- vendor_prop.GetProp("ro.virtual_ab.compression.enabled") == "true" and \
- not OPTIONS.disable_vabc
- if vabc_used:
+ # If source supports VABC, delta_generator/update_engine will attempt to
+ # use VABC. This dangerous, as the target build won't have snapuserd to
+ # serve I/O request when device boots. Therefore, disable VABC if source
+ # build doesn't supports it.
+ if not source_info.is_vabc or not target_info.is_vabc:
+ OPTIONS.disable_vabc = True
+ if not OPTIONS.disable_vabc:
# TODO(zhangkelvin) Remove this once FEC on VABC is supported
logger.info("Virtual AB Compression enabled, disabling FEC")
OPTIONS.disable_fec_computation = True
OPTIONS.disable_verity_computation = True
+
else:
assert "ab_partitions" in OPTIONS.info_dict, \
"META/ab_partitions.txt is required for ab_update."
diff --git a/tools/warn.py b/tools/warn.py
index 5f796f5..97f54f9 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -27,6 +27,7 @@
def main():
+ """Old main() calls warn.warn."""
os.environ['PYTHONPATH'] = os.path.dirname(os.path.abspath(__file__))
subprocess.check_call(['/usr/bin/python3', '-m', 'warn.warn'] + sys.argv[1:])
diff --git a/tools/warn/android_project_list.py b/tools/warn/android_project_list.py
index 82c0fbd..8383dc0 100644
--- a/tools/warn/android_project_list.py
+++ b/tools/warn/android_project_list.py
@@ -17,6 +17,7 @@
def create_pattern(name, pattern=None):
+ """Return a tuple of name and warn patten."""
if pattern is not None:
return [name, '(^|.*/)' + pattern + '/.*: warning:']
return [name, '(^|.*/)' + name + '/.*: warning:']
diff --git a/tools/warn/chrome_project_list.py b/tools/warn/chrome_project_list.py
index 6096522..d8b2179 100644
--- a/tools/warn/chrome_project_list.py
+++ b/tools/warn/chrome_project_list.py
@@ -8,6 +8,7 @@
def create_pattern(pattern):
+ """Return a tuple of name and warn patten."""
return [pattern, '(^|.*/)' + pattern + '/.*: warning:']
diff --git a/tools/warn/cpp_warn_patterns.py b/tools/warn/cpp_warn_patterns.py
index e8783bc..2fa9916 100644
--- a/tools/warn/cpp_warn_patterns.py
+++ b/tools/warn/cpp_warn_patterns.py
@@ -15,10 +15,12 @@
"""Warning patterns for C/C++ compiler, but not clang-tidy."""
+# No need of doc strings for trivial small functions.
+# pylint:disable=missing-function-docstring
+
import re
# pylint:disable=relative-beyond-top-level
-# pylint:disable=g-importing-member
from .severity import Severity
@@ -56,7 +58,8 @@
warn_patterns = [
- # pylint:disable=line-too-long,g-inconsistent-quotes
+ # pylint does not recognize g-inconsistent-quotes
+ # pylint:disable=line-too-long,bad-option-value,g-inconsistent-quotes
medium('Implicit function declaration',
[r".*: warning: implicit declaration of function .+",
r".*: warning: implicitly declaring library function"]),
@@ -300,7 +303,7 @@
medium('Missing noreturn',
[r".*: warning: function '.*' could be declared with attribute 'noreturn'"]),
medium('User warning',
- [r".*: warning: #warning "".+"""]),
+ [r".*: warning: #warning \".+\""]),
medium('Vexing parsing problem',
[r".*: warning: empty parentheses interpreted as a function declaration"]),
medium('Dereferencing void*',
diff --git a/tools/warn/html_writer.py b/tools/warn/html_writer.py
index be71b55..bed25ed 100644
--- a/tools/warn/html_writer.py
+++ b/tools/warn/html_writer.py
@@ -15,6 +15,9 @@
"""Emit warning messages to html or csv files."""
+# Many functions in this module have too many arguments to be refactored.
+# pylint:disable=too-many-arguments,missing-function-docstring
+
# To emit html page of warning messages:
# flags: --byproject, --url, --separator
# Old stuff for static html components:
@@ -57,11 +60,10 @@
import sys
# pylint:disable=relative-beyond-top-level
-# pylint:disable=g-importing-member
from .severity import Severity
-html_head_scripts = """\
+HTML_HEAD_SCRIPTS = """\
<script type="text/javascript">
function expand(id) {
var e = document.getElementById(id);
@@ -113,7 +115,7 @@
def dump_html_prologue(title, writer, warn_patterns, project_names):
writer('<html>\n<head>')
writer('<title>' + title + '</title>')
- writer(html_head_scripts)
+ writer(HTML_HEAD_SCRIPTS)
emit_stats_by_project(writer, warn_patterns, project_names)
writer('</head>\n<body>')
writer(html_big(title))
@@ -142,7 +144,7 @@
2D warnings array where warnings[p][s] is # of warnings in project name p of
severity level s
"""
- # pylint:disable=g-complex-comprehension
+ # pylint:disable=invalid-name
warnings = {p: {s.value: 0 for s in Severity.levels} for p in project_names}
for i in warn_patterns:
s = i['severity'].value
@@ -153,7 +155,6 @@
def get_total_by_project(warnings, project_names):
"""Returns dict, project as key and # warnings for that project as value."""
- # pylint:disable=g-complex-comprehension
return {
p: sum(warnings[p][s.value] for s in Severity.levels)
for p in project_names
@@ -162,7 +163,6 @@
def get_total_by_severity(warnings, project_names):
"""Returns dict, severity as key and # warnings of that severity as value."""
- # pylint:disable=g-complex-comprehension
return {
s.value: sum(warnings[p][s.value] for p in project_names)
for s in Severity.levels
@@ -235,7 +235,7 @@
writer('<script>')
emit_const_string_array('StatsHeader', stats_header, writer)
emit_const_object_array('StatsRows', stats_rows, writer)
- writer(draw_table_javascript)
+ writer(DRAW_TABLE_JAVASCRIPT)
writer('</script>')
@@ -246,8 +246,8 @@
total_by_project = get_total_by_project(warnings, project_names)
total_by_severity = get_total_by_severity(warnings, project_names)
stats_header = emit_table_header(total_by_severity)
- total_all_projects, stats_rows = \
- emit_row_counts_per_project(warnings, total_by_project, total_by_severity, project_names)
+ total_all_projects, stats_rows = emit_row_counts_per_project(
+ warnings, total_by_project, total_by_severity, project_names)
emit_row_counts_per_severity(total_by_severity, stats_header, stats_rows,
total_all_projects, writer)
@@ -287,6 +287,7 @@
# id for each warning pattern
# sort by project, severity, warn_id, warning_message
def emit_buttons(writer):
+ """Write the button elements in HTML."""
writer('<button class="button" onclick="expandCollapse(1);">'
'Expand all warnings</button>\n'
'<button class="button" onclick="expandCollapse(0);">'
@@ -412,7 +413,7 @@
writer('];')
-scripts_for_warning_groups = """
+SCRIPTS_FOR_WARNING_GROUPS = """
function compareMessages(x1, x2) { // of the same warning type
return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
}
@@ -620,7 +621,7 @@
emit_const_html_string_array('WarningLinks', warning_links, writer)
-draw_table_javascript = """
+DRAW_TABLE_JAVASCRIPT = """
google.charts.load('current', {'packages':['table']});
google.charts.setOnLoadCallback(drawTable);
function drawTable() {
@@ -653,7 +654,7 @@
writer('\n<script>')
emit_js_data(writer, flags, warning_messages, warning_links, warning_records,
warn_patterns, project_names)
- writer(scripts_for_warning_groups)
+ writer(SCRIPTS_FOR_WARNING_GROUPS)
writer('</script>')
emit_buttons(writer)
# Warning messages are grouped by severities or project names.
diff --git a/tools/warn/java_warn_patterns.py b/tools/warn/java_warn_patterns.py
index ac1ed5d..534f48d 100644
--- a/tools/warn/java_warn_patterns.py
+++ b/tools/warn/java_warn_patterns.py
@@ -15,8 +15,10 @@
"""Warning patterns for Java compiler tools."""
+# No need of doc strings for trivial small functions.
+# pylint:disable=missing-function-docstring
+
# pylint:disable=relative-beyond-top-level
-# pylint:disable=g-importing-member
from .cpp_warn_patterns import compile_patterns
from .severity import Severity
@@ -59,7 +61,8 @@
warn_patterns = [
- # pylint:disable=line-too-long,g-inconsistent-quotes
+ # pylint does not recognize g-inconsistent-quotes
+ # pylint:disable=line-too-long,bad-option-value,g-inconsistent-quotes
# Warnings from Javac
java_medium('Use of deprecated',
[r'.*: warning: \[deprecation\] .+',
diff --git a/tools/warn/make_warn_patterns.py b/tools/warn/make_warn_patterns.py
index 4b20493..a54c502 100644
--- a/tools/warn/make_warn_patterns.py
+++ b/tools/warn/make_warn_patterns.py
@@ -16,12 +16,12 @@
"""Warning patterns for build make tools."""
# pylint:disable=relative-beyond-top-level
-# pylint:disable=g-importing-member
from .cpp_warn_patterns import compile_patterns
from .severity import Severity
warn_patterns = [
- # pylint:disable=line-too-long,g-inconsistent-quotes
+ # pylint does not recognize g-inconsistent-quotes
+ # pylint:disable=line-too-long,bad-option-value,g-inconsistent-quotes
{'category': 'make', 'severity': Severity.MEDIUM,
'description': 'make: overriding commands/ignoring old commands',
'patterns': [r".*: warning: overriding commands for target .+",
diff --git a/tools/warn/other_warn_patterns.py b/tools/warn/other_warn_patterns.py
index 8df5b87..d05c8e9 100644
--- a/tools/warn/other_warn_patterns.py
+++ b/tools/warn/other_warn_patterns.py
@@ -15,8 +15,10 @@
"""Warning patterns from other tools."""
+# No need of doc strings for trivial small functions.
+# pylint:disable=missing-function-docstring
+
# pylint:disable=relative-beyond-top-level
-# pylint:disable=g-importing-member
from .cpp_warn_patterns import compile_patterns
from .severity import Severity
@@ -57,7 +59,8 @@
warn_patterns = [
- # pylint:disable=line-too-long,g-inconsistent-quotes
+ # pylint does not recognize g-inconsistent-quotes
+ # pylint:disable=line-too-long,bad-option-value,g-inconsistent-quotes
# aapt warnings
aapt('No comment for public symbol',
[r".*: warning: No comment for public symbol .+"]),
diff --git a/tools/warn/severity.py b/tools/warn/severity.py
index b4c03c9..20064c3 100644
--- a/tools/warn/severity.py
+++ b/tools/warn/severity.py
@@ -19,8 +19,9 @@
"""
-# pylint:disable=old-style-class
+# pylint:disable=too-few-public-methods
class SeverityInfo:
+ """Class of Severity Info, part of a Severity object."""
def __init__(self, value, color, column_header, header):
self.value = value
@@ -29,7 +30,7 @@
self.header = header
-# pylint:disable=old-style-class
+# pylint:disable=too-few-public-methods
class Severity:
"""Class of Severity levels where each level is a SeverityInfo."""
diff --git a/tools/warn/tidy_warn_patterns.py b/tools/warn/tidy_warn_patterns.py
index 5416cb2..7018d10 100644
--- a/tools/warn/tidy_warn_patterns.py
+++ b/tools/warn/tidy_warn_patterns.py
@@ -15,8 +15,10 @@
"""Warning patterns for clang-tidy."""
+# No need of doc strings for trivial small functions.
+# pylint:disable=missing-function-docstring
+
# pylint:disable=relative-beyond-top-level
-# pylint:disable=g-importing-member
from .cpp_warn_patterns import compile_patterns
from .severity import Severity
@@ -39,7 +41,6 @@
def analyzer_high(description, patterns):
- # Important clang analyzer warnings to be fixed ASAP.
return {
'category': 'C/C++',
'severity': Severity.HIGH,
@@ -74,7 +75,8 @@
warn_patterns = [
- # pylint:disable=line-too-long,g-inconsistent-quotes
+ # pylint does not recognize g-inconsistent-quotes
+ # pylint:disable=line-too-long,bad-option-value,g-inconsistent-quotes
group_tidy_warn_pattern('android'),
simple_tidy_warn_pattern('abseil-string-find-startswith'),
simple_tidy_warn_pattern('bugprone-argument-comment'),
diff --git a/tools/warn/warn.py b/tools/warn/warn.py
index cb5daec..acfbb55 100755
--- a/tools/warn/warn.py
+++ b/tools/warn/warn.py
@@ -20,7 +20,8 @@
import signal
import sys
-# pylint:disable=relative-beyond-top-level
+# pylint:disable=relative-beyond-top-level,no-name-in-module
+# suppress false positive of no-name-in-module warnings
from . import warn_common as common
@@ -50,6 +51,7 @@
def create_and_launch_subprocesses(num_cpu, classify_warnings_fn, arg_groups,
group_results):
+ """Fork num_cpu processes to classify warnings."""
pool = multiprocessing.Pool(num_cpu)
for cpu in range(num_cpu):
proc_result = pool.map(classify_warnings_fn, arg_groups[cpu])
@@ -59,6 +61,7 @@
def main():
+ """Old main() calls new common_main."""
use_google3 = False
common.common_main(use_google3, create_and_launch_subprocesses,
classify_warnings)
diff --git a/tools/warn/warn_common.py b/tools/warn/warn_common.py
index b2dd8ab..d69050f 100755
--- a/tools/warn/warn_common.py
+++ b/tools/warn/warn_common.py
@@ -52,8 +52,8 @@
import re
import sys
-# pylint:disable=relative-beyond-top-level
-# pylint:disable=g-importing-member
+# pylint:disable=relative-beyond-top-level,no-name-in-module
+# suppress false positive of no-name-in-module warnings
from . import android_project_list
from . import chrome_project_list
from . import cpp_warn_patterns as cpp_patterns
@@ -115,6 +115,8 @@
def find_project_index(line, project_patterns):
+ """Return the index to the project pattern array."""
+ # pylint:disable=invalid-name
for i, p in enumerate(project_patterns):
if p.match(line):
return i
@@ -124,30 +126,30 @@
def classify_one_warning(warning, link, results, project_patterns,
warn_patterns):
"""Classify one warning line."""
+ # pylint:disable=invalid-name
for i, w in enumerate(warn_patterns):
for cpat in w['compiled_patterns']:
if cpat.match(warning):
p = find_project_index(warning, project_patterns)
results.append([warning, link, i, p])
return
- else:
- # If we end up here, there was a problem parsing the log
- # probably caused by 'make -j' mixing the output from
- # 2 or more concurrent compiles
- pass
+ # If we end up here, there was a problem parsing the log
+ # probably caused by 'make -j' mixing the output from
+ # 2 or more concurrent compiles
-def remove_prefix(s, sub):
- """Remove everything before last occurrence of substring sub in string s."""
- if sub in s:
- inc_sub = s.rfind(sub)
- return s[inc_sub:]
- return s
+def remove_prefix(src, sub):
+ """Remove everything before last occurrence of substring sub in string src."""
+ if sub in src:
+ inc_sub = src.rfind(sub)
+ return src[inc_sub:]
+ return src
# TODO(emmavukelj): Don't have any generate_*_cs_link functions call
# normalize_path a second time (the first time being in parse_input_file)
def generate_cs_link(warning_line, flags, android_root=None):
+ """Try to add code search HTTP URL prefix."""
if flags.platform == 'chrome':
return generate_chrome_cs_link(warning_line, flags)
if flags.platform == 'android':
@@ -279,8 +281,7 @@
if idx >= 0:
# remove chrome_root/, we want path relative to that
return path[idx + len('chrome_root/'):]
- else:
- return path
+ return path
def normalize_warning_line(line, flags, android_root=None):
@@ -309,6 +310,7 @@
# Remove the duplicated warnings save ~8% of time when parsing
# one typical build log than before
unique_warnings = dict()
+ # pylint:disable=invalid-name
for line in infile:
if warning_pattern.match(line):
normalized_line = normalize_warning_line(line, flags)
@@ -344,6 +346,7 @@
def parse_input_file_android(infile, flags):
"""Parse Android input file, collect parameters and warning lines."""
+ # pylint:disable=too-many-locals,too-many-branches
platform_version = 'unknown'
target_product = 'unknown'
target_variant = 'unknown'
@@ -393,6 +396,7 @@
line, flags, android_root, unique_warnings)
continue
+ # pylint:disable=invalid-name
if line_counter < 100:
# save a little bit of time by only doing this for the first few lines
line_counter += 1
@@ -424,6 +428,7 @@
def parse_input_file(infile, flags):
+ """Parse one input file for chrome or android."""
if flags.platform == 'chrome':
return parse_input_file_chrome(infile, flags)
if flags.platform == 'android':
@@ -448,9 +453,12 @@
if platform == 'chrome':
warn_patterns = cpp_patterns.warn_patterns
elif platform == 'android':
- warn_patterns = make_patterns.warn_patterns + cpp_patterns.warn_patterns + java_patterns.warn_patterns + tidy_patterns.warn_patterns + other_patterns.warn_patterns
+ warn_patterns = (make_patterns.warn_patterns + cpp_patterns.warn_patterns +
+ java_patterns.warn_patterns + tidy_patterns.warn_patterns +
+ other_patterns.warn_patterns)
else:
raise Exception('platform name %s is not valid' % platform)
+ # pylint:disable=invalid-name
for w in warn_patterns:
w['members'] = []
# Each warning pattern has a 'projects' dictionary, that
@@ -473,6 +481,7 @@
use_google3, create_launch_subprocs_fn,
classify_warnings_fn):
"""Classify all warning lines with num_cpu parallel processes."""
+ # pylint:disable=too-many-arguments,too-many-locals
num_cpu = args.processes
group_results = []
@@ -531,8 +540,10 @@
def process_log(logfile, flags, project_names, project_patterns, warn_patterns,
html_path, use_google3, create_launch_subprocs_fn,
classify_warnings_fn, logfile_object):
- # pylint: disable=g-doc-args
- # pylint: disable=g-doc-return-or-yield
+ # pylint does not recognize g-doc-*
+ # pylint: disable=bad-option-value,g-doc-args
+ # pylint: disable=bad-option-value,g-doc-return-or-yield
+ # pylint: disable=too-many-arguments,too-many-locals
"""Function that handles processing of a log.
This is isolated into its own function (rather than just taking place in main)