Skip to content

Commit 84e250e

Browse files
committed
Apply ocplint recommandations
1 parent fae7a7d commit 84e250e

18 files changed

+424
-130
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# jbuilder working directory
22
_build/
33

4+
# ocplint working directory
5+
_olint/
6+
47
# Autogenerated files
58
**/.merlin
69
**/*.install

.ocplint

+289
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
1+
2+
3+
(*************************************)
4+
(* Never edit options files while *)
5+
(* the program is running *)
6+
(*************************************)
7+
(* SECTION : Header *)
8+
(* These options must be read first *)
9+
(*************************************)
10+
11+
12+
13+
(* [ignore]: Module to ignore during the lint. *)
14+
ignore = [
15+
]
16+
17+
(* [db_persistence]: Time before erasing cached results (in days). *)
18+
db_persistence = 1
19+
plugin_typedtree = {
20+
21+
(* [enabled]: A plugin with linters on typed tree. *)
22+
enabled = true
23+
fully_qualified_identifiers = {
24+
25+
(* [enabled]: Enable/Disable linter "Fully-Qualified Identifiers". *)
26+
enabled = true
27+
28+
(* [ignore]: Module to ignore durint the lint of "Fully-Qualified Identifiers" *)
29+
ignore = [
30+
]
31+
32+
(* [warnings]: Enable/Disable warnings from "Fully-Qualified Identifiers" *)
33+
warnings = "+A"
34+
ignored_modules = [
35+
Pervasives;
36+
Opal;
37+
]
38+
ignore_operators = true
39+
ignore_depth = 2
40+
}
41+
polymorphic_function = {
42+
43+
(* [enabled]: Enable/Disable linter "Polymorphic function". *)
44+
enabled = true
45+
46+
(* [ignore]: Module to ignore durint the lint of "Polymorphic function" *)
47+
ignore = [
48+
]
49+
50+
(* [warnings]: Enable/Disable warnings from "Polymorphic function" *)
51+
warnings = "+A"
52+
}
53+
}
54+
plugin_text = {
55+
56+
(* [enabled]: A plugin with linters on the source. *)
57+
enabled = true
58+
code_length = {
59+
60+
(* [enabled]: Enable/Disable linter "Code Length". *)
61+
enabled = true
62+
63+
(* [ignore]: Module to ignore durint the lint of "Code Length" *)
64+
ignore = [
65+
]
66+
67+
(* [warnings]: Enable/Disable warnings from "Code Length" *)
68+
warnings = "+A"
69+
70+
(* [max_line_length]: Maximum line length *)
71+
max_line_length = 80
72+
}
73+
useless_space_line = {
74+
75+
(* [enabled]: Enable/Disable linter "Useless space character and empty line at the end of file.". *)
76+
enabled = true
77+
78+
(* [ignore]: Module to ignore durint the lint of "Useless space character and empty line at the end of file." *)
79+
ignore = [
80+
]
81+
82+
(* [warnings]: Enable/Disable warnings from "Useless space character and empty line at the end of file." *)
83+
warnings = "+A"
84+
}
85+
not_that_char = {
86+
87+
(* [enabled]: Enable/Disable linter "Detect use of unwanted chars in files". *)
88+
enabled = true
89+
90+
(* [ignore]: Module to ignore durint the lint of "Detect use of unwanted chars in files" *)
91+
ignore = [
92+
]
93+
94+
(* [warnings]: Enable/Disable warnings from "Detect use of unwanted chars in files" *)
95+
warnings = "+A"
96+
}
97+
}
98+
plugin_patch = {
99+
100+
(* [enabled]: Detect pattern with semantic patch. *)
101+
enabled = true
102+
sempatch_lint_default = {
103+
104+
(* [enabled]: Enable/Disable linter "Lint from semantic patches (default)". *)
105+
enabled = true
106+
107+
(* [ignore]: Module to ignore durint the lint of "Lint from semantic patches (default)" *)
108+
ignore = [
109+
]
110+
111+
(* [warnings]: Enable/Disable warnings from "Lint from semantic patches (default)" *)
112+
warnings = "+A"
113+
}
114+
sempatch_lint_user_defined = {
115+
116+
(* [enabled]: Enable/Disable linter "Lint from semantic patches (user defined).". *)
117+
enabled = true
118+
119+
(* [ignore]: Module to ignore durint the lint of "Lint from semantic patches (user defined)." *)
120+
ignore = [
121+
]
122+
123+
(* [warnings]: Enable/Disable warnings from "Lint from semantic patches (user defined)." *)
124+
warnings = "+A"
125+
}
126+
}
127+
plugin_parsing = {
128+
129+
(* [enabled]: Analyses requiring to re-parse the file *)
130+
enabled = true
131+
raw_syntax = {
132+
133+
(* [enabled]: Enable/Disable linter "Raw Syntax". *)
134+
enabled = true
135+
136+
(* [ignore]: Module to ignore durint the lint of "Raw Syntax" *)
137+
ignore = [
138+
]
139+
140+
(* [warnings]: Enable/Disable warnings from "Raw Syntax" *)
141+
warnings = "+A"
142+
}
143+
}
144+
plugin_parsetree = {
145+
146+
(* [enabled]: A plugin with linters on parsetree. *)
147+
enabled = true
148+
code_identifier_length = {
149+
150+
(* [enabled]: Enable/Disable linter "Code Identifier Length". *)
151+
enabled = false
152+
153+
(* [ignore]: Module to ignore durint the lint of "Code Identifier Length" *)
154+
ignore = [
155+
]
156+
157+
(* [warnings]: Enable/Disable warnings from "Code Identifier Length" *)
158+
warnings = "+A"
159+
160+
(* [min_identifier_length]: Identifiers with a shorter name will trigger a warning *)
161+
min_identifier_length = 2
162+
163+
(* [max_identifier_length]: Identifiers with a longer name will trigger a warning *)
164+
max_identifier_length = 30
165+
}
166+
code_list_on_singleton = {
167+
168+
(* [enabled]: Enable/Disable linter "List function on singleton". *)
169+
enabled = true
170+
171+
(* [ignore]: Module to ignore durint the lint of "List function on singleton" *)
172+
ignore = [
173+
]
174+
175+
(* [warnings]: Enable/Disable warnings from "List function on singleton" *)
176+
warnings = "+A"
177+
}
178+
phys_comp_allocated_lit = {
179+
180+
(* [enabled]: Enable/Disable linter "Physical comparison between allocated litterals.". *)
181+
enabled = true
182+
183+
(* [ignore]: Module to ignore durint the lint of "Physical comparison between allocated litterals." *)
184+
ignore = [
185+
]
186+
187+
(* [warnings]: Enable/Disable warnings from "Physical comparison between allocated litterals." *)
188+
warnings = "+A"
189+
}
190+
fabrice_good_practices = {
191+
192+
(* [enabled]: Enable/Disable linter "Good Practices". *)
193+
enabled = true
194+
195+
(* [ignore]: Module to ignore durint the lint of "Good Practices" *)
196+
ignore = [
197+
]
198+
199+
(* [warnings]: Enable/Disable warnings from "Good Practices" *)
200+
warnings = "+A"
201+
}
202+
check_constr_args = {
203+
204+
(* [enabled]: Enable/Disable linter "Check Constructor Arguments". *)
205+
enabled = true
206+
207+
(* [ignore]: Module to ignore durint the lint of "Check Constructor Arguments" *)
208+
ignore = [
209+
]
210+
211+
(* [warnings]: Enable/Disable warnings from "Check Constructor Arguments" *)
212+
warnings = "+A"
213+
}
214+
code_redefine_stdlib_module = {
215+
216+
(* [enabled]: Enable/Disable linter "Refedine Stdlib Module". *)
217+
enabled = false
218+
219+
(* [ignore]: Module to ignore durint the lint of "Refedine Stdlib Module" *)
220+
ignore = [
221+
]
222+
223+
(* [warnings]: Enable/Disable warnings from "Refedine Stdlib Module" *)
224+
warnings = "+A"
225+
}
226+
}
227+
plugin_indent = {
228+
229+
(* [enabled]: A plugin with linters on the source. *)
230+
enabled = true
231+
ocp_indent = {
232+
233+
(* [enabled]: Enable/Disable linter "Indention with ocp-indent". *)
234+
enabled = true
235+
236+
(* [ignore]: Module to ignore durint the lint of "Indention with ocp-indent" *)
237+
ignore = [
238+
]
239+
240+
(* [warnings]: Enable/Disable warnings from "Indention with ocp-indent" *)
241+
warnings = "+A"
242+
}
243+
}
244+
plugin_file_system = {
245+
246+
(* [enabled]: A plugin with linters on file system like interface missing, etc. *)
247+
enabled = true
248+
interface_missing = {
249+
250+
(* [enabled]: Enable/Disable linter "Missing interface". *)
251+
enabled = false
252+
253+
(* [ignore]: Module to ignore durint the lint of "Missing interface" *)
254+
ignore = [
255+
]
256+
257+
(* [warnings]: Enable/Disable warnings from "Missing interface" *)
258+
warnings = "+A"
259+
}
260+
project_files = {
261+
262+
(* [enabled]: Enable/Disable linter "File Names". *)
263+
enabled = true
264+
265+
(* [ignore]: Module to ignore durint the lint of "File Names" *)
266+
ignore = [
267+
]
268+
269+
(* [warnings]: Enable/Disable warnings from "File Names" *)
270+
warnings = "+A"
271+
}
272+
}
273+
plugin_complex = {
274+
275+
(* [enabled]: A plugin with linters on different inputs. *)
276+
enabled = true
277+
interface_module_type_name = {
278+
279+
(* [enabled]: Enable/Disable linter "Checks on module type name.". *)
280+
enabled = true
281+
282+
(* [ignore]: Module to ignore durint the lint of "Checks on module type name." *)
283+
ignore = [
284+
]
285+
286+
(* [warnings]: Enable/Disable warnings from "Checks on module type name." *)
287+
warnings = "+A"
288+
}
289+
}

lib/parse/ast.ml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
(**
22
Parsetree for the nix language
3-
*)
3+
*)
44

55
type 'a with_loc = 'a Location.With_loc.t
66

77
type operator =
88
| Ocons
9-
109

1110
type expr = expr_desc with_loc
1211

@@ -17,7 +16,7 @@ and expr_desc =
1716
x
1817
x.y
1918
x.y or e
20-
*)
19+
*)
2120
| Econstant of constant
2221
| Estring of str
2322
(* Not constant because of interpolation *)
@@ -86,15 +85,15 @@ and field =
8685
| FstaticDef of string * expr
8786
| Finherit of inherit_
8887
(** inherit x y z...;
89-
inherit (e) x y z...;
90-
*)
88+
inherit (e) x y z...;
89+
*)
9190

9291
and binding =
93-
| Bdef of access_path * expr (* FIXME: the first element can not be an arbitrary expr *)
92+
| Bdef of access_path * expr
93+
(* FIXME: the first element can not be an arbitrary expr *)
9494
| BstaticDef of pattern_var * expr
9595
| Binherit of inherit_
9696

9797
and inherit_ = expr option * (string with_loc) list
9898

9999
and interpol = expr
100-

lib/parse/location.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(**
22
Simple data structure to add location information to AST nodes
3-
*)
3+
*)
44
type t = {
55
pos_start: Lexing.position [@opaque];
66
pos_end: Lexing.position [@opaque];

0 commit comments

Comments
 (0)