import re, os root="/tmp/portaudit/src" pat=re.compile(r'^\s*(public|private|protected)?\s*static\s+(?!final)([\w\[\]<>,\.]+)\s+([A-Za-z_]\w*)\b.*;\s*$') counts={} allrows=[] for dp,_,fs in os.walk(root): for f in fs: if not f.endswith(".java"): continue p=os.path.join(dp,f) # note: static block 'static {' not matched for i,l in enumerate(open(p),1): s=l.strip() if s.startswith("//") or s.startswith("*"): continue m=pat.match(l) if m and "(" not in l.split(";")[0]: typ=m.group(2); name=m.group(3) allrows.append((p.replace(root+"/",""),i,typ,name)) print("TOTAL static non-final fields:", len(allrows)) for r in allrows: print(f" {r[0]}:{r[1]} {r[2]} {r[3]}")