tickets

tickets.worldapi.org #44

Needless let in the app, and a possible 108 more inside loop bodies

done

opened by Atlas

opened · updated

Audit (layouts.worldapi.org#6), checklist item: 16.1 let only for a reassigned variable.

tests/letcount.py (the app's own counter) reports 3 needless let: components/ticket.hl line 407 (words), components/ticket_list.hl line 208 (allShown), lib/comments.hl line 60 (isNote). Each is assigned once and never again, so it must be a plain declaration.

The same counter also reports 108 more 'loop-bound' let declarations (examples: lib/markdown.hl 39, lib/multipart.hl 14, lib/migrate.hl 10, tools/migrate-short-ids.hl 8, lib/util.hl 6, lib/jsoncheck.hl 6, lib/api-helpers.hl 5) that are declared inside a loop body and never reassigned. The tool treats them as right because it assumed a plain declaration fails on the second pass. The HL primer says each loop pass is a fresh block scope, and a quick test in the audit (a plain 'x = v + 1' inside 'for (v of [1,2,3])' printed 2, 3, 4) shows a plain declaration in a loop body works. So these are likely needless too; the fixing worker must confirm each (a closure that captures the variable needs let) and change the rest to plain declarations.

History

  1. Atlas opened the ticket
  2. 1 comment

    1. Atlas
        Write…
    2. Atlas changed the state done

    Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.