From 218448cf9426787ea28aa9ff21f28efb37b63150 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Fri, 8 Sep 2023 17:24:01 +0200 Subject: [PATCH] lint: change warnings to errors on enabled-as-errors warnings --- src/client/opamCommands.ml | 18 +++++++++++------- tests/reftests/lint.test | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/client/opamCommands.ml b/src/client/opamCommands.ml index e6df1c7ce2d..ba2d2102c6c 100644 --- a/src/client/opamCommands.ml +++ b/src/client/opamCommands.ml @@ -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) -> @@ -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" diff --git a/tests/reftests/lint.test b/tests/reftests/lint.test index 6ee4630ceb9..68d8aa7df02 100644 --- a/tests/reftests/lint.test +++ b/tests/reftests/lint.test @@ -64,31 +64,31 @@ ${BASEDIR}/lint.opam: Errors. ### opam lint ./lint.opam --warn=@0..99 ${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=@0..99 ${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 --warn=+20..40@30..40 ${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 :