Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "5.2"
ocaml-compiler: "5.3"

- run: opam install . --deps-only --with-test

Expand All @@ -45,7 +45,7 @@ jobs:
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "5.2"
ocaml-compiler: "5.3"
- uses: ocaml/setup-ocaml/lint-doc@v3

lint-opam:
Expand All @@ -56,5 +56,5 @@ jobs:
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "5.2"
ocaml-compiler: "5.3"
- uses: ocaml/setup-ocaml/lint-opam@v3
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Dead-code analyzer for OCaml
## Overview

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 with **-bin-annot**. Exported values are collected by reading .cmti 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

Expand Down Expand Up @@ -38,7 +38,7 @@ For more information, see [the documentation](docs/USER_DOC.md)

## Requirements

- Currently tested and working on **OCaml 5.2**
- Currently tested and working on **OCaml 5.3**


## Install
Expand Down
4 changes: 0 additions & 4 deletions check/threshold-3-0.5/threshold-3-0.5.ref
Original file line number Diff line number Diff line change
Expand Up @@ -1051,12 +1051,9 @@ Nothing else to report in this section
./examples/using_make/dir/anonFn2.mli:2: ?a (2/3 calls)
./examples/using_make/dir/anonFn2.mli:2: ?b (2/3 calls)
./examples/using_make/dir/match_opt.ml:1: ?b (2/3 calls)

./examples/using_make/dir/matchopt.ml:1: ?x (3/4 calls)

./examples/using_make/dir/ref_fn.ml:1: ?a (2/3 calls)
./examples/using_make/dir/ref_fn.ml:1: ?b (2/3 calls)

./examples/using_make/matchopt.ml:1: ?x (3/4 calls)

./examples/using_make/opt/sig_struct.ml:2: ?x (2/3 calls)
Expand Down Expand Up @@ -1252,7 +1249,6 @@ Nothing else to report in this section
./examples/using_make/dir/anonFn.mli:3: ?a (1/2 calls)
./examples/using_make/dir/anonFn.mli:3: ?b (1/2 calls)
./examples/using_make/dir/anonFn2.mli:1: ?b (2/3 calls)

./examples/using_make/dir/matchopt.ml:1: ?y (3/4 calls)
./examples/using_make/dir/matchopt.ml:1: ?z (3/4 calls)
./examples/using_make/let_in.ml:1: ?b (2/3 calls)
Expand Down
2 changes: 1 addition & 1 deletion dead_code_analyzer.opam
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ homepage: "https://github.com/LexiFi/dead_code_analyzer"
bug-reports: "https://github.com/LexiFi/dead_code_analyzer/issues"
depends: [
"dune" {>= "3.20"}
"ocaml" {>= "5.2" & < "5.3"}
"ocaml" {>= "5.3" & < "5.4"}
"odoc" {with-doc}
]
build: [
Expand Down
14 changes: 7 additions & 7 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
Calling `dead_code_analyzer --help` provides the following output, describing
the main command line aspect, different options available and their effects.

The `<path>` argument is any number of directory, `.cmt` and `.cmi` files.
The `<path>` argument is any number of directory, `.cmt` and `.cmti` files.
These files can be produced using the compiler flags `-keep-locs` (on by default)
for `.cmi` and `-bin-annot` for `.cmt`.
for `.cmti` and `-bin-annot` for `.cmt`.
The directories are traversed looking for such files.
> [!TIP]
> If you are using `dune` for your project, the files can be obtained via the
Expand Down Expand Up @@ -190,15 +190,15 @@ the development.
```
src
├── debug
│   ├── debug.cmi
│   ├── debug.cmti
│   ├── debug.cmt
│   └── debug.ml
├── foo.cmi
├── foo.cmti
├── foo.cmt
├── foo.ml
├── foo.mli
└── lib
├── lib.cmi
├── lib.cmti
├── lib.cmt
├── lib.ml
└── lib.mli
Expand Down Expand Up @@ -306,9 +306,9 @@ the file and moves on.

- If a file is ignored and it is not obvious why, then opening an issue is
welcome.
- If no file is ignored, check that no file is missing. There should be a `.cmi`
- If no file is ignored, check that no file is missing. There should be a `.cmti`
and a `.cmt` file for each expected `<file_path>`.
- If no `.cmi` or `.cmt` file is missing then the false negatives must be due
- If no `.cmti` or `.cmt` file is missing then the false negatives must be due
to limitations of the tool and opening an issue is welcome.

## Thresholds
Expand Down
33 changes: 16 additions & 17 deletions docs/exported_values/HELLO_WORLD.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ without any external use.
The reference file for this example is
[`hello_world_without_intf.ml`](../../examples/docs/exported_values/hello_world/hello_world_without_intf.ml).

The compilation command to produce `hello_world_without_intf.cmi` and
`hello_world_without_intf.cmt` is :
The compilation command to produce `hello_world_without_intf.cmt` is :
```
ocamlopt -bin-annot hello_world_without_intf.ml
```

The analysis command is :
```
dead_code_analyzer --nothing -E all hello_world_without_intf.cmi hello_world_without_intf.cmt
dead_code_analyzer --nothing -E all hello_world_without_intf.cmt
```

## First run
Expand Down Expand Up @@ -62,7 +61,7 @@ reported location: `File "hello_world_without_intf.ml", line 8`

Analyze :
```
$ dead_code_analyzer --nothing -E all hello_world_without_intf.cmi hello_world_without_intf.cmt
$ dead_code_analyzer --nothing -E all hello_world_without_intf.cmt
Scanning files...
[DONE]

Expand Down Expand Up @@ -100,7 +99,7 @@ Compile and analyze :
```
$ ocamlopt -bin-annot hello_world_without_intf.ml

$ dead_code_analyzer --nothing -E all hello_world_without_intf.cmi hello_world_without_intf.cmt
$ dead_code_analyzer --nothing -E all hello_world_without_intf.cmt
Scanning files...
[DONE]

Expand Down Expand Up @@ -136,7 +135,7 @@ Compile and analyze :
```
$ ocamlopt -bin-annot hello_world_without_intf.ml

$ dead_code_analyzer --nothing -E all hello_world_without_intf.cmi hello_world_without_intf.cmt
$ dead_code_analyzer --nothing -E all hello_world_without_intf.cmt
Scanning files...
[DONE]

Expand All @@ -160,14 +159,14 @@ The reference files for this example are
[`hello_world_with_intf.mli`](../../examples/docs/exported_values/hello_world/hello_world_with_intf.mli) and
[`hello_world_with_intf.ml`](../../examples/docs/exported_values/hello_world/hello_world_with_intf.ml)

The compilation command to produce `hello_world.cmi` and `hello_world.cmt` is :
The compilation command to produce `hello_world.cmti` and `hello_world.cmt` is :
```
ocamlopt -bin-annot hello_world_with_intf.mli hello_world_with_intf.ml
```

The analysis command is :
```
dead_code_analyzer --nothing -E all hello_world.cmi hello_world.cmt
dead_code_analyzer --nothing -E all hello_world.cmti hello_world.cmt
```

## First run
Expand Down Expand Up @@ -199,7 +198,7 @@ File "hello_world_with_intf.ml", line 8, characters 6-19:
^^^^^^^^^^^^^
Warning 26 [unused-var]: unused variable goodbye_world.

$ dead_code_analyzer --nothing -E all hello_world.cmi hello_world.cmt
$ dead_code_analyzer --nothing -E all hello_world.cmti hello_world.cmt
Scanning files...
[DONE]

Expand Down Expand Up @@ -246,7 +245,7 @@ let () =
Compile and analyze :
```
$ ocamlopt -bin-annot hello_world_with_intf.ml
$ dead_code_analyzer --nothing -E all hello_world.cmi hello_world.cmt
$ dead_code_analyzer --nothing -E all hello_world.cmti hello_world.cmt
Scanning files...
[DONE]

Expand Down Expand Up @@ -284,14 +283,14 @@ The reference files for this example are
[`hello_world_lib.ml`](../../examples/docs/exported_values/hello_world/hello_world_lib.ml), and
[`hello_world_bin.ml`](../../examples/docs/exported_values/hello_world/hello_world_bin.ml)

The compilation command to produce the necessary `.cmi` and `.cmt` files is :
The compilation command to produce the necessary `.cmti` and `.cmt` files is :
```
ocamlopt -bin-annot hello_world_lib.mli hello_world_lib.ml hello_world_bin.ml
```

The analysis command is :
```
dead_code_analyzer --nothing -E all hello_world_lib.cmi hello_world_lib.cmt hello_world_bin.cmi hello_world_bin.cmt
dead_code_analyzer --nothing -E all hello_world_lib.cmti hello_world_lib.cmt hello_world_bin.cmti hello_world_bin.cmt
```

> [!NOTE]
Expand Down Expand Up @@ -330,7 +329,7 @@ File "hello_world_bin.ml", line 5, characters 6-19:
^^^^^^^^^^^^^
Warning 26 [unused-var]: unused variable goodbye_world.

$ dead_code_analyzer --nothing -E all hello_world_lib.cmi hello_world_lib.cmt hello_world_bin.cmi hello_world_bin.cmt
$ dead_code_analyzer --nothing -E all hello_world_lib.cmti hello_world_lib.cmt hello_world_bin.cmti hello_world_bin.cmt
Scanning files...
[DONE]

Expand Down Expand Up @@ -383,7 +382,7 @@ Compile and analyze :
```
$ ocamlopt -bin-annot hello_world_lib.mli hello_world_lib.ml hello_world_bin.ml

$ dead_code_analyzer --nothing -E all hello_world_lib.cmi hello_world_lib.cmt hello_world_bin.cmi hello_world_bin.cmt
$ dead_code_analyzer --nothing -E all hello_world_lib.cmti hello_world_lib.cmt hello_world_bin.cmti hello_world_bin.cmt
Scanning files...
[DONE]

Expand Down Expand Up @@ -425,7 +424,7 @@ Compile and analyze :
```
$ ocamlopt -bin-annot hello_world_lib.mli hello_world_lib.ml hello_world_bin.ml

$ dead_code_analyzer --nothing -E all hello_world_lib.cmi hello_world_lib.cmt hello_world_bin.cmi hello_world_bin.cmt
$ dead_code_analyzer --nothing -E all hello_world_lib.cmti hello_world_lib.cmt hello_world_bin.cmti hello_world_bin.cmt
Scanning files...
[DONE]

Expand Down Expand Up @@ -458,7 +457,7 @@ reach a satisfying codebase.

The reference files for this example are all those listed previously.

The compilation command to produce the necessary `.cmi` and `.cmt` files,
The compilation command to produce the necessary `.cmti` and `.cmt` files,
and the desired warnings is the combination of all the previous ones :
```
ocamlopt -w +32 -bin-annot hello_world_without_intf.ml hello_world_with_intf.mli hello_world_with_intf.ml hello_world_lib.mli hello_world_lib.ml hello_world_bin.ml
Expand All @@ -476,7 +475,7 @@ dead_code_analyzer --nothing -E all .

> [!TIP]
> As we can see in the compilation command, there is a large number of files to
> list. Instead of listing all the `.cmi` and `.cmt` files in the command line,
> list. Instead of listing all the `.cmti` and `.cmt` files in the command line,
> the analyzer accepts directories as arguments and will analyze all the
> relevant files it can find in them.

Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
(synopsis "Dead code analyzer for OCaml")
(license MIT)
(depends
(ocaml (and (>= 5.2) (< 5.3)))
(ocaml (and (>= 5.3) (< 5.4)))
)
)
2 changes: 1 addition & 1 deletion src/config/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ let normalize_path path =

let rec add_filepaths acc path =
match Utils.Filepath.kind ~exclude:(fun _ -> false) path with
| Cmi | Cmt -> Utils.StringSet.add path acc
| Cmti | Cmt_without_mli | Cmt_with_mli -> Utils.StringSet.add path acc
| Dir ->
Sys.readdir path
|> Array.fold_left
Expand Down
Loading