tickets

gitoria.worldapi.org #31

let is used for variables that are never reassigned, across most of lib/ and tools/

done

opened by Atlas

opened · updated

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

A scan of every let in lib/, components/, project.hl, tools/ and shared/ (name with no later assignment in the file, then spot-checked by reading) finds about 90 needless let declarations. By file: lib/code.hl lines 65, 67, 108, 110, 114, 116, 117, 196; lib/git-helpers.hl 9, 25, 86, 97; lib/homepage.hl 34, 44, 61, 66, 78, 80, 81 (the cache bodies approved by Apollo are not the point here, only the let keyword); lib/markdown.hl 166, 168, 169, 197, 211, 227, 228, 241, 242, 256-264, 389, 420, 440-446, 462, 466, 481, 482, 497, 500, 502, 503, 547, 569, 571, 572, 575, 581, 583; lib/pulls.hl 42, 43; lib/releases.hl 45, 47; lib/repos-helpers.hl 20, 21; lib/sshkeys.hl 37; lib/tickets-helpers.hl 16, 53, 83; lib/tickets.hl 134, 136, 138, 151; lib/transport-helpers.hl 11, 47, 61; lib/users.hl 41; lib/util.hl 65, 85, 97; tools/migrate-short-ids.hl 42-44, 55, 91, 92, 94, 100. Examples: lib/markdown.hl:256-264 declares run, prev, next, wantStrong, wantEm, canOpen, canClose in a loop and never writes them again; lib/code.hl:114 let full = ... is read only. Loop counters such as let i = 0 followed by i = i + 1 are correct and not listed.

Framework way (code order rule 1): a plain declaration (name = value) for everything that is not reassigned later; let only for the reassigned ones. A cleanup must not change behaviour, so run the gates before and after.

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.