Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26c80906 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Detect non-static abstract inner classes.

Test: script detects issue
Bug: 32982018
Change-Id: I4e3521bf603f6272bfe5583e3d4977dd5b59afe8
parent d0abcbeb
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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):