Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
8c62390a
Commit
8c62390a
authored
2 years ago
by
Patrick Baudin
Committed by
Andre Maroneze
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[lint] better error messages
parent
70b88047
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/lint/lint.ml
+19
-11
19 additions, 11 deletions
tools/lint/lint.ml
with
19 additions
and
11 deletions
tools/lint/lint.ml
+
19
−
11
View file @
8c62390a
...
...
@@ -79,13 +79,15 @@ let ml_indent_formatter = Ocp_indent
type
indent_check
=
NoCheck
|
Check
of
indent_formatter
option
let
parse_indent_formatter
=
function
let
parse_indent_formatter
~
file
~
attr
~
value
=
match
value
with
|
"unset"
->
NoCheck
|
"set"
->
Check
None
(* use the default formatter *)
|
"ocp-indent"
->
Check
(
Some
ml_indent_formatter
)
|
"clang-format"
->
Check
(
Some
(
Tool
c_indent_formatter
))
|
"black"
->
Check
(
Some
(
Tool
python_indent_formatter
))
|
s
->
Format
.
eprintf
"Unsupported tool: %s@."
s
;
NoCheck
|
_
->
Format
.
eprintf
"Unsupported indent formatter: %s %s=%s@."
file
attr
value
;
NoCheck
(**************************************************************************)
(* Available Checks and corresponding attributes *)
...
...
@@ -104,14 +106,19 @@ let no_checks =
;
utf8
=
false
}
let
add_attr
checks
attr
value
=
let
is_set
v
=
v
=
"set"
in
let
add_attr
~
file
~
attr
~
value
checks
=
let
is_set
=
function
|
"set"
->
true
|
"unset"
->
false
|
_
->
failwith
(
Format
.
sprintf
"Invalid attribute value: %s %s=%s"
file
attr
value
)
in
match
attr
with
|
"check-eoleof"
->
{
checks
with
eoleof
=
is_set
value
}
|
"check-indent"
->
{
checks
with
indent
=
parse_indent_formatter
value
}
|
"check-syntax"
->
{
checks
with
syntax
=
is_set
value
}
|
"check-utf8"
->
{
checks
with
utf8
=
is_set
value
}
|
_
->
failwith
(
Format
.
sprintf
"Unknown attr %s"
attr
)
|
"check-indent"
->
{
checks
with
indent
=
parse_indent_formatter
~
file
~
attr
~
value
}
|
_
->
failwith
(
Format
.
sprintf
"Unknown attribute: %s %s=%s"
file
attr
value
)
let
handled_attr
s
=
s
=
"check-eoleof"
||
s
=
"check-indent"
||
...
...
@@ -134,10 +141,11 @@ let rec collect = function
collect
tl
|
file
::
attr
::
value
::
tl
->
let
checks
=
get
file
in
Hashtbl
.
replace
table
file
(
add_attr
checks
attr
value
)
;
Hashtbl
.
replace
table
file
(
add_attr
~
file
~
attr
~
value
checks
)
;
collect
tl
|
[]
->
()
|
l
->
List
.
iter
(
Format
.
eprintf
"Could not load file list %s@."
)
l
|
[
file
;
attr
]
->
Format
.
eprintf
"Missing attribute value: %s %s=?@."
file
attr
|
[
file
]
->
Format
.
eprintf
"Missing attribute name for file: %s@."
file
(**************************************************************************)
(* Functions used to check lint *)
...
...
@@ -280,9 +288,9 @@ let check_indent ~indent_formatter ~update file =
|
Ocp_indent
->
check_ml_indent
~
update
file
|
Tool
indent_formatter
->
if
not
@@
is_formatter_available
indent_formatter
then
true
else
let
cmd
=
if
update
then
indent_formatter
.
update_cmd
else
indent_formatter
.
check_cmd
in
0
=
Sys
.
command
(
Format
.
sprintf
"%s
\"
%s
\"
"
cmd
file
)
else
if
not
update
then
0
=
Sys
.
command
(
Format
.
sprintf
"%s
\"
%s
\"
"
indent_formatter
.
check_cmd
file
)
else
0
=
Sys
.
command
(
Format
.
sprintf
"%s
\"
%s
\"
"
indent_formatter
.
update_
cmd
file
)
let
res
=
ref
true
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment