gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit942ac995942ac995status: paused workers statemre942ac995/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

  • 942ac995status: paused workers statemre
  • 44b934e5log: respawn cleanupmre
  • 03a80097Log: Anton GC A/Bmre
  • c7cdef62Log: Apollo STOP, workers pausedmre
  • d0c083fbLog: usage stopmre
  • c6d464e5Log: Apollo GO backlog, AP56 and BS1 startedmre
  • 1eb6f1a1Missions AP56, BS1mre
  • 4871f8adLog: AP52 live on day52, browser gate greenmre
  • d9bf2988Merge ap52: day52, tracker#58 server argument, #51 modal close rule, #56 keyed season rowsmre
  • c4a60ef2Log: RT52 retest passed, AP52 startedmre
  • 83760a55Browser gate: search results belong to the address form of the typed text (tracker#52 navigate replace)mre
  • 6e951d91AP52: show-page rows are keyed records; closing a season is one upsert and removes (tracker#56, hybriel#331)mre
  • 3bb4ccddAP52: modal close button refers to its nested rule with Style.buttonModalX (tracker#51, hybriel#333)mre
  • ba16933fAP52: login callback and title route are static handlers taking the server as third argument (tracker#58, hybriel#332)mre
  • 85153900AP52: re-vendor Hybriel set day52 (source 77cfca31, bin 0a8ed496)mre
  • 7c051eddLog: hybriel#338 answermre
  • d049b8b8Log: HM50 live, #52 donemre
  • 6d05fa37Log: HM50 Part A mergedmre
  • 1c7dab74HM50: the shell reads the framework's online state, netProbe removed (tracker#55)mre
  • e8b91697HM50: search address follows the text via navigate(path, replace = true) (tracker#52)mre