• Home
  • Raw
  • Download

Lines Matching refs:m

301     for m in clazz.methods:
302 if re.search("[A-Z]{2,}", m.name) is not None:
303 … warn(clazz, m, "S1", "Method names with acronyms should be getMtu() instead of getMTU()")
304 if re.match("[^a-z]", m.name):
305 error(clazz, m, "S1", "Method name must start with lowercase char")
323 for m in clazz.methods:
324 if not re.match("on[A-Z][a-z]*", m.name):
325 error(clazz, m, "L1", "Callback method names must be onFoo() style")
339 for m in clazz.methods:
340 if not re.match("on[A-Z][a-z]*", m.name):
341 error(clazz, m, "L1", "Listener method names must be onFoo() style")
344 m = clazz.methods[0]
345 if (m.name + "Listener").lower() != clazz.name.lower():
346 error(clazz, m, "L1", "Single listener method name must match class name")
414 for m in clazz.methods:
415 if " static " in m.raw: continue
416 if "boolean equals(java.lang.Object)" in m.raw: eq = True
417 if "int hashCode()" in m.raw: hc = True
439 for m in clazz.methods:
440 if "protected" in m.split:
441 error(clazz, m, "M7", "Protected methods not allowed; must be public")
496 methods = [ m.name for m in clazz.methods ]
497 for m in clazz.methods:
498 if "Callback" in m.raw:
499 if m.name.startswith("register"):
500 other = "unregister" + m.name[8:]
502 error(clazz, m, "L2", "Missing unregister method")
503 if m.name.startswith("unregister"):
504 other = "register" + m.name[10:]
506 error(clazz, m, "L2", "Missing register method")
508 if m.name.startswith("add") or m.name.startswith("remove"):
509 error(clazz, m, "L3", "Callback methods should be named register/unregister")
511 if "Listener" in m.raw:
512 if m.name.startswith("add"):
513 other = "remove" + m.name[3:]
515 error(clazz, m, "L2", "Missing remove method")
516 if m.name.startswith("remove") and not m.name.startswith("removeAll"):
517 other = "add" + m.name[6:]
519 error(clazz, m, "L2", "Missing add method")
521 if m.name.startswith("register") or m.name.startswith("unregister"):
522 error(clazz, m, "L3", "Listener methods should be named add/remove")
527 for m in clazz.methods:
528 if "synchronized" in m.split:
529 error(clazz, m, "M5", "Internal locks must not be exposed")
536 for m in clazz.methods:
537 if m.typ == "android.content.Intent":
538 if m.name.startswith("create") and m.name.endswith("Intent"):
541 … warn(clazz, m, "FW1", "Methods creating an Intent should be named createFooIntent()")
583 for m in clazz.methods:
584 if "final" in m.split: continue
585 if not re.match("on[A-Z]", m.name):
586 if "abstract" in m.split:
587 … warn(clazz, m, None, "Methods implemented by developers should be named onFoo()")
589 …warn(clazz, m, None, "If implemented by developer, should be named onFoo(); otherwise consider mar…
602 for m in clazz.methods:
603 if m.name == "build":
607 if m.name.startswith("get"): continue
608 if m.name.startswith("clear"): continue
610 if m.name.startswith("with"):
611 warn(clazz, m, None, "Builder methods names should use setFoo() style")
613 if m.name.startswith("set"):
614 if not m.typ.endswith(clazz.fullname):
615 warn(clazz, m, "M4", "Methods must return the builder object")
667 for m in clazz.methods:
668 ir = rank(m.typ)
670 warn(clazz, m, "FW6", "Method return type violates package layering")
671 for arg in m.args:
674 warn(clazz, m, "FW6", "Method argument type violates package layering")
681 def is_get(m): return len(m.args) == 0 and m.typ == "boolean" argument
682 def is_set(m): return len(m.args) == 1 and m.args[0] == "boolean" argument
684 gets = [ m for m in clazz.methods if is_get(m) ]
685 sets = [ m for m in clazz.methods if is_set(m) ]
688 for m in methods:
689 if m.name == actual:
690 … error(clazz, m, "M6", "Symmetric method for %s must be named %s" % (trigger, expected))
692 for m in clazz.methods:
693 if is_get(m):
694 if re.match("is[A-Z]", m.name):
695 target = m.name[2:]
697 error_if_exists(sets, m.name, expected, "setHas" + target)
698 elif re.match("has[A-Z]", m.name):
699 target = m.name[3:]
701 error_if_exists(sets, m.name, expected, "setIs" + target)
702 error_if_exists(sets, m.name, expected, "set" + target)
703 elif re.match("get[A-Z]", m.name):
704 target = m.name[3:]
706 error_if_exists(sets, m.name, expected, "setIs" + target)
707 error_if_exists(sets, m.name, expected, "setHas" + target)
709 if is_set(m):
710 if re.match("set[A-Z]", m.name):
711 target = m.name[3:]
713 error_if_exists(sets, m.name, expected, "is" + target)
714 error_if_exists(sets, m.name, expected, "has" + target)
723 for m in clazz.methods:
724 if m.typ in bad:
725 … error(clazz, m, "CL2", "Return type is concrete collection; must be higher-level interface")
726 for arg in m.args:
728 … error(clazz, m, "CL2", "Argument is concrete collection; must be higher-level interface")
749 for m in clazz.methods:
750 …if "throws java.lang.Exception" in m.raw or "throws java.lang.Throwable" in m.raw or "throws java.…
751 error(clazz, m, "S1", "Methods must not throw generic exceptions")
753 if "throws android.os.RemoteException" in m.raw:
758 …error(clazz, m, "FW9", "Methods calling into system server should rethrow RemoteException as Runti…
784 for m in clazz.methods:
785 if m.typ == "java.util.BitSet":
786 error(clazz, m, None, "Return type must not be heavy BitSet")
787 for arg in m.args:
789 error(clazz, m, None, "Argument type must not be heavy BitSet")
800 for m in clazz.methods:
801 if m.typ == clazz.fullname:
802 error(clazz, m, None, "Managers must always be obtained from Context")
819 for m in clazz.methods:
820 if m.typ in boxed:
821 error(clazz, m, "M11", "Must avoid boxed primitives")
822 for arg in m.args:
824 error(clazz, m, "M11", "Must avoid boxed primitives")
851 for m in clazz.methods:
852 if "deprecated" in m.split: continue
853 overloads[m.name].append(m)
869 for m in methods:
870 common_args = common_args & cluster(m.args)
876 for m in methods:
877 sig = m.args[0:len(common_args)]
879 …warn(clazz, m, "M2", "Expected common arguments [%s] at beginning of overloaded method" % (", ".jo…
883 …error(clazz, m, "M2", "Expected consistent argument ordering between overloads: %s..." % (", ".joi…
913 for m in clazz.methods:
914 if m.name.startswith("unregister"): continue
915 if m.name.startswith("remove"): continue
916 if re.match("on[A-Z]+", m.name): continue
918 by_name[m.name].append(m)
920 for a in m.args:
922 found[m.name] = m
926 for m in by_name[f.name]:
927 if "android.os.Handler" in m.args:
936 for m in examine:
937 if len(m.args) > 1 and m.args[0] != "android.content.Context":
938 if "android.content.Context" in m.args[1:]:
939 error(clazz, m, "M3", "Context is distinct, so it must be the first argument")
940 if len(m.args) > 1 and m.args[0] != "android.content.ContentResolver":
941 if "android.content.ContentResolver" in m.args[1:]:
942 … error(clazz, m, "M3", "ContentResolver is distinct, so it must be the first argument")
948 for m in examine:
949 if "Listener" in m.name or "Callback" in m.name: continue
951 for a in m.args:
955 warn(clazz, m, "M3", "Listeners should always be at end of argument list")
995 for m in test:
996 if "java.io.File" in m.args:
997 has_file.add(m)
998 …leDescriptor" in m.args or "android.os.ParcelFileDescriptor" in m.args or "java.io.InputStream" in…
999 has_stream.add(m.name)
1001 for m in has_file:
1002 if m.name not in has_stream:
1003 … warn(clazz, m, "M10", "Methods accepting File should also accept FileDescriptor or streams")
1011 for m in clazz.methods:
1012 if m.typ.startswith("android.") and m.typ.endswith("[]"):
1013 …warn(clazz, m, None, "Methods should return List<? extends Parcelable> instead of Parcelable[] to …
1096 for m in clazz.methods:
1097 if m.typ not in ["short","int","long"]: continue
1099 if m.name.endswith(k):
1100 error(clazz, m, None, "Expected method name units to be " + v)
1101 if m.name.endswith("Nanos") or m.name.endswith("Micros"):
1102 …warn(clazz, m, None, "Returned time values are strongly encouraged to be in milliseconds unless yo…
1103 if m.name.endswith("Seconds"):
1104 error(clazz, m, None, "Returned time values must be in milliseconds")
1106 for m in clazz.methods:
1107 typ = m.typ
1109 if len(m.args) != 1: continue
1110 typ = m.args[0]
1112 if m.name.endswith("Fraction") and typ != "float":
1113 error(clazz, m, None, "Fractions must use floats")
1114 if m.name.endswith("Percentage") and typ != "int":
1115 error(clazz, m, None, "Percentage must use ints")
1123 for m in clazz.methods:
1124 if len(m.args) > 0: continue
1125 …if m.name in ["close","release","destroy","finish","finalize","disconnect","shutdown","stop","free…
1126 …warn(clazz, m, None, "Classes that release resources should implement AutoClosable and CloseGuard")
1208 for m in clazz.ctors:
1209 if m.ident == test.ident: return True
1220 for m in methods:
1221 if m.ident == test.ident: return True