Skip to content

Commit 9078290

Browse files
committed
[docs][methods][2/n] add immediate object example
This demonstrates the use by explicit references and use by requirements. It also shows that unused methods can coexist with unused values.
1 parent ae9ee1e commit 9078290

File tree

17 files changed

+495
-12
lines changed

17 files changed

+495
-12
lines changed

check/classic/classic.exp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
./examples/docs/exported_values/hello_world/hello_world_with_intf.mli:3: goodbye
2626
./examples/docs/exported_values/hello_world/hello_world_with_intf.mli:4: world
2727

28+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj
29+
2830
./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused
2931
./examples/using_dune/preprocessed_lib/preprocessed.mli:3: internally_used
3032
./examples/using_dune/preprocessed_lib/preprocessed.mli:38: internally_used_f
@@ -146,6 +148,9 @@ Nothing else to report in this section
146148

147149
.> UNUSED METHODS:
148150
=================
151+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj#unused_method
152+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#reset
153+
149154
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused
150155
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused
151156

check/classic/classic.ref

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
./examples/docs/exported_values/hello_world/hello_world_with_intf.mli:3: goodbye
2727
./examples/docs/exported_values/hello_world/hello_world_with_intf.mli:4: world
2828

29+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj
30+
2931
./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused
3032
./examples/using_dune/preprocessed_lib/preprocessed.mli:3: internally_used
3133
./examples/using_dune/preprocessed_lib/preprocessed.mli:38: internally_used_f
@@ -147,6 +149,9 @@ Nothing else to report in this section
147149

148150
.> UNUSED METHODS:
149151
=================
152+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj#unused_method
153+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#reset
154+
150155
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused
151156
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused
152157

@@ -617,7 +622,7 @@ Nothing else to report in this section
617622
--------------------------------------------------------------------------------
618623

619624

620-
Total: 531
621-
Success: 530
625+
Total: 534
626+
Success: 533
622627
Failed: 1
623-
Ratio: 99.8116760829%
628+
Ratio: 99.8127340824%

check/internal/internal.exp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
./examples/docs/exported_values/code_constructs/module/module_lib.mli:6: M.unused
1717

18+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj
19+
1820
./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused
1921
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:2: unused
2022

@@ -101,6 +103,9 @@ Nothing else to report in this section
101103

102104
.> UNUSED METHODS:
103105
=================
106+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj#unused_method
107+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#reset
108+
104109
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused
105110
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused
106111

check/internal/internal.ref

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
./examples/docs/exported_values/code_constructs/module/module_lib.mli:6: M.unused
1818

19+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj
20+
1921
./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused
2022
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:2: unused
2123

@@ -102,6 +104,9 @@ Nothing else to report in this section
102104

103105
.> UNUSED METHODS:
104106
=================
107+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj#unused_method
108+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#reset
109+
105110
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused
106111
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused
107112

@@ -572,7 +577,7 @@ Nothing else to report in this section
572577
--------------------------------------------------------------------------------
573578

574579

575-
Total: 489
576-
Success: 488
580+
Total: 492
581+
Success: 491
577582
Failed: 1
578-
Ratio: 99.7955010225%
583+
Ratio: 99.7967479675%

check/threshold-1/threshold-1.exp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
./examples/docs/exported_values/code_constructs/module/module_lib.mli:6: M.unused
1717

18+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj
19+
1820
./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused
1921
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:2: unused
2022

@@ -131,6 +133,9 @@
131133
./examples/docs/exported_values/hello_world/hello_world_without_intf.ml:2: hello
132134
./examples/docs/exported_values/hello_world/hello_world_without_intf.ml:3: goodbye
133135

136+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:6: push_n_times
137+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:12: clear_stack
138+
134139
./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed.mli:1: mark_used
135140
./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_lib.mli:1: mark_used
136141
./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_no_intf.mli:1: mark_used
@@ -336,6 +341,9 @@ Nothing else to report in this section
336341

337342
.> UNUSED METHODS:
338343
=================
344+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj#unused_method
345+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#reset
346+
339347
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused
340348
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused
341349

@@ -396,6 +404,10 @@ Nothing else to report in this section
396404

397405
.>-> ALMOST UNUSED METHODS: Called 1 time(s):
398406
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#peek
408+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#pop
409+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#push
410+
399411
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used
400412
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used
401413
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used

check/threshold-1/threshold-1.ref

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
./examples/docs/exported_values/code_constructs/module/module_lib.mli:6: M.unused
1818

19+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj
20+
1921
./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused
2022
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:2: unused
2123

@@ -135,6 +137,9 @@
135137
./examples/docs/exported_values/hello_world/hello_world_without_intf.ml:2: hello
136138
./examples/docs/exported_values/hello_world/hello_world_without_intf.ml:3: goodbye
137139

140+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:6: push_n_times
141+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:12: clear_stack
142+
138143
./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed.mli:1: mark_used
139144
./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_lib.mli:1: mark_used
140145
./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_no_intf.mli:1: mark_used
@@ -340,6 +345,9 @@ Nothing else to report in this section
340345

341346
.> UNUSED METHODS:
342347
=================
348+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj#unused_method
349+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#reset
350+
343351
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused
344352
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused
345353

@@ -400,6 +408,10 @@ Nothing else to report in this section
400408

401409
.>-> ALMOST UNUSED METHODS: Called 1 time(s):
402410
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
411+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#peek
412+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#pop
413+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#push
414+
403415
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used
404416
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used
405417
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used
@@ -950,7 +962,7 @@ Nothing else to report in this section
950962
--------------------------------------------------------------------------------
951963

952964

953-
Total: 821
954-
Success: 817
965+
Total: 829
966+
Success: 825
955967
Failed: 4
956-
Ratio: 99.5127892814%
968+
Ratio: 99.517490953%

check/threshold-3-0.5/threshold-3-0.5.exp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
./examples/docs/exported_values/code_constructs/module/module_lib.mli:6: M.unused
1717

18+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj
19+
1820
./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused
1921
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:2: unused
2022

@@ -131,6 +133,9 @@
131133
./examples/docs/exported_values/hello_world/hello_world_without_intf.ml:2: hello
132134
./examples/docs/exported_values/hello_world/hello_world_without_intf.ml:3: goodbye
133135

136+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:6: push_n_times
137+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:12: clear_stack
138+
134139
./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed.mli:1: mark_used
135140
./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_lib.mli:1: mark_used
136141
./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_no_intf.mli:1: mark_used
@@ -345,6 +350,8 @@
345350
./examples/docs/exported_values/hello_world/hello_world_with_intf.mli:4: world
346351
./examples/docs/exported_values/hello_world/hello_world_without_intf.ml:4: world
347352

353+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack
354+
348355
./examples/using_dune/preprocessed_lib/preprocessed.mli:2: used
349356
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: exported_f
350357
./examples/using_dune/preprocessed_lib/preprocessed.mli:38: internally_used_f
@@ -471,6 +478,9 @@ Nothing else to report in this section
471478

472479
.> UNUSED METHODS:
473480
=================
481+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj#unused_method
482+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#reset
483+
474484
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused
475485
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused
476486

@@ -531,6 +541,10 @@ Nothing else to report in this section
531541

532542
.>-> ALMOST UNUSED METHODS: Called 1 time(s):
533543
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
544+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#peek
545+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#pop
546+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#push
547+
534548
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used
535549
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used
536550
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used
@@ -597,6 +611,10 @@ Nothing else to report in this section
597611

598612
.>-> ALMOST UNUSED METHODS: Called 2 time(s):
599613
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
614+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:2: counter#get
615+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:2: counter#incr
616+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:2: counter#reset
617+
600618
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#used
601619
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#used
602620

check/threshold-3-0.5/threshold-3-0.5.ref

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
./examples/docs/exported_values/code_constructs/module/module_lib.mli:6: M.unused
1818

19+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj
20+
1921
./examples/using_dune/preprocessed_lib/preprocessed.mli:1: unused
2022
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:2: unused
2123

@@ -135,6 +137,9 @@
135137
./examples/docs/exported_values/hello_world/hello_world_without_intf.ml:2: hello
136138
./examples/docs/exported_values/hello_world/hello_world_without_intf.ml:3: goodbye
137139

140+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:6: push_n_times
141+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:12: clear_stack
142+
138143
./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed.mli:1: mark_used
139144
./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_lib.mli:1: mark_used
140145
./examples/using_dune/bin/use_preprocessed_lib/use_preprocessed_no_intf.mli:1: mark_used
@@ -349,6 +354,8 @@
349354
./examples/docs/exported_values/hello_world/hello_world_with_intf.mli:4: world
350355
./examples/docs/exported_values/hello_world/hello_world_without_intf.ml:4: world
351356

357+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack
358+
352359
./examples/using_dune/preprocessed_lib/preprocessed.mli:2: used
353360
./examples/using_dune/preprocessed_lib/preprocessed.mli:31: exported_f
354361
./examples/using_dune/preprocessed_lib/preprocessed.mli:38: internally_used_f
@@ -475,6 +482,9 @@ Nothing else to report in this section
475482

476483
.> UNUSED METHODS:
477484
=================
485+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_bin.ml:2: unused_obj#unused_method
486+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#reset
487+
478488
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#unused
479489
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#unused
480490

@@ -535,6 +545,10 @@ Nothing else to report in this section
535545

536546
.>-> ALMOST UNUSED METHODS: Called 1 time(s):
537547
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
548+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#peek
549+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#pop
550+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:8: int_stack#push
551+
538552
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#externally_used
539553
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#internally_used
540554
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#externally_used
@@ -601,6 +615,10 @@ Nothing else to report in this section
601615

602616
.>-> ALMOST UNUSED METHODS: Called 2 time(s):
603617
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
618+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:2: counter#get
619+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:2: counter#incr
620+
./examples/docs/methods/code_constructs/imm_obj/imm_obj_lib.mli:2: counter#reset
621+
604622
./examples/using_dune/preprocessed_lib/preprocessed.mli:6: immediate#used
605623
./examples/using_dune/preprocessed_lib/preprocessed_no_intf.ml:12: immediate#used
606624

@@ -1346,7 +1364,7 @@ Nothing else to report in this section
13461364
--------------------------------------------------------------------------------
13471365

13481366

1349-
Total: 1138
1350-
Success: 1134
1367+
Total: 1150
1368+
Success: 1146
13511369
Failed: 4
1352-
Ratio: 99.6485061511%
1370+
Ratio: 99.652173913%

docs/methods/METHODS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,15 @@ from the `.mli` if there is one and the `.ml`.
130130
> of new unused methods, or remove some for values of object types.
131131
> Consequently, it is expected that a user might need to compile and analyze
132132
> their code multiple times when cleaning up their codebase.
133+
134+
# Examples
135+
136+
- The [code constructs](./code_constructs) directory contains a collection of
137+
examples dedicated to specific code constructs :
138+
- [Immediate object](./code_constructs/IMMEDIATE_OBJ.md)
139+
140+
[TODO]: # (
141+
- [Class](./code_constructs/CLASS.md)
142+
- [Class type](./code_constructs/CLASS_TYPE.md)
143+
- [Inheritance](./code_constructs/INHERITANCE.md)
144+
)

0 commit comments

Comments
 (0)