Skip to content

Commit

Permalink
lint: change warnings to errors on enabled-as-errors warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbou authored and kit-ty-kate committed Sep 11, 2023
1 parent a0423ef commit 218448c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
18 changes: 11 additions & 7 deletions src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3890,13 +3890,10 @@ let lint cli =
stdin_f stdin,
None
in
let enabled =
let map =
List.fold_left
(fun acc (wn, state) -> OpamStd.IntMap.add wn state acc)
OpamStd.IntMap.empty warnings_sel
in
fun w -> try OpamStd.IntMap.find w map with Not_found -> default_warn
let warnings_sel_map = OpamStd.IntMap.of_list warnings_sel in
let enabled w =
try OpamStd.IntMap.find w warnings_sel_map
with Not_found -> default_warn
in
let warnings, failed =
List.fold_left (fun (warnings, failed) ((n, state, _) as warn) ->
Expand All @@ -3906,6 +3903,13 @@ let lint cli =
| `Disable, _ -> (warnings, failed)
) ([], false) warnings
in
let warnings =
List.map (fun ((n, _, s) as warn) ->
match OpamStd.IntMap.find_opt n warnings_sel_map with
| Some `EnableError -> (n, `Error, s)
| Some (`Disable | `Enable) | None -> warn)
warnings
in
if short then
(if warnings <> [] then
msg "%s\n"
Expand Down
22 changes: 11 additions & 11 deletions tests/reftests/lint.test
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,31 @@ ${BASEDIR}/lint.opam: Errors.
### opam lint ./lint.opam [email protected]
${BASEDIR}/lint.opam: Errors.
error 23: Missing field 'maintainer'
warning 25: Missing field 'authors'
warning 35: Missing field 'homepage'
warning 36: Missing field 'bug-reports'
error 25: Missing field 'authors'
error 35: Missing field 'homepage'
error 36: Missing field 'bug-reports'
error 57: Synopsis must not be empty
warning 68: Missing field 'license'
error 68: Missing field 'license'
# Return code 1 #
### opam lint ./lint.opam [email protected]
${BASEDIR}/lint.opam: Errors.
error 23: Missing field 'maintainer'
warning 25: Missing field 'authors'
warning 35: Missing field 'homepage'
warning 36: Missing field 'bug-reports'
error 25: Missing field 'authors'
error 35: Missing field 'homepage'
error 36: Missing field 'bug-reports'
error 57: Synopsis must not be empty
warning 68: Missing field 'license'
error 68: Missing field 'license'
# Return code 1 #
### opam lint ./lint.opam --warn=+25@25
${BASEDIR}/lint.opam: Errors.
warning 25: Missing field 'authors'
error 25: Missing field 'authors'
# Return code 1 #
### opam lint ./lint.opam [email protected]
${BASEDIR}/lint.opam: Errors.
error 23: Missing field 'maintainer'
warning 25: Missing field 'authors'
warning 35: Missing field 'homepage'
warning 36: Missing field 'bug-reports'
error 35: Missing field 'homepage'
error 36: Missing field 'bug-reports'
# Return code 1 #
### ::::::::::::::
### : Test lints :
Expand Down

0 comments on commit 218448c

Please sign in to comment.