diff options
| author | 2016-12-21 22:21:13 +0000 | |
|---|---|---|
| committer | 2016-12-21 22:21:17 +0000 | |
| commit | a090de5c8bf04fc14fae31a9a9e2e632ab7be81e (patch) | |
| tree | a2b1cd023273c8fd96e69f7a49c5647d2a76eea2 /tools/apilint/apilint.py | |
| parent | 87c7b34807630e47332467b24ebfdd75964baf73 (diff) | |
| parent | 26c809064747d62a139f33c3c5124102cbba7e83 (diff) | |
Merge "Detect non-static abstract inner classes."
Diffstat (limited to 'tools/apilint/apilint.py')
| -rw-r--r-- | tools/apilint/apilint.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/apilint/apilint.py b/tools/apilint/apilint.py index 6ca59b0fb93b..48a1330063c4 100644 --- a/tools/apilint/apilint.py +++ b/tools/apilint/apilint.py @@ -990,6 +990,14 @@ def verify_manager_list(clazz): warn(clazz, m, None, "Methods should return List<? extends Parcelable> instead of Parcelable[] to support ParceledListSlice under the hood") +def verify_abstract_inner(clazz): + """Verifies that abstract inner classes are static.""" + + if re.match(".+?\.[A-Z][^\.]+\.[A-Z]", clazz.fullname): + if " abstract " in clazz.raw and " static " not in clazz.raw: + warn(clazz, None, None, "Abstract inner classes should be static to improve testability") + + def examine_clazz(clazz): """Find all style issues in the given class.""" if clazz.pkg.name.startswith("java"): return @@ -1036,6 +1044,7 @@ def examine_clazz(clazz): verify_resource_names(clazz) verify_files(clazz) verify_manager_list(clazz) + verify_abstract_inner(clazz) def examine_stream(stream): |