Duplicate code detection across OCaml packages
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-linkedin: apply dune fmt

Pure formatting changes from `dune fmt`: doc comment placement moves
from above the binding to below it for `type`s, multi-line `match`
expressions collapse onto one line where they fit, and infix operator
applications pick up spaces (`Soup.($?)` -> `Soup.( $? )`). No
semantic changes.

+32 -4
+25 -4
README.md
··· 15 15 4. **Cluster** — Bindings with the same hash are grouped; cross-package 16 16 clusters are reported as clones 17 17 18 + ## Installation 19 + 20 + Install with opam: 21 + 22 + ```sh 23 + opam install dupfind 24 + ``` 25 + 26 + If opam cannot find the package, it may not yet be released in the public 27 + `opam-repository`. Add the overlay repository, then install it: 28 + 29 + ```sh 30 + opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git 31 + opam update 32 + opam install dupfind 33 + ``` 34 + 18 35 ## Usage 19 36 20 37 ### Find cross-package duplicates ··· 47 64 - A **qualified name** like `Module.func` — looks up the binding in the 48 65 scanned files, then finds all structural matches 49 66 - A **hex hash** (32 chars) — finds all bindings with that exact hash 50 - - An **inline OCaml expression** like `"let f x = x + 1"` — normalizes and 67 + - An **inline OCaml expression** like `" 68 + let f x = x + 1"` — normalizes and 51 69 hashes it, then searches for matches 52 70 53 71 ``` 54 72 $ dupfind find Encode.to_bytes src/ 55 73 $ dupfind find db4909941d07713e84ced7187adab6c8 src/ 56 - $ dupfind find "let f x = x + 1" src/ 74 + $ dupfind find " 75 + let f x = x + 1" src/ 57 76 ``` 58 77 59 78 ### Inspect the normalized AST and hash ··· 66 85 Useful for understanding how normalization works and debugging. 67 86 68 87 ``` 69 - $ dupfind hash "let f x = x + 1" 88 + $ dupfind hash " 89 + let f x = x + 1" 70 90 AST: fun _0 -> + _0 1 71 91 Hash: db4909941d07713e84ced7187adab6c8 72 92 73 - $ dupfind hash "let g y = y + 1" 93 + $ dupfind hash " 94 + let g y = y + 1" 74 95 AST: fun _0 -> + _0 1 75 96 Hash: db4909941d07713e84ced7187adab6c8 76 97 ```
+4
dune
··· 1 1 (env 2 2 (dev 3 3 (flags :standard %{dune-warnings}))) 4 + 5 + (mdx 6 + (files README.md) 7 + (libraries dupfind))
+2
dune-project
··· 1 1 (lang dune 3.21) 2 + (using mdx 0.4) 2 3 3 4 (name dupfind) 4 5 ··· 27 28 fpath 28 29 bos 29 30 re 31 + (mdx :with-test) 30 32 json memtrace))
+1
dupfind.opam
··· 20 20 "fpath" 21 21 "bos" 22 22 "re" 23 + "mdx" {with-test} 23 24 "json" 24 25 "memtrace" 25 26 "odoc" {with-doc}