Find and remove dead code and unused APIs in OCaml projects
at main 39 lines 1.4 kB view raw
1(** Symbol discovery and analysis orchestration for prune *) 2 3open Types 4 5(** {2 Main analysis orchestration} *) 6 7val unused_exports : 8 cache:Cache.t -> 9 ?exclude_dirs:string list -> 10 string -> 11 string list -> 12 ( (string * occurrence_info list) list * (string * occurrence_info list) list, 13 error ) 14 result 15(** [unused_exports ~cache ?exclude_dirs root_dir mli_files] finds unused 16 exports in the given .mli files within the project context. Returns 17 (unused_by_file, excluded_only_by_file) where: 18 - unused_by_file: symbols that are completely unused 19 - excluded_only_by_file: symbols that are only used in excluded directories. 20*) 21 22(** {2 Functions for other analysis tools} *) 23 24val all_symbol_occurrences : 25 cache:Cache.t -> 26 ?exclude_dirs:string list -> 27 string -> 28 string list -> 29 (occurrence_info list, error) result 30(** [all_symbol_occurrences ~cache ?exclude_dirs root_dir mli_files] gets 31 occurrence information for all symbols in the given .mli files. Unlike 32 find_unused_exports, this returns all symbols regardless of usage. *) 33 34(** {2 Internal functions exposed for testing} *) 35 36val filter_modules_with_used : 37 occurrence_info list -> occurrence_info list -> occurrence_info list 38(** [filter_modules_with_used unused_symbols all_occurrence_data] filters out 39 modules from the unused list that contain any used symbols. *)