Skip to content

Commit

Permalink
Fix defects found on self-applications. Many still left
Browse files Browse the repository at this point in the history
Signed-off-by: Kakadu <[email protected]>
  • Loading branch information
Kakadu committed Jul 28, 2024
1 parent 1e7c6e0 commit c0af402
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 21 deletions.
2 changes: 1 addition & 1 deletion review/diff_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ let file_head : _ option parser =

let a_chunk : chunk parser =
log "%d: a_chunk" __LINE__;
let* info = Line_parser.(run ~info:"chunk_head" @@ chunk_head <?> "chunk_head") in
let* info = Line_parser.(run ~info:"chunk_head" chunk_head <?> "chunk_head") in
(* The string '\ No new line in the end of file' could be
in an arbitrary place of the diff. So we do filter of result *)
let* diffs =
Expand Down
2 changes: 1 addition & 1 deletion review/line_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ let pos_num : int parser =
| '0' .. '9' -> true
| _ -> false
in
take_while1 is_digit >>| fun s -> int_of_string s
take_while1 is_digit >>| int_of_string
;;

let chunk_head : chunk_info parser =
Expand Down
8 changes: 8 additions & 0 deletions src/Collected_decls.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[@@@ocaml.text "/*"]

(** Copyright 2021-2024, Kakadu. *)

(** SPDX-License-Identifier: LGPL-3.0-or-later *)

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

open Utils
module StringSet = Set.Make (String)

Expand Down
2 changes: 1 addition & 1 deletion src/Collected_lints.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ let report () =
let (_ : int) = Sys.command (Format.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.rdjsonl ppf)
[ ( (fun (module M : LINT.REPORTER) -> M.rdjsonl)
, Caml.Format.formatter_of_out_channel ch
, ch )
]
Expand Down
8 changes: 8 additions & 0 deletions src/Dune_project.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[@@@ocaml.text "/*"]

(** Copyright 2021-2024, Kakadu. *)

(** SPDX-License-Identifier: LGPL-3.0-or-later *)

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

let string_of_sexp = Base.string_of_sexp
let sexp_of_string = Base.sexp_of_string
let option_of_sexp = Base.option_of_sexp
Expand Down
8 changes: 8 additions & 0 deletions src/Lint_filesystem.mli
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
[@@@ocaml.text "/*"]

(** Copyright 2021-2024, Kakadu. *)

(** SPDX-License-Identifier: LGPL-3.0-or-later *)

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

val check : Dune_project.t list -> unit
val describe_as_json : unit -> Yojson.Safe.t
3 changes: 1 addition & 2 deletions src/Unused_ML_logger.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ open Utils

let run _info filename fallback =
let _ : string = filename in
let rec get_ident_string path =
match path with
let rec get_ident_string = function
| Path.Pident id -> Some (Ident.name id)
| Path.Pdot (lhs, rhs) ->
get_ident_string lhs |> Option.map ~f:(fun str -> str ^ "." ^ rhs)
Expand Down
8 changes: 4 additions & 4 deletions src/fix/replacement/log.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ let create_file name =
;;

let rec rm path =
match Sys.is_directory path with
| true ->
if Sys.is_directory path
then (
Sys.readdir path |> Array.iter (fun f -> rm (fix_dir ^ f));
Sys.rmdir path
| false -> Sys.remove path
Sys.rmdir path)
else Sys.remove path
;;

let prepare_env () =
Expand Down
15 changes: 7 additions & 8 deletions src/fix/replacement/padding.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ let payload_between_repls (loc_end_buf, loc_start_repl) flines =
loc_start_repl.pos_lnum, loc_start_repl.pos_cnum - loc_start_repl.pos_bol
in
let payload =
match end_buf_line = repl_line with
| true -> String.sub flines.(repl_line - 1) end_buf_col (repl_col - end_buf_col)
| false ->
if end_buf_line = repl_line
then String.sub flines.(repl_line - 1) end_buf_col (repl_col - end_buf_col)
else (
let lines =
String.sub
flines.(end_buf_line - 1)
Expand All @@ -83,8 +83,7 @@ let payload_between_repls (loc_end_buf, loc_start_repl) flines =
(Format.sprintf "%s\n" lines)
(Array.sub flines end_buf_line (repl_line - end_buf_line - 1))
in
let lines = lines ^ String.sub flines.(repl_line - 1) 0 repl_col in
lines
lines ^ String.sub flines.(repl_line - 1) 0 repl_col)
in
payload
;;
Expand Down Expand Up @@ -123,9 +122,9 @@ let comments_inside_loc comms fix_loc =
let relative_pos st_pos pos =
let rel_lnum = pos.pos_lnum - st_pos.pos_lnum in
let rel_bol, rel_cnum =
match rel_lnum = 0 with
| true -> pos.pos_bol - st_pos.pos_bol, pos.pos_cnum - st_pos.pos_cnum
| false -> pos.pos_bol, pos.pos_cnum
if rel_lnum = 0
then pos.pos_bol - st_pos.pos_bol, pos.pos_cnum - st_pos.pos_cnum
else pos.pos_bol, pos.pos_cnum
in
{ pos with pos_bol = rel_bol; pos_cnum = rel_cnum; pos_lnum = rel_lnum + 1 }
;;
Expand Down
3 changes: 1 addition & 2 deletions src/pattern/Tast_pattern.ml
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,7 @@ let path xs =
T (helper (List.rev xs))
;;

let path_of_list xs =
match xs with
let path_of_list = function
| [] -> failwith "Bad argument: path_of_list"
| s :: tl ->
List.fold_left
Expand Down
5 changes: 3 additions & 2 deletions src/typed/Eta.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ let run _ fallback =
(List.length ids)
(List.length args); *)
let idents = List.filter_map ~f:extract_ident args in
if List.length args > 0
&& List.length args = List.length idents
let args_len = List.length args in
if args_len > 0
&& args_len = List.length idents
&& List.equal String.equal ids (List.map idents ~f:Ident.name)
&& (not (Base.List.contains_dup ~compare:String.compare ids))
&& List.for_all idents ~f:(fun ident -> no_ident ident func)
Expand Down

0 comments on commit c0af402

Please sign in to comment.