Skip to content

Commit

Permalink
Upgrade for OCamlformat 0.26.2
Browse files Browse the repository at this point in the history
Signed-off-by: Kakadu <[email protected]>
  • Loading branch information
Kakadu committed Jul 25, 2024
1 parent 7382ec2 commit f16ff96
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 84 deletions.
32 changes: 16 additions & 16 deletions src/CollectedLints.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ let loc_lints f = Queue.map found_Lints ~f

let report () =
(* let mdfile =
match Config.Options.outfile () with
| Some s ->
(* Format.printf "Opening file '%s'...\n%!" s; *)
let (_ : int) = Caml.Sys.command (asprintf "touch %s" s) in
let ch = Caml.open_out_gen [ Caml.Open_append; Open_creat ] 0o666 s in
[ ( (fun (module M : LINT.REPORTER) ppf -> M.md ppf)
match Config.Options.outfile () with
| Some s ->
(* Format.printf "Opening file '%s'...\n%!" s; *)
let (_ : int) = Caml.Sys.command (asprintf "touch %s" s) in
let ch = Caml.open_out_gen [ Caml.Open_append; Open_creat ] 0o666 s in
[ ( (fun (module M : LINT.REPORTER) ppf -> M.md ppf)
, Format.formatter_of_out_channel ch
, ch )
]
| None -> []
in *)
| None -> []
in *)
(* let golint_files =
match Config.Options.out_golint () with
| Some s ->
let (_ : int) = Caml.Sys.command (asprintf "touch %s" s) in
(* By some reason on CI Open_creat is not enough to create a file *)
let ch = Caml.open_out_gen [ Caml.Open_append; Open_creat ] 0o666 s in
[ ( (fun (module M : LINT.REPORTER) ppf -> M.golint ppf)
match Config.Options.out_golint () with
| Some s ->
let (_ : int) = Caml.Sys.command (asprintf "touch %s" s) in
(* By some reason on CI Open_creat is not enough to create a file *)
let ch = Caml.open_out_gen [ Caml.Open_append; Open_creat ] 0o666 s in
[ ( (fun (module M : LINT.REPORTER) ppf -> M.golint ppf)
, Format.formatter_of_out_channel ch
, ch )
]
| None -> []
in *)
| None -> []
in *)
let rdjsonl_files =
match Config.out_rdjsonl () with
| Some s ->
Expand Down
6 changes: 3 additions & 3 deletions src/Lint_filesystem.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ let check db =
then
List.iter
(function
| Build_context _ | Root _ -> ()
| Executables es -> on_executables es
| Library l -> on_library l)
| Build_context _ | Root _ -> ()
| Executables es -> on_executables es
| Library l -> on_library l)
db
;;
2 changes: 1 addition & 1 deletion src/fix/refactoring/IfBool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let bool_value e =
(* Fix for unwise_conj assumes that the conj takes two arguments because at the time
of implementation the linter can only detect the use of a conjuction with two arguments *)
let check_bool args vbool =
let helper e e' f f' =
let helper e e' f f' =
let func = if vbool then f else f' in
set_empty_padding (func e) (func e')
in
Expand Down
2 changes: 1 addition & 1 deletion src/fix/replacement/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
(name Replacement)
(libraries zanuda_core angstrom)
(instrumentation
(backend bisect_ppx)))
(backend bisect_ppx)))
5 changes: 3 additions & 2 deletions src/pattern/Tast_pattern.ml
Original file line number Diff line number Diff line change
Expand Up @@ -733,14 +733,15 @@ let tsig_attribute (T fattr) =
| _ -> fail loc "tsig_attribute")
;;

let tsig_val_name (T fname) =
let tsig_val_name (T fname) =
T
(fun ctx loc str k ->
match str.sig_desc with
| Tsig_value {val_id = txt} ->
| Tsig_value { val_id = txt } ->
ctx.matched <- ctx.matched + 1;
k |> fname ctx loc txt
| _ -> fail loc "tsig_val_name")
;;

let attribute (T fname) (T fpayload) =
T
Expand Down
2 changes: 0 additions & 2 deletions src/pattern/Tast_pattern.mli
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,8 @@ val core_typ : (Types.type_expr, 'a, 'b) t -> (core_type, 'a, 'b) t
(* Structure *)
val tstr_attribute : (attribute, 'a, 'b) t -> (structure_item, 'a, 'b) t
val tsig_attribute : (attribute, 'a, 'b) t -> (signature_item, 'a, 'b) t

val tsig_val_name : (Ident.t, 'a, 'b) t -> (signature_item, 'a, 'b) t


val attribute
: (string, 'a, 'b) t
-> (Parsetree.payload, 'b, 'c) t
Expand Down
10 changes: 5 additions & 5 deletions src/typed/Equality.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ let run _ fallback =
let open Typedtree in
let loc = expr.exp_loc in
(* if String.is_substring loc.loc_start.pos_fname ~substring:"Equality"
then
Format.printf
"%a\n%!"
Pprintast.expression
Untypeast.(default_mapper.expr default_mapper expr); *)
then
Format.printf
"%a\n%!"
Pprintast.expression
Untypeast.(default_mapper.expr default_mapper expr); *)
Tast_pattern.parse
pat
loc
Expand Down
2 changes: 1 addition & 1 deletion src/typed/ExcTryWithWildcard.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ let run _ fallback =
expr
(fun { loc } () ->
(* Reported location is a location of whole match and not of pattern
TODO: understand how to fix it *)
TODO: understand how to fix it *)
(* Format.printf "%a\n%!" Location.print_loc loc; *)
CollectedLints.add ~loc (report loc.Location.loc_start.Lexing.pos_fname ~loc))
();
Expand Down
6 changes: 3 additions & 3 deletions src/typed/Failwith.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ let run _ fallback =
let open Typedtree in
let loc = expr.exp_loc in
(* if String.is_substring loc.loc_start.pos_fname ~substring:"Failwith"
then (
let u = Untypeast.(default_mapper.expr default_mapper expr) in
Format.printf "%a\n%a\n%!" Pprintast.expression u (Printast.expression 0) u); *)
then (
let u = Untypeast.(default_mapper.expr default_mapper expr) in
Format.printf "%a\n%a\n%!" Pprintast.expression u (Printast.expression 0) u); *)
Tast_pattern.parse
pat
loc
Expand Down
10 changes: 5 additions & 5 deletions src/typed/List_fusion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ let run _ fallback =
texp_apply_nolabelled list_map (drop ^:: texp_apply list_map drop ^:: nil)
|> map0 ~f:MapMap
||| (texp_apply_nolabelled list_filter (drop ^:: texp_apply list_map drop ^:: nil)
|> map0 ~f:FilterMap)
|> map0 ~f:FilterMap)
||| (texp_apply list_concat ((nolabel ** some (texp_apply list_map drop)) ^:: nil)
|> map0 ~f:ConcatMap)
|> map0 ~f:ConcatMap)
in
let open Tast_iterator in
{ fallback with
Expand All @@ -103,9 +103,9 @@ let run _ fallback =
let open Typedtree in
let loc = expr.exp_loc in
(* if String.is_substring loc.loc_start.pos_fname ~substring:"Fusion"
then (
let u = Untypeast.(default_mapper.expr default_mapper expr) in
Format.printf "%a\n%a\n%!" Pprintast.expression u (Printast.expression 0) u); *)
then (
let u = Untypeast.(default_mapper.expr default_mapper expr) in
Format.printf "%a\n%a\n%!" Pprintast.expression u (Printast.expression 0) u); *)
Tast_pattern.parse
pat
loc
Expand Down
36 changes: 19 additions & 17 deletions src/typed/List_length.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,18 @@ let pat_list_length () : (expression, 'a, 'a) Tast_pattern.t =
;;

let make_pat_op : 'a. string -> (expression, 'a, 'a) t =
fun op ->
fun op ->
texp_ident (path [ "Stdlib"; op ])
||| texp_ident (path [ "Stdlib!"; op ])
||| texp_ident (path [ "Base!"; op ])
||| texp_ident (path [ "Base"; op ])
;;

let pat
: ( Typedtree.expression, Typedtree.expression -> Typedtree.expression -> 'a, 'a )
Tast_pattern.t
: ( Typedtree.expression
, Typedtree.expression -> Typedtree.expression -> 'a
, 'a )
Tast_pattern.t
=
let open Tast_pattern in
let ops = [ ">=", "<=", 0; "<=", ">=", 0; ">", "<", 0; "<", ">", 0; "=", "=", 0 ] in
Expand All @@ -105,13 +107,13 @@ let pat
;;

(* let%test _ =
Tast_pattern.parse
pat
Location.none
~on_error:(fun _ -> true)
[%expr List.length xs = List.length ys]
(fun _ () -> true)
;; *)
Tast_pattern.parse
pat
Location.none
~on_error:(fun _ -> true)
[%expr List.length xs = List.length ys]
(fun _ () -> true)
;; *)

let run _ fallback =
let open Tast_iterator in
Expand All @@ -126,13 +128,13 @@ let run _ fallback =
expr
(fun e1 e2 () ->
(* let __ _ =
Format.printf
"List_length DEBUG: '%a' and '%a'\n%!"
MyPrinttyped.expr
e1
MyPrinttyped.expr
e2
in *)
Format.printf
"List_length DEBUG: '%a' and '%a'\n%!"
MyPrinttyped.expr
e1
MyPrinttyped.expr
e2
in *)
CollectedLints.add
~loc
(report loc.Location.loc_start.Lexing.pos_fname ~loc e1 e2))
Expand Down
2 changes: 1 addition & 1 deletion src/typed/Monad_laws.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let run _ fallback =
(tpat_var __)
none
(texp_apply1 (texp_ident (pident (string "return"))) (texp_ident (pident __)))
^:: nil)
^:: nil)
(* TODO: invent monads to be able to check two identifiers during the matching *)
in
let open Tast_iterator in
Expand Down
2 changes: 1 addition & 1 deletion src/typed/Nested_if.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[@@@ocaml.text "/*"]

open Zanuda_core
open Zanuda_core
open Zanuda_core.Utils

type input = Tast_iterator.iterator
Expand Down
24 changes: 12 additions & 12 deletions src/typed/String_concat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ let run _ fallback =
let open Typedtree in
let loc = expr.exp_loc in
(* let __ _ =
if String.is_substring loc.loc_start.pos_fname ~substring:"StringConcat"
then (
let u = Untypeast.(default_mapper.expr default_mapper expr) in
Format.printf
"%a\n%a\n%a\n%!"
Pprintast.expression
u
(Printast.expression 0)
u
MyPrinttyped.expr
expr)
in *)
if String.is_substring loc.loc_start.pos_fname ~substring:"StringConcat"
then (
let u = Untypeast.(default_mapper.expr default_mapper expr) in
Format.printf
"%a\n%a\n%a\n%!"
Pprintast.expression
u
(Printast.expression 0)
u
MyPrinttyped.expr
expr)
in *)
Tast_pattern.parse
pat
loc
Expand Down
8 changes: 4 additions & 4 deletions src/typed/String_concat_fold.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ let run _ fallback =
let list_fold =
texp_ident_typ
(path [ "Stdlib"; "List"; "fold_left" ]
||| path [ "Stdlib!"; "List"; "fold_left" ]
||| path [ "Stdlib"; "Array"; "fold_left" ]
||| path [ "Stdlib!"; "Array"; "fold_left" ])
||| path [ "Stdlib!"; "List"; "fold_left" ]
||| path [ "Stdlib"; "Array"; "fold_left" ]
||| path [ "Stdlib!"; "Array"; "fold_left" ])
(typ_arrow drop (typ_arrow drop drop))
in
let list_fold_labelled =
texp_ident_typ
(path [ "Stdlib"; "ListLabels"; "fold_left" ]
||| path [ "Stdlib!"; "ListLabels"; "fold_left" ])
||| path [ "Stdlib!"; "ListLabels"; "fold_left" ])
(typ_arrow drop (typ_arrow drop drop))
in
let concat_op =
Expand Down
14 changes: 7 additions & 7 deletions src/unidiff/parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
[@@@ocaml.text "/*"]

(*
commit:
https://github.com/<owner>/<repo>/commit/<commit>.diff
wget https://github.com/Kakadu/zanuda/commit/e4d35c2.diff
commit:
https://github.com/<owner>/<repo>/commit/<commit>.diff
wget https://github.com/Kakadu/zanuda/commit/e4d35c2.diff
pull:
pull:
wget https://github.com/Kakadu/zanuda/commit/e4d35c2.diff
*)

(*
doc: https://www.artima.com/weblogs/viewpost.jsp?thread=164293
https://github.com/reviewdog/reviewdog/blob/master/diff/parse.go
https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
doc: https://www.artima.com/weblogs/viewpost.jsp?thread=164293
https://github.com/reviewdog/reviewdog/blob/master/diff/parse.go
https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
*)
open Angstrom

Expand Down
4 changes: 2 additions & 2 deletions src/unused_decls/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
(name UnusedDecls)
(libraries zanuda_core Tast_pattern Refactoring)
(modules
MLILogger
MLLogger
MLILogger
MLLogger
;
)
(preprocess
Expand Down
2 changes: 1 addition & 1 deletion tests/fix/dune
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(cram
(deps %{bin:zanuda}))
(deps %{bin:zanuda}))

0 comments on commit f16ff96

Please sign in to comment.