gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit4043945640439456Merge hm63-searchtext: tracker#63 packed search textmre40439456/tools/lambda-audit.py

1.8 KB

  1. # tools/lambda-audit.py <app dir> (mission 070, hybriel#48): every lambda that CHANGES a parameter without & (field/list
  2. # writes, or a local alias `x = p` / `let x = p` — mission 028: a plain declaration copies like `let`) — since 8efba065 it changes a COPY; check that each caller uses the returned value.
  3. import re,sys,glob,os
  4. os.chdir(sys.argv[1])
  5. files=[f for f in glob.glob('*.hl')+glob.glob('lib/*.hl')+glob.glob('components/*.hl')+glob.glob('tools/*.hl')+glob.glob('tests/*.hl')+glob.glob('shared/*.hl')]
  6. lam=re.compile(r'(?:^|[\s,(=])(?:static\s+)?([A-Za-z_]\w*)?\s*=?\s*\(([^()]*)\)\s*=>\s*\{')
  7. tot=0
  8. for f in sorted(files):
  9. src=open(f,encoding='utf-8').read()
  10. for m in re.finditer(r'\(([^()]*)\)\s*=>\s*\{',src):
  11. params=[p.strip() for p in m.group(1).split(',') if p.strip()]
  12. i=m.end(); depth=1
  13. while depth and i<len(src):
  14. c=src[i]
  15. if c=='{':depth+=1
  16. elif c=='}':depth-=1
  17. i+=1
  18. body=src[m.end():i-1]
  19. line=src.count('\n',0,m.start())+1
  20. tot+=1
  21. for p in params:
  22. if p.startswith('&'): continue
  23. p=p.split('=')[0].strip()
  24. if not re.match(r'^\w+$',p): continue
  25. hits=[]
  26. for pat,kind in [(r'\b%s(?:\.\w+|\[[^\]]*\])+\s*=(?!=)'%p,'field-assign'),(r'\b%s(?:\.\w+|\[[^\]]*\])*\.(push|pop|shift|unshift|splice|sort|reverse)\('%p,'list-mutate'),(r'^\s*(?:let\s+)?(\w+)\s*=\s*%s\s*$'%p,'alias')]:
  27. for h in re.finditer(pat,body,re.M):
  28. hits.append(kind+': '+body[max(0,h.start()-0):h.end()+20].split('\n')[0].strip())
  29. if hits:
  30. name=src[max(0,m.start()-60):m.start()].split('\n')[-1].strip()
  31. print(f'{f}:{line} [{name} ({",".join(params)})] param {p}:', ' | '.join(hits[:4]))
  32. print('lambdas scanned:',tot, file=sys.stderr)

Branches

Latest commits

  • 40439456Merge hm63-searchtext: tracker#63 packed search textmre
  • b7e6b48ePack normalized search text behind numeric offsetsmre
  • b35f53e1log: DP62 stale runtime decisionmre
  • f9593602log: Apollo deploy rule correctionmre
  • 3c95f7f3log: DP62 and HM63 startedmre
  • 9c4397c9mission HM63mre
  • 8dfe42c8mission DP62mre
  • e347fef4Merge rv44: tracker#61 #62 on Hybriel day44mre
  • 8274bcf1log: RV44 done, deploy held for the usage windowmre
  • 1ef7a3b1RV44: report day44 gates and migration/restart proofsmre
  • a5f62f6cRV44: re-vendor Hybriel set day44 (source 222edef7, bin 4f0f263e)mre
  • 6159a248Merge branch 'hm62-personindex' into rv44mre
  • a8923d93log: RV44 startedmre
  • cf28cf77mission RV44mre
  • 585782dfLog: tracker#60 Chrome look, STATUS rewrittenmre
  • 147d0172conductor: caramboleyo is the user, not owner/creatorApollo
  • 21dd0cfblog: #60 live measurement, reviewmre
  • 7793cf94HM62b report: person indexes with fixed mpackdbmre
  • b4c8d3a9Document tracker#62 fixed-index migration and GC proofmre
  • 09d66ed5status: #60 livemre