ocaml / ocaml/dune

Warn if there are files not covered by rules?

Open
#3,943 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

acknowledged
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

Desired Behavior

If there are files that look like they should be compiled (say *.ml) but they are not matched by any rule, I would like to receive a warning.

A stronger requirement may be to list all «extra files» and give an error for any unexpected file. This feature may be hidden behind a flag.

Why?
  • Detect dead code.
  • Make sure all tests execute.

Example

% tree
├── examples/
│   ├── .merlin
│   ├── dune
│   ├── i_am_failing.ml
│   └── i_am_succeeding.ml
. . .

% cat examples/dune
(tests
  (names i_am_succeeding)
  . . .
)

Here, a test has been written but I forgot to add it to the dune file. There is an impression of success, and a fault is missed.

Discussion

There is already an error when some extra files are present. (See #3933.) But it is not really motivated. The feature I propose here, on the opposite, has a good reason to exist.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing extra-files error referenced in #3933 and the example rules in examples/dune. Define how Dune should identify source-like files such as .ml that match no rule, and whether reporting is a warning or a flag-controlled error. Done means the omitted test is surfaced without changing the behavior of matched files.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.