import re, os, sys root = "/tmp/portaudit/src" results = [] # regex for method decl: modifiers... returnType name(args) { decl_re = re.compile(r'^\s*(?:public|private|protected|static|final|abstract|synchronized|native|\s)*[\w\[\]<>.,\s]+\s+(\w+)\s*\([^;{]*\)\s*\{') for dirpath, _, files in os.walk(root): for f in files: if not f.endswith(".java"): continue path = os.path.join(dirpath, f) with open(path) as fh: lines = fh.readlines() i = 0 while i < len(lines): line = lines[i] m = decl_re.match(line) # skip control statements / class decls if m and not re.match(r'^\s*(if|for|while|switch|catch|do|else|try|synchronized|return|new)\b', line): name = m.group(1) # find matching brace depth = 0 started = False j = i end = None while j < len(lines): for ch in lines[j]: if ch == '{': depth += 1 started = True elif ch == '}': depth -= 1 if started and depth == 0: end = j break if end is not None: break j += 1 if end is not None and 'class ' not in line and 'interface ' not in line: size = end - i + 1 results.append((size, f"{path.replace(root+'/','')}:{i+1}", name)) i = end + 1 if end is not None else i + 1 else: i += 1 results.sort(reverse=True) for size, loc, name in results[:25]: print(f"{size:5d} {loc:50s} {name}")