Skip to content

Commit ed099dc

Browse files
committed
[docs][usage] proofread
+ Reformulation for clarity + Fix some links
1 parent 4280b09 commit ed099dc

File tree

1 file changed

+45
-31
lines changed

1 file changed

+45
-31
lines changed

docs/USAGE.md

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
+ [Stylistic issues](#stylistic-issues)
99
+ [Advanced usage](#advanced-usage)
1010
+ [Path-related options](#path-related-options)
11-
+ [`--exclude <path>`](#--exclude-<path>)
12-
+ [`--references <path>`](#--references-<path>)
11+
+ [`--exclude <path>`](#--exclude-path)
12+
+ [`--references <path>`](#--references-path)
1313
+ [Value-related options](#value-related-options)
1414
+ [`--underscore`](#--underscore)
1515
+ [`--internal`](#--internal)
16-
+ [Missing reports](#missing-reports)
16+
+ [Missing or invalid reports](#missing-or-invalid-reports)
1717
+ [`--verbose`](#--verbose)
1818
+ [Thresholds](#thresholds)
1919
+ [Thresholds on default reports](#thresholds-on-default-reports)
@@ -96,9 +96,11 @@ st be respected for the element to be reported
9696
To ease the usage of the tool to only focus on some kinds of reports, 2 options
9797
are available :
9898
- `--nothing` deactivates all the reports. One can then selectively activate the
99-
ones they are interested in using the corresponding options (see the sections below)
99+
ones they are interested in using the corresponding options (see the sections below).
100+
This is equivalent to `-E nothing -M nothing -T nothing -On nothing -Oa nothing -S -all`.
100101
- `--all` activates all the reports. One can then selectively deactivate the
101-
ones they are not interested in using the corresponding options (see the sections below)
102+
ones they are not interested in using the corresponding options (see the sections below).
103+
This is equivalent to `-E all -M all -T all -On all -Oa all -S +all`.
102104

103105
Activating or deactivating a report section actually activates or deactivates
104106
some parts of the analysis. Therefore, it impacts the cost (memory and time)
@@ -136,6 +138,10 @@ they are interested in by using respectively `-E all`, `-M all`, or `-T all`.
136138
unused exported values.
137139

138140
> [!Note]
141+
> `dead_code_analyzer <path>` is equivalent to
142+
> `dead_code_analyzer -E all -M all -T all <path>`.
143+
144+
> [!Warning]
139145
> Analyzing unused methods can be memory intensive.
140146
141147
## Optional arguments
@@ -146,25 +152,26 @@ As discussed in [the introduction](USER_DOC.md#introduction), another important
146152
focus of the `dead_code_analyzer` is on the optional arguments never or always used.
147153
Analyzing and reporting on those can be turned on using respectively `-On all`, or
148154
`-Oa all`. Similarly with the previous options, turning these reports off is
149-
done usising the `nothing` argument instead of `all`: respectively `-On nothing`,
155+
done using the `nothing` argument instead of `all`: respectively `-On nothing`,
150156
or `-Oa nothing`. Using `--nothing` or `--all` also affects these sections.
151157

152158
**Example :** `dead_code_analyzer --nothing -On all` will enable the analysis of
153159
optional arguments and only report those that are never used.
154160

155161
> [!Note]
156-
> Enabling the reporting for either the optional arguments never or always
157-
> used activates the same analysis which can be memory intensive.
162+
> Reporting for either the optional arguments never or always used actually
163+
> relies on the same analysis which can be memory intensive.
158164
159165
## Stylistic issues
160166

161167
**option :** `-S <warning>`
162168

163-
Finally, as a bonus, on can activate some stylistic reports by using `-S +all`.
169+
Finally, as a bonus, one can activate some stylistic reports by using `-S +all`.
164170
Notice the extra `+` before `all`. The `-S` option expects slightly different
165171
arguments from the previous options. Rather than expecting `all` or `nothing`,
166172
it expects a description of the desired stylistic issues to report, with `+`
167173
indicating a category to activate and `-` one to deactivate.
174+
Using `--nothing` or `--all` also affects this section.
168175

169176
**Example :** `dead_code_analyzer --nothing -S +all-bind` only reports stylistic issues,
170177
and reports all of them but the "useless binding" ones
@@ -199,45 +206,51 @@ src
199206

200207
### `--exclude <path>`
201208

202-
`dead_code_analyzer --nothing -E all src` will analyze and find unused exported
203-
values in all of `src`. Some reported values may point to locations in
204-
`src/debug/debug.ml`, adding noise because this module is actually used
205-
occasionnaly but no reference to it should subsist in production code.
209+
`dead_code_analyzer src` will analyze and find unused elements of code in all
210+
of `src`. Some reports may point to locations in `src/debug/debug.ml`, adding
211+
noise because this module is actually used occasionnaly but no reference to it
212+
should subsist in production code.
206213

207214
To ignore that module, both for declarations and uses, one can use the
208215
`--exclude <path>` option.
209216

210-
`dead_code_analyzer --nothing -E all --exclude src/debug src` only reports
211-
values outside of `src/debug`.
217+
`dead_code_analyzer --exclude src/debug src` only reports locations outside of
218+
`src/debug`.
212219

213220
### `--references <path>`
214221

215-
Using the previous command line, some reported values (e.g. located in
222+
Using the previous command line, some reported elements (e.g. located in
216223
`src/lib/lib.mli`) could be used by the `Debug` module. In this situation.
217224
In this case, completely excluding `src/debug` from the analysis leads to false
218225
positives (FP): invalid reports.
219226

220227
To fix the situation, one can use the `--references <path>` option. This option
221228
includes the `<path>` when observing uses.
222229

223-
`dead_code_analyzer --nothing -E all --exclude src/debug --references src/debug src`
224-
only reports values outside of `src/debug` and does not report values used by
230+
As a result, `dead_code_analyzer --exclude src/debug --references src/debug src`
231+
only reports elements outside of `src/debug` and does not report elements used by
225232
code in `src/debug`.
226233

227234
## Value-related options
228235

229236
### `--underscore`
230237

231238
The compiler ignores unused values when their names are prefixed with an
232-
underscore (e.g. `let _x = ...`). The `dead_code_analyzer` imitates that behavior. One can
233-
enable the analysis and reports on such names using the `--underscore` option.
239+
underscore (e.g. `let _x = ...`). The `dead_code_analyzer` imitates that
240+
behavior. One can enable the analysis and reports on such names using the
241+
`--underscore` option.
242+
243+
> [!Note]
244+
> This behavior (ignoring names starting with underscore) is not only limited
245+
> to unused exported values but applied to all the report kinds. Thus, they are
246+
> all affected by the `--underscore` option.
234247
235248
### `--internal`
236249

237250
The compiler already warns the user about unused values that are not exported.
238251
That is, values that are not exposed in the signature of a module. In case no
239252
interface is available, all the toplevel declaration are exported. Consequently,
240-
none of them can be reported unused by the compiler. In order to complement the
253+
none of them can be reported by the compiler. In order to complement the
241254
compiler well, and fit some coding habits, the `dead_code_analyzer` keeps track
242255
of internal uses in implementations (`.ml`) without corresponding interfaces (`.mli`).
243256

@@ -275,15 +288,16 @@ all (can be removed from the codebase).
275288
(* foo.mli *)
276289
val f : 'a -> 'a
277290
```
278-
Using the `--internal` option, the `dead_code_analyzer` will not report `f`
291+
By using the `--internal` option, the `dead_code_analyzer` will not report `f`
279292
as unused anymore.
280293
281-
## Missing reports
294+
## Missing or invalid reports
282295
283296
### `--verbose`
284297
285-
When using the `dead_code_analyzer`, on may encounter false negatives (FN):
286-
missing reports. In this case, chances are that some files were not analyzed.
298+
When using the `dead_code_analyzer`, one may encounter false negatives (FN):
299+
missing reports. Users may also encounter false positives (FP): invlaid reports.
300+
In both cases, chances are that some files were not analyzed.
287301
An easy way to see the list of analyzed files is by using the `--verbose` option.
288302
This will print out `Scanning <file_path>` for every file it tries to read.
289303
In case there is an issue reading the file, then it prints out a second line
@@ -305,7 +319,7 @@ welcome.
305319
306320
In addition to activating/deactivating some reports, one can extend the details
307321
of the reports using thresholds. The idea with thresholds is to not only report
308-
unused elements of code but also reports almost unused ones, up to a desired
322+
unused elements of code but also report almost unused ones, up to a desired
309323
maximum amount: the threshold.
310324
311325
For the 3 default reports (exported values, methods, and constructors and record
@@ -325,14 +339,14 @@ twice.
325339
326340
The threshold argument has an ever more detailed variant : `calls:<int>`. This
327341
time, the subreports will not only indicate the elements used exactly `n` times
328-
but also display the locations where they are used.
342+
but also display the locations of their use.
329343
330-
#### Thresholds on optional arguments
344+
### Thresholds on optional arguments
331345
332346
**options :** `-On <display>`, `-Oa <display>`
333347
334-
Optional arguments always/never used options also accept a `threshold` argument.
335-
However it looks a bit different from the one for the default reports.
348+
The options for optional arguments always/never used also accept a `threshold`
349+
argument. However it looks a bit different from the one for the default reports.
336350
Instead of using `threshold:<int>`, there are 2 different modes available:
337351
`percent:<float>` and `both:<int>,<float>` with `0.0 <= <float> <= 1.0` and
338352
`0 <= <int>`.
@@ -354,7 +368,7 @@ and at least the provided percent of the time.
354368
arguments always used, and those unused at most once but used at least 90% of
355369
the time.
356370
357-
> [!Note]
371+
> [!Tip]
358372
> Using `0` for `<float>` provides the same effect as the `threshold:<int>`
359373
> argument for the default reports.
360374
>

0 commit comments

Comments
 (0)