gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit875353c1875353c1calendar mission 009: re-vendor Hybriel master 022a3ac1 (int 6 6b396322 hl:time browser side, int 7 65e8ec21; bin sha256 6e0f77d7, plugins whole)mre875353c1/tests/letcount.py

3.6 KB

  1. #!/usr/bin/env python3
  2. # tests/letcount.py (copied from tickets.worldapi.org mission 010 via gitoria 002 / notes 002; calendar mission 001: sub-folders too): the code-order counts of an app tree (antcolony docs/code-order.md) — root .hl files, project.hl lines, and every `let`:
  3. # reassigned the name is assigned again later in its block → `let` is right
  4. # loop-bound declared inside a for/while body (re-bound each pass —
  5. # Hybriel refuses a plain declaration there on pass 2) → `let` is right
  6. # never neither → should be a plain declaration
  7. # python3 tests/letcount.py . [-v] (-v lists every `let` that should be a plain declaration) (scans *.hl, components/, lib/, tools/, tests/ with sub-folders; not plugins/)
  8. import os, re, sys
  9. root = sys.argv[1]; verbose = '-v' in sys.argv
  10. files = []
  11. files += [os.path.join(root, f) for f in sorted(os.listdir(root)) if f.endswith('.hl')]
  12. for d in ['components', 'lib', 'tools', 'tests']: # with their sub-folders (components/month-view/)
  13. for dp, dn, fn in sorted(os.walk(os.path.join(root, d))): dn.sort(); files += [os.path.join(dp, f) for f in sorted(fn) if f.endswith('.hl')]
  14. def strip(src):
  15. # blank out strings and comments (same length) so braces/names inside them do not count
  16. out = list(src); i = 0; n = len(src)
  17. while i < n:
  18. c = src[i]
  19. if src.startswith('//', i):
  20. j = src.find('\n', i); j = n if j < 0 else j
  21. for k in range(i, j): out[k] = ' '
  22. i = j; continue
  23. if c in '\'"`':
  24. j = i + 1
  25. while j < n and src[j] != c:
  26. if c == "'" and src[j] == '\\' and j + 1 < n and src[j + 1] == "'": j += 2; continue
  27. j += 1
  28. for k in range(i + 1, min(j, n)):
  29. if out[k] != '\n': out[k] = ' '
  30. i = j + 1; continue
  31. i += 1
  32. return ''.join(out)
  33. tot = {'reassigned': 0, 'loop-bound': 0, 'never': 0}
  34. per = {}
  35. for f in files:
  36. s = strip(open(f).read())
  37. opens = []; match = {}; stack = []
  38. for i, c in enumerate(s):
  39. if c == '{': stack.append(i)
  40. elif c == '}' and stack: match[stack.pop()] = i
  41. for m in re.finditer(r'\blet\s+(\w+)\s*=', s):
  42. name, p = m.group(1), m.start()
  43. encl = [o for o, e in match.items() if o < p < e]
  44. encl.sort(reverse=True) # innermost first
  45. inner_end = match[encl[0]] if encl else len(s)
  46. kind = 'never'
  47. if re.search(r'(?<![\w.#])' + re.escape(name) + r'\s*(=(?!=)|\+\+|--|\+=|-=)', s[m.end():inner_end]): kind = 'reassigned'
  48. else:
  49. for o in encl:
  50. head = s[max(0, o - 300):o]
  51. line = head[head.rfind('\n') + 1:] if '\n' in head else head
  52. if re.search(r'=>\s*$', head) or re.match(r'\s*(on\s|static\s|\w+\s*\([^)]*\)\s*$)', line) and not re.match(r'\s*(if|for|while|else)\b', line): break
  53. if re.search(r'\b(for|while)\s*\([^{}]*\)\s*$', head): kind = 'loop-bound'; break
  54. tot[kind] += 1
  55. per.setdefault(os.path.relpath(f, root), {'reassigned': 0, 'loop-bound': 0, 'never': 0})[kind] += 1
  56. if verbose and kind == 'never': print(f' never: {os.path.relpath(f, root)}:{s.count(chr(10), 0, p) + 1} {name}')
  57. rootHl = [f for f in os.listdir(root) if f.endswith('.hl')]
  58. pl = sum(1 for _ in open(os.path.join(root, 'project.hl')))
  59. print(f'root .hl files: {len(rootHl)} ({" ".join(sorted(rootHl))})')
  60. print(f'project.hl lines: {pl}')
  61. print(f'let total {sum(tot.values())}: reassigned {tot["reassigned"]}, loop-bound {tot["loop-bound"]}, never reassigned {tot["never"]}')
  62. for f, k in sorted(per.items()): print(f' {f}: {k}')

Branches

Latest commits

  • 875353c1calendar mission 009: re-vendor Hybriel master 022a3ac1 (int 6 6b396322 hl:time browser side, int 7 65e8ec21; bin sha256 6e0f77d7, plugins whole)mre
  • ce16a4efdeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • f490bc8cdeploy: Web Push gate tests/push.mjs (PUSH_GATE_PORT)mre
  • 3af29fc8calendar mission 008 (A8): report, README, LOG, push-shots.mjsmre
  • f91f3663calendar mission 008 (A8): push only asked of the browser when the app has the VAPID settings (pushAvailable); real-FCM E2E scripts (push-real-app.mjs, push-real.mjs)mre
  • bf571badcalendar mission 008 (A8): Turn off on this device (unsubscribes the browser, server drops the device, choice kept), subscribe/refresh when the app is shown again; push gate part 3mre
  • 50985708calendar mission 008 (A7): Web Push report, README, mission, LOGmre
  • ee318774calendar mission 008 (A7): push-real.mjs, push sent log linemre
  • ebda0fd1calendar mission 008 (A7): server-side reminder plan on hl:time (push-plan.hl; hl:time fromLocal in a browser static is refused: repro .scratch/hltime-client), push gate 9/9mre
  • d063dad3calendar mission 008 (A7): Web Push (WIP): lib/push.hl subscriptions + sender clock, faces calPushSave/calPushOff, button subscribes, VAPID tool, tests/push.mjs; instantOf on hl:timemre
  • cf175c80calendar mission 008 (A7): re-vendor Hybriel master 0e3c9830 (bin 9d957fed, plugins whole: hl:crypto Web Push primitives, hl:web sendPush)mre
  • 9bf3c38bcalendar mission 008: re-vendor Hybriel f9833544 (gates old = new); Web Push stopped: hl:crypto half missing on mastermre
  • 186f969bcalendar mission 007: signed-in gate for the first-pointer race (fails on 3c5604f), README theme section, reportmre
  • ba9b4955calendar mission 006: first pointer event no longer re-runs the month (stale overwrite race), gate check, e2e settings cleanup, reportmre
  • bd730759calendar mission 006: theme move (WIP): brief, report, LOG, STATUSmre
  • b117b153calendar mission 006 WIP: reminder row fields keep 44 px; e2e script flagsmre
  • 53e3b0debrowser gate: Log out through the user menu, theme colour rgb(15, 20, 25)mre
  • 90bf9e2ecalendar mission 006 WIP: theme dbe3de7, theme shell (AppHeader/MainMenu/UserMenu/Sidebar/ContentFirst), styles cut to the app's own rules, check-theme gate, e2e toolsmre
  • 3c5604f9identkit: refuse a taken ident port, cold-start deadline, abort on dead ident, clear no-code error (as notes)mre
  • 4996bbe7paths: projects moved into /media/STORAGE/projects/WorldAPI/mre