Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here


Dead-code analyzer for OCaml

Subscribe to updates I use dead_code_analyzer

Statistics on dead_code_analyzer

Number of watchers on Github 52
Number of open issues 3
Main language OCaml
Average time to merge a PR 14 days
Open pull requests 1+
Closed pull requests 3+
Last commit about 3 years ago
Repo Created over 5 years ago
Repo Last Updated over 2 years ago
Size 533 KB
Organization / Authorlexifi
Page Updated
Do you use dead_code_analyzer? Leave a review!
View open issues (3)
View dead_code_analyzer activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating dead_code_analyzer for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

dead code analyzer

Dead-code analyzer for OCaml


The tool assumes that .mli files are compiled with -keep-locs and .ml files with -bin-annot. Exported values are collected by reading .cmi or .cmt files (depending on the existence of an explicit .mli interface). References to such values are collected by reading typed trees from .cmt files

This tool scans a compiled OCaml project and reports various warnings about suspicious code:

  • Exported values never used. (The declaration can be dropped from the interface, and then from the implementation if there is no internal use -- which will be reported by standard OCaml warnings).

  • Types fields and constructors never used. (Can be dropped from the type)

  • Class fields never used. (Can be dropped from the signature)

  • Optional arguments for which either all call sites or none of them provide a value (other than None). (The argument can be made mandatory or dropped.)

  • Other stylistic issues: patterns matching a value of type unit which are not () (typically, _ or a variable); let-binding let () = ... in ... (it's usually better to use sequencing); let-binding of the form let x = ... in x (the binding is useless); optional argument in argument's type: val f: ... -> (... -> ?_:_ -> ...) -> ...


  • Currently tested and working on OCaml 4.05.0+trunk



opam install dead_code_analyzer


  1. Download the sources.
  2. Build by either
    • running make to generate the dead_code_analyzer.byt bytecode executable file;
    • running make opt to generate the dead_code_analyzer.opt native-code executable file. Both will be produced in the build directory.


dead_code_analyzer.<byt|opt> <options> <path>

The given paths can be files and directories. For more information about the usage, use the -help option.


To run the tests use make check. For each subset of the tests a file <subset>.out is generated, containg the output of the execution on it.

To run a subset of the tests call make -C check <subset>.


Running make doc will produce the documentation as html files in the doc directory.

Running make man will produce documentation as man pages in the man/man3 directory.


You are welcome to clone this repository and send us back pull requests.

Read CONTRIBUTING.md at the root of this directory for more informations on how to contribute.


The project is used internally at LexiFi.

There has been no official release yet.


Tracking the optional arguments uses may consume a lot of memory. Tracking the methods uses may consume a lot of memory.


Source code is distributed under the conditions stated in file License


This project was initiated by LexiFi (http://www.lexifi.com) and is part of the SecurOCaml project.

Contact: alain.frisch@lexifi.com

dead_code_analyzer open pull requests (View All Pulls)
  • Ignore deprecated values
dead_code_analyzer list of languages used
More projects by LexiFi View all
Other projects in OCaml