Created
October 26, 2023 22:39
-
-
Save lukechampine/77533ebdc2e57e8314a4e58723de58a4 to your computer and use it in GitHub Desktop.
Dead Hoon linter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dead arms detected by running the above script on urbit/urbit tip, against a corpus | |
| of ~300k lines of Hoon (including urbit/urbit itself and various community repos): | |
| urbit/pkg/autoprop/sur/sole.hoon: | |
| +sole-gen | |
| urbit/pkg/autoprop/lib/ethereum.hoon: | |
| +address-to-checksum | |
| +batch-read-request | |
| +encode-atoms | |
| +light-json-request | |
| +parse-eth-new-filter-res | |
| +parse-transaction-hash | |
| +sign-typed-transaction | |
| urbit/pkg/autoprop/lib/language-server/complete.hoon: | |
| +advance-tape | |
| +search-exact | |
| urbit/pkg/autoprop/lib/sole.hoon: | |
| +remit | |
| urbit/pkg/base-dev/sur/hood.hoon: | |
| +get-apps-live | |
| +read-bill | |
| +read-bill-foreign | |
| +report-kids | |
| urbit/pkg/base-dev/sur/bitcoin.hoon: | |
| +op-checksig | |
| +op-dup | |
| +op-equalverify | |
| +op-hash160 | |
| +vbytes | |
| urbit/pkg/base-dev/sur/sole.hoon: | |
| +sole-gen | |
| urbit/pkg/base-dev/lib/strandio.hoon: | |
| +check-online | |
| +send-cancel-request | |
| +take-watch | |
| +watch-one | |
| urbit/pkg/base-dev/lib/jose.hoon: | |
| +eor | |
| urbit/pkg/base-dev/lib/sss.hoon: | |
| +chit | |
| +fled | |
| +handle-fake-on-rock | |
| +mk-mar | |
| +mk-pubs | |
| +surf | |
| urbit/pkg/base-dev/lib/ethereum.hoon: | |
| +address-to-checksum | |
| +batch-read-request | |
| +encode-atoms | |
| +light-json-request | |
| +parse-eth-new-filter-res | |
| +parse-transaction-hash | |
| +sign-typed-transaction | |
| urbit/pkg/base-dev/lib/test.hoon: | |
| +expect-success | |
| +run-chain | |
| urbit/pkg/base-dev/lib/ph/util.hoon: | |
| +expect-dojo-output | |
| urbit/pkg/base-dev/lib/azimuth.hoon: | |
| +apply-point-diff | |
| +conditional-star-release | |
| +event-log-to-point-diff | |
| +function-to-call | |
| +parse-id | |
| urbit/pkg/base-dev/lib/bip/b173.hoon: | |
| +encode-pubkey | |
| +from-address | |
| urbit/pkg/base-dev/lib/bip/b158.hoon: | |
| +all-match | |
| urbit/pkg/base-dev/lib/bip/b174.hoon: | |
| +get-txid | |
| urbit/pkg/base-dev/lib/agentio.hoon: | |
| +kick-only | |
| +warp-slim | |
| urbit/pkg/base-dev/lib/language-server/build.hoon: | |
| +get-errors-from-tang | |
| urbit/pkg/base-dev/lib/language-server/complete.hoon: | |
| +advance-tape | |
| +search-exact | |
| urbit/pkg/base-dev/lib/bitcoin-utils.hoon: | |
| +dea | |
| urbit/pkg/base-dev/lib/bip32.hoon: | |
| +from-public-point | |
| +private-chain | |
| +prv-extended | |
| +pub-extended | |
| +public-chain | |
| urbit/pkg/base-dev/lib/server.hoon: | |
| +login-redirect | |
| +manx-response | |
| +woff2-response | |
| urbit/pkg/base-dev/lib/sole.hoon: | |
| +remit | |
| urbit/pkg/base-dev/lib/azimuthio.hoon: | |
| +fetch-point | |
| urbit/pkg/base-dev/lib/keygen.hoon: | |
| +full-wallet-from-ticket | |
| urbit/pkg/landscape/mar/demo/update.hoon: | |
| +demo-update-1 | |
| urbit/pkg/landscape/mar/demo/update-0.hoon: | |
| +demo-update-1 | |
| urbit/pkg/landscape/mar/graph/update.hoon: | |
| +graph-update-0 | |
| urbit/pkg/landscape/mar/metadata/update.hoon: | |
| +metadata-update-0 | |
| urbit/pkg/landscape/ted/graph/groupify.hoon: | |
| +check-live | |
| urbit/pkg/landscape/sur/hood.hoon: | |
| +get-apps-live | |
| +read-bill | |
| +read-bill-foreign | |
| +report-kids | |
| urbit/pkg/landscape/sur/bitcoin.hoon: | |
| +op-checksig | |
| +op-dup | |
| +op-equalverify | |
| +op-hash160 | |
| +vbytes | |
| urbit/pkg/landscape/sur/settings.hoon: | |
| +settings-0 | |
| +settings-1 | |
| urbit/pkg/landscape/sur/sole.hoon: | |
| +sole-gen | |
| urbit/pkg/landscape/sur/hark-store-historical.hoon: | |
| +indexed-notification | |
| +unread-stats | |
| urbit/pkg/landscape/app/chat-cli.hoon: | |
| +append-newline | |
| +show-create | |
| urbit/pkg/landscape/app/group-view.hoon: | |
| +leave-breach | |
| urbit/pkg/landscape/app/hark-graph-hook.hoon: | |
| +summarize | |
| urbit/pkg/landscape/app/graph-pull-hook.hoon: | |
| +state-nul | |
| urbit/pkg/landscape/app/sane.hoon: | |
| +report-many | |
| urbit/pkg/landscape/tests/lib/pull-hook-virt.hoon: | |
| +test-kick-mule | |
| +test-mule-scry-bad-ship | |
| +test-mule-scry-bad-time | |
| urbit/pkg/landscape/tests/lib/versioning.hoon: | |
| +test-append-version | |
| +test-current-version | |
| +test-is-root | |
| +test-read-version | |
| +test-supported | |
| urbit/pkg/landscape/lib/strandio.hoon: | |
| +check-online | |
| +send-cancel-request | |
| +take-watch | |
| +watch-one | |
| urbit/pkg/landscape/lib/group.hoon: | |
| +get-tagged-ships | |
| +scry-tag | |
| urbit/pkg/landscape/lib/jose.hoon: | |
| +eor | |
| urbit/pkg/landscape/lib/ethereum.hoon: | |
| +address-to-checksum | |
| +batch-read-request | |
| +encode-atoms | |
| +light-json-request | |
| +parse-eth-new-filter-res | |
| +parse-transaction-hash | |
| +sign-typed-transaction | |
| urbit/pkg/landscape/lib/hark-store.hoon: | |
| +binned-notification | |
| urbit/pkg/landscape/lib/pull-hook.hoon: | |
| +check-subscription | |
| +tr-leave-ver | |
| +version-dock | |
| urbit/pkg/landscape/lib/metadata.hoon: | |
| +app-paths-from-group | |
| +graphs-of-group | |
| +md-resources-from-group | |
| urbit/pkg/landscape/lib/test.hoon: | |
| +expect-success | |
| +run-chain | |
| urbit/pkg/landscape/lib/graph-store.hoon: | |
| +change-revision-graph | |
| +zero-load | |
| urbit/pkg/landscape/lib/ph/util.hoon: | |
| +expect-dojo-output | |
| urbit/pkg/landscape/lib/azimuth.hoon: | |
| +apply-point-diff | |
| +conditional-star-release | |
| +event-log-to-point-diff | |
| +function-to-call | |
| +parse-id | |
| urbit/pkg/landscape/lib/bip/b173.hoon: | |
| +encode-pubkey | |
| +from-address | |
| urbit/pkg/landscape/lib/bip/b158.hoon: | |
| +all-match | |
| urbit/pkg/landscape/lib/bip/b174.hoon: | |
| +get-txid | |
| urbit/pkg/landscape/lib/agentio.hoon: | |
| +kick-only | |
| +warp-slim | |
| urbit/pkg/landscape/lib/language-server/build.hoon: | |
| +get-errors-from-tang | |
| urbit/pkg/landscape/lib/language-server/complete.hoon: | |
| +advance-tape | |
| +search-exact | |
| urbit/pkg/landscape/lib/bitcoin-utils.hoon: | |
| +dea | |
| urbit/pkg/landscape/lib/gladio.hoon: | |
| +network-raw | |
| urbit/pkg/landscape/lib/bip32.hoon: | |
| +from-public-point | |
| +private-chain | |
| +prv-extended | |
| +pub-extended | |
| +public-chain | |
| urbit/pkg/landscape/lib/group-store.hoon: | |
| +invite-policy-diff | |
| +migrate-path-map | |
| +oj | |
| +open-policy-diff | |
| urbit/pkg/landscape/lib/server.hoon: | |
| +login-redirect | |
| +manx-response | |
| +woff2-response | |
| urbit/pkg/landscape/lib/sole.hoon: | |
| +remit | |
| urbit/pkg/landscape/lib/azimuthio.hoon: | |
| +fetch-point | |
| urbit/pkg/landscape/lib/keygen.hoon: | |
| +full-wallet-from-ticket | |
| urbit/pkg/arvo/mar/helm-hi.hoon: | |
| +psal | |
| urbit/pkg/arvo/ted/aqua/eyre.hoon: | |
| +take-sigh-tang | |
| urbit/pkg/arvo/sur/hood.hoon: | |
| +get-apps-live | |
| +read-bill | |
| +read-bill-foreign | |
| +report-kids | |
| urbit/pkg/arvo/sur/bitcoin.hoon: | |
| +op-checksig | |
| +op-dup | |
| +op-equalverify | |
| +op-hash160 | |
| +vbytes | |
| urbit/pkg/arvo/sur/dns-bind.hoon: | |
| +nameserver | |
| urbit/pkg/arvo/sur/sole.hoon: | |
| +sole-gen | |
| urbit/pkg/arvo/app/claz.hoon: | |
| +rpc-result | |
| urbit/pkg/arvo/app/azimuth.hoon: | |
| +nuke-azimuth-tracker | |
| urbit/pkg/arvo/app/language-server.hoon: | |
| +get-subject | |
| +lsp-req | |
| urbit/pkg/arvo/app/dbug.hoon: | |
| +poke-kill | |
| +poke-verb-toggle | |
| urbit/pkg/arvo/app/dojo.hoon: | |
| +bead | |
| +dy-made-noun | |
| +he-like | |
| +he-peer | |
| +he-stop | |
| +parse-iden-url | |
| urbit/pkg/arvo/gen/deco.hoon: | |
| +say-goodbye | |
| +say-minimum | |
| urbit/pkg/arvo/gen/tx.hoon: | |
| +domain-separator | |
| +mainnet-separator | |
| urbit/pkg/arvo/sys/lull.hoon: | |
| +by-clock | |
| +egg-any | |
| +hate | |
| +httq | |
| +ipa | |
| +live-packet | |
| +mizu | |
| +nuri | |
| +rout | |
| +saba | |
| +scar | |
| +sift-wail | |
| urbit/pkg/arvo/sys/hoon.hoon: | |
| +aftr | |
| +clef | |
| +colm | |
| +expk | |
| +expl | |
| +expu | |
| +expv | |
| +exqk | |
| +exqw | |
| +fuss | |
| +glop | |
| +jes | |
| +lfn | |
| +loon | |
| +lure | |
| +mare | |
| +maru | |
| +onyx | |
| +pi-heck | |
| +pi-noon | |
| +pi-tell | |
| +pock | |
| +pout | |
| +qad | |
| +reck | |
| +rta | |
| +rusk | |
| +seem | |
| +shad | |
| +shan | |
| +shaw | |
| +shf | |
| +slit | |
| +spn | |
| +succ | |
| +tony | |
| +ulva | |
| +voy | |
| +w-co | |
| +zig | |
| urbit/pkg/arvo/sys/vane/jael.hoon: | |
| +ez | |
| +get-source | |
| +message-result | |
| +order-events | |
| urbit/pkg/arvo/sys/vane/ames.hoon: | |
| +dip-left | |
| +fi-show | |
| +show-meow | |
| urbit/pkg/arvo/sys/vane/gall.hoon: | |
| +egg-any | |
| +mo-past | |
| +mo-slip | |
| urbit/pkg/arvo/sys/vane/clay.hoon: | |
| +all-fits | |
| +may-write | |
| +print-cult | |
| +run-pact | |
| +sort-by-head | |
| urbit/pkg/arvo/sys/vane/eyre.hoon: | |
| +request-is-logged-in | |
| urbit/pkg/arvo/sys/zuse.hoon: | |
| +apix | |
| +berk | |
| +bu | |
| +by-clock | |
| +cla | |
| +de-part | |
| +de-turf | |
| +de-urlt | |
| +drop-list | |
| +drop-map | |
| +drop-pole | |
| +explode-bytes | |
| +hmac-sha256t | |
| +keccak-224 | |
| +keccak-384 | |
| +keccak-512 | |
| +oj | |
| +rawshake-128 | |
| +rawshake-256 | |
| +sha3-224 | |
| +sha3-256 | |
| +sha3-384 | |
| +sha3-512 | |
| +shake-128 | |
| +shake-256 | |
| +to-capped-queue | |
| +trub | |
| +utfe | |
| +ypt | |
| urbit/pkg/arvo/lib/strandio.hoon: | |
| +check-online | |
| +send-cancel-request | |
| +take-watch | |
| +watch-one | |
| urbit/pkg/arvo/lib/pprint.hoon: | |
| +endfmt | |
| +render-all-hoons-inside-of-type | |
| +render-type-from-cord | |
| urbit/pkg/arvo/lib/deco.hoon: | |
| +default-jam | |
| +default-juice | |
| +say-goodbye | |
| +say-minimum | |
| urbit/pkg/arvo/lib/test/ames-gall.hoon: | |
| +ames-call | |
| +ames-check-call | |
| +ames-check-take | |
| +ames-scry-hunk | |
| +ames-scry-peer | |
| +gall-check-call | |
| +gall-check-take | |
| +gall-scry-nonce | |
| +nec-bud | |
| urbit/pkg/arvo/lib/jose.hoon: | |
| +eor | |
| urbit/pkg/arvo/lib/old-phon.hoon: | |
| +zig | |
| urbit/pkg/arvo/lib/pretty-file.hoon: | |
| +vale-cord | |
| urbit/pkg/arvo/lib/ethereum.hoon: | |
| +address-to-checksum | |
| +batch-read-request | |
| +encode-atoms | |
| +light-json-request | |
| +parse-eth-new-filter-res | |
| +parse-transaction-hash | |
| +sign-typed-transaction | |
| urbit/pkg/arvo/lib/number-to-words.hoon: | |
| +eng-us | |
| +to-words | |
| urbit/pkg/arvo/lib/naive-transactions.hoon: | |
| +gen-tx | |
| urbit/pkg/arvo/lib/test.hoon: | |
| +expect-success | |
| +run-chain | |
| urbit/pkg/arvo/lib/json/rpc.hoon: | |
| +request-to-hiss | |
| urbit/pkg/arvo/lib/ph/util.hoon: | |
| +expect-dojo-output | |
| urbit/pkg/arvo/lib/azimuth.hoon: | |
| +apply-point-diff | |
| +conditional-star-release | |
| +event-log-to-point-diff | |
| +function-to-call | |
| +parse-id | |
| urbit/pkg/arvo/lib/bip/b173.hoon: | |
| +encode-pubkey | |
| +from-address | |
| urbit/pkg/arvo/lib/bip/b158.hoon: | |
| +all-match | |
| urbit/pkg/arvo/lib/bip/b174.hoon: | |
| +get-txid | |
| urbit/pkg/arvo/lib/agentio.hoon: | |
| +kick-only | |
| +warp-slim | |
| urbit/pkg/arvo/lib/language-server/build.hoon: | |
| +get-errors-from-tang | |
| urbit/pkg/arvo/lib/language-server/complete.hoon: | |
| +advance-tape | |
| +search-exact | |
| urbit/pkg/arvo/lib/bitcoin-utils.hoon: | |
| +dea | |
| urbit/pkg/arvo/lib/bip32.hoon: | |
| +from-public-point | |
| +private-chain | |
| +prv-extended | |
| +pub-extended | |
| +public-chain | |
| urbit/pkg/arvo/lib/server.hoon: | |
| +login-redirect | |
| +manx-response | |
| +woff2-response | |
| urbit/pkg/arvo/lib/sole.hoon: | |
| +remit | |
| urbit/pkg/arvo/lib/azimuthio.hoon: | |
| +fetch-point | |
| urbit/pkg/arvo/lib/csv.hoon: | |
| +print-rows | |
| urbit/pkg/arvo/lib/keygen.hoon: | |
| +full-wallet-from-ticket |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bytes" | |
| "fmt" | |
| "io" | |
| "log" | |
| "os" | |
| spath "path" | |
| "sort" | |
| ) | |
| func forEachFile(path string, fn func(path string, data []byte)) error { | |
| f, err := os.Open(path) | |
| if err != nil { | |
| return err | |
| } | |
| defer f.Close() | |
| if stat, _ := f.Stat(); !stat.IsDir() { | |
| data, err := io.ReadAll(f) | |
| if err != nil { | |
| return err | |
| } | |
| fn(path, data) | |
| return nil | |
| } | |
| names, err := f.Readdirnames(-1) | |
| if err != nil { | |
| return err | |
| } | |
| for _, name := range names { | |
| forEachFile(path+"/"+name, fn) | |
| } | |
| return nil | |
| } | |
| func splitID(r rune) bool { | |
| switch { | |
| case '0' <= r && r <= '9': | |
| return false | |
| case 'a' <= r && r <= 'z': | |
| return false | |
| case r == '-': | |
| return false | |
| } | |
| return true | |
| } | |
| func splitArm(r rune) bool { | |
| return splitID(r) && (r != '+' && r != '$') | |
| } | |
| func main() { | |
| log.SetFlags(0) | |
| if len(os.Args) != 3 { | |
| log.Fatalf("Usage: %v [arm source dir] [usage dir]", os.Args[0]) | |
| } | |
| armsDir, usageDir := os.Args[1], os.Args[2] | |
| isArm := make(map[string]bool) | |
| forEachFile(armsDir, func(path string, data []byte) { | |
| fields := bytes.FieldsFunc(data, splitArm) | |
| for i, arm := range fields { | |
| // only match fields preceeded by ++ or +$ | |
| if i == 0 || (string(fields[i-1]) != "++" && string(fields[i-1]) != "+$") { | |
| continue | |
| } | |
| isArm[string(arm)] = true | |
| } | |
| }) | |
| counts := make(map[string]int) | |
| forEachFile(usageDir, func(path string, data []byte) { | |
| fields := bytes.FieldsFunc(data, splitArm) | |
| for i, arm := range fields { | |
| // ignore fields preceeded by ++ or +$ | |
| if i > 0 && (string(fields[i-1]) == "++" || string(fields[i-1]) == "+$") { | |
| continue | |
| } | |
| if isArm[string(arm)] { | |
| counts[string(arm)]++ | |
| } | |
| } | |
| }) | |
| forEachFile(armsDir, func(path string, data []byte) { | |
| var arms []string | |
| seen := make(map[string]bool) | |
| for _, arm := range bytes.FieldsFunc(data, splitID) { | |
| if isArm[string(arm)] && !seen[string(arm)] && counts[string(arm)] == 0 { | |
| arms = append(arms, string(arm)) | |
| seen[string(arm)] = true | |
| } | |
| } | |
| if len(arms) > 0 { | |
| sort.Strings(arms) | |
| fmt.Printf("%v:\n", spath.Clean(path)) | |
| for _, arm := range arms { | |
| fmt.Printf(" +%s\n", arm) | |
| } | |
| } | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment