Fix pylint warning and refactor project_list.
Bug: 31377083
Test: run warn.py --byproject build.log
Change-Id: Id442cf6608bf5c14784063c05f5ff0b731f17486
diff --git a/tools/warn.py b/tools/warn.py
index dc6aacd..2e7927a 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -1661,82 +1661,91 @@
]
+def project_name_and_pattern(name, pattern):
+ return [name, '(^|.*/)' + pattern + '/.*: warning:']
+
+
+def simple_project_pattern(pattern):
+ return project_name_and_pattern(pattern, pattern)
+
+
# A list of [project_name, file_path_pattern].
# project_name should not contain comma, to be used in CSV output.
project_list = [
- # pylint:disable=bad-whitespace,g-inconsistent-quotes,line-too-long
- ['art', r"(^|.*/)art/.*: warning:"],
- ['bionic', r"(^|.*/)bionic/.*: warning:"],
- ['bootable', r"(^|.*/)bootable/.*: warning:"],
- ['build', r"(^|.*/)build/.*: warning:"],
- ['cts', r"(^|.*/)cts/.*: warning:"],
- ['dalvik', r"(^|.*/)dalvik/.*: warning:"],
- ['developers', r"(^|.*/)developers/.*: warning:"],
- ['development', r"(^|.*/)development/.*: warning:"],
- ['device', r"(^|.*/)device/.*: warning:"],
- ['doc', r"(^|.*/)doc/.*: warning:"],
+ simple_project_pattern('art'),
+ simple_project_pattern('bionic'),
+ simple_project_pattern('bootable'),
+ simple_project_pattern('build'),
+ simple_project_pattern('cts'),
+ simple_project_pattern('dalvik'),
+ simple_project_pattern('developers'),
+ simple_project_pattern('development'),
+ simple_project_pattern('device'),
+ simple_project_pattern('doc'),
# match external/google* before external/
- ['external/google', r"(^|.*/)external/google.*: warning:"],
- ['external/non-google', r"(^|.*/)external/.*: warning:"],
- ['frameworks/av/camera',r"(^|.*/)frameworks/av/camera/.*: warning:"],
- ['frameworks/av/cmds', r"(^|.*/)frameworks/av/cmds/.*: warning:"],
- ['frameworks/av/drm', r"(^|.*/)frameworks/av/drm/.*: warning:"],
- ['frameworks/av/include',r"(^|.*/)frameworks/av/include/.*: warning:"],
- ['frameworks/av/media', r"(^|.*/)frameworks/av/media/.*: warning:"],
- ['frameworks/av/radio', r"(^|.*/)frameworks/av/radio/.*: warning:"],
- ['frameworks/av/services', r"(^|.*/)frameworks/av/services/.*: warning:"],
- ['frameworks/av/Other', r"(^|.*/)frameworks/av/.*: warning:"],
- ['frameworks/base', r"(^|.*/)frameworks/base/.*: warning:"],
- ['frameworks/compile', r"(^|.*/)frameworks/compile/.*: warning:"],
- ['frameworks/minikin', r"(^|.*/)frameworks/minikin/.*: warning:"],
- ['frameworks/native', r"(^|.*/)frameworks/native/.*: warning:"],
- ['frameworks/opt', r"(^|.*/)frameworks/opt/.*: warning:"],
- ['frameworks/rs', r"(^|.*/)frameworks/rs/.*: warning:"],
- ['frameworks/webview', r"(^|.*/)frameworks/webview/.*: warning:"],
- ['frameworks/wilhelm', r"(^|.*/)frameworks/wilhelm/.*: warning:"],
- ['frameworks/Other', r"(^|.*/)frameworks/.*: warning:"],
- ['hardware/akm', r"(^|.*/)hardware/akm/.*: warning:"],
- ['hardware/broadcom', r"(^|.*/)hardware/broadcom/.*: warning:"],
- ['hardware/google', r"(^|.*/)hardware/google/.*: warning:"],
- ['hardware/intel', r"(^|.*/)hardware/intel/.*: warning:"],
- ['hardware/interfaces', r"(^|.*/)hardware/interfaces/.*: warning:"],
- ['hardware/libhardware',r"(^|.*/)hardware/libhardware/.*: warning:"],
- ['hardware/libhardware_legacy',r"(^|.*/)hardware/libhardware_legacy/.*: warning:"],
- ['hardware/qcom', r"(^|.*/)hardware/qcom/.*: warning:"],
- ['hardware/ril', r"(^|.*/)hardware/ril/.*: warning:"],
- ['hardware/Other', r"(^|.*/)hardware/.*: warning:"],
- ['kernel', r"(^|.*/)kernel/.*: warning:"],
- ['libcore', r"(^|.*/)libcore/.*: warning:"],
- ['libnativehelper', r"(^|.*/)libnativehelper/.*: warning:"],
- ['ndk', r"(^|.*/)ndk/.*: warning:"],
+ project_name_and_pattern('external/google', 'external/google.*'),
+ project_name_and_pattern('external/non-google', 'external'),
+ simple_project_pattern('frameworks/av/camera'),
+ simple_project_pattern('frameworks/av/cmds'),
+ simple_project_pattern('frameworks/av/drm'),
+ simple_project_pattern('frameworks/av/include'),
+ simple_project_pattern('frameworks/av/media'),
+ simple_project_pattern('frameworks/av/radio'),
+ simple_project_pattern('frameworks/av/services'),
+ project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
+ simple_project_pattern('frameworks/base'),
+ simple_project_pattern('frameworks/compile'),
+ simple_project_pattern('frameworks/minikin'),
+ simple_project_pattern('frameworks/native'),
+ simple_project_pattern('frameworks/opt'),
+ simple_project_pattern('frameworks/rs'),
+ simple_project_pattern('frameworks/webview'),
+ simple_project_pattern('frameworks/wilhelm'),
+ project_name_and_pattern('frameworks/Other', 'frameworks'),
+ simple_project_pattern('hardware/akm'),
+ simple_project_pattern('hardware/broadcom'),
+ simple_project_pattern('hardware/google'),
+ simple_project_pattern('hardware/intel'),
+ simple_project_pattern('hardware/interfaces'),
+ simple_project_pattern('hardware/libhardware'),
+ simple_project_pattern('hardware/libhardware_legacy'),
+ simple_project_pattern('hardware/qcom'),
+ simple_project_pattern('hardware/ril'),
+ project_name_and_pattern('hardware/Other', 'hardware'),
+ simple_project_pattern('kernel'),
+ simple_project_pattern('libcore'),
+ simple_project_pattern('libnativehelper'),
+ simple_project_pattern('ndk'),
# match vendor/unbungled_google/packages before other packages
- ['unbundled_google', r"(^|.*/)unbundled_google/.*: warning:"],
- ['packages', r"(^|.*/)packages/.*: warning:"],
- ['pdk', r"(^|.*/)pdk/.*: warning:"],
- ['prebuilts', r"(^|.*/)prebuilts/.*: warning:"],
- ['system/bt', r"(^|.*/)system/bt/.*: warning:"],
- ['system/connectivity', r"(^|.*/)system/connectivity/.*: warning:"],
- ['system/core', r"(^|.*/)system/core/.*: warning:"],
- ['system/extras', r"(^|.*/)system/extras/.*: warning:"],
- ['system/gatekeeper', r"(^|.*/)system/gatekeeper/.*: warning:"],
- ['system/keymaster', r"(^|.*/)system/keymaster/.*: warning:"],
- ['system/libhwbinder', r"(^|.*/)system/libhwbinder/.*: warning:"],
- ['system/media', r"(^|.*/)system/media/.*: warning:"],
- ['system/netd', r"(^|.*/)system/netd/.*: warning:"],
- ['system/security', r"(^|.*/)system/security/.*: warning:"],
- ['system/sepolicy', r"(^|.*/)system/sepolicy/.*: warning:"],
- ['system/tools', r"(^|.*/)system/tools/.*: warning:"],
- ['system/vold', r"(^|.*/)system/vold/.*: warning:"],
- ['system/Other', r"(^|.*/)system/.*: warning:"],
- ['toolchain', r"(^|.*/)toolchain/.*: warning:"],
- ['test', r"(^|.*/)test/.*: warning:"],
- ['tools', r"(^|.*/)tools/.*: warning:"],
+ simple_project_pattern('unbundled_google'),
+ simple_project_pattern('packages'),
+ simple_project_pattern('pdk'),
+ simple_project_pattern('prebuilts'),
+ simple_project_pattern('system/bt'),
+ simple_project_pattern('system/connectivity'),
+ simple_project_pattern('system/core'),
+ simple_project_pattern('system/extras'),
+ simple_project_pattern('system/gatekeeper'),
+ simple_project_pattern('system/keymaster'),
+ simple_project_pattern('system/libhwbinder'),
+ simple_project_pattern('system/media'),
+ simple_project_pattern('system/netd'),
+ simple_project_pattern('system/security'),
+ simple_project_pattern('system/sepolicy'),
+ simple_project_pattern('system/tools'),
+ simple_project_pattern('system/vold'),
+ project_name_and_pattern('system/Other', 'system'),
+ simple_project_pattern('toolchain'),
+ simple_project_pattern('test'),
+ simple_project_pattern('tools'),
# match vendor/google* before vendor/
- ['vendor/google', r"(^|.*/)vendor/google.*: warning:"],
- ['vendor/non-google', r"(^|.*/)vendor/.*: warning:"],
+ project_name_and_pattern('vendor/google', 'vendor/google.*'),
+ project_name_and_pattern('vendor/non-google', 'vendor'),
# keep out/obj and other patterns at the end.
- ['out/obj', r".*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:"],
- ['other', r".*: warning:"],
+ ['out/obj',
+ '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
+ 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
+ ['other', '.*'] # all other unrecognized patterns
]
project_patterns = []