From 432a9704325c5be1b669de075814b9f751341d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezgi=20=C3=87i=C3=A7ek?= Date: Fri, 12 Mar 2021 01:36:11 -0800 Subject: [PATCH] [refactor] Remove `then ()` Reviewed By: jvillard Differential Revision: D26978263 fbshipit-source-id: c7c684d4b --- infer/src/IR/Typ.ml | 3 +-- infer/src/al/AL.ml | 3 +-- infer/src/backend/RestartScheduler.ml | 4 ++-- infer/src/base/Location.ml | 4 ++-- infer/src/base/ProcessPool.ml | 5 ++--- infer/src/biabduction/Absarray.ml | 4 ++-- infer/src/biabduction/Prop.ml | 3 +-- infer/src/checkers/inefficientKeysetIterator.ml | 3 +-- infer/src/clang/CAddImplicitGettersSetters.ml | 5 ++--- infer/src/clang/cFrontend_decl.ml | 3 +-- infer/src/clang/cTrans_utils.ml | 3 +-- infer/src/integration/BuckFlavors.ml | 5 ++--- infer/src/pulse/PulseFormula.ml | 8 +++----- 13 files changed, 21 insertions(+), 32 deletions(-) diff --git a/infer/src/IR/Typ.ml b/infer/src/IR/Typ.ml index c3f04cfe8..bb4cdf314 100644 --- a/infer/src/IR/Typ.ml +++ b/infer/src/IR/Typ.ml @@ -338,8 +338,7 @@ and pp_template_spec_info pe f = function and pp_protocols pe f protocols = - if List.is_empty protocols then () - else + if not (List.is_empty protocols) then F.fprintf f "%s%a%s" (escape pe "<") (Pp.comma_seq (pp_name_c_syntax pe)) protocols (escape pe ">") diff --git a/infer/src/al/AL.ml b/infer/src/al/AL.ml index 1d7923c8e..0b7e99f3b 100644 --- a/infer/src/al/AL.ml +++ b/infer/src/al/AL.ml @@ -280,8 +280,7 @@ and do_frontend_checks_via_transition linters context an trans = and do_frontend_checks_decl linters (context : CLintersContext.context) decl = let open Clang_ast_t in - if CAst_utils.is_implicit_decl decl then () (* do not analyze implicit declarations *) - else + if not (CAst_utils.is_implicit_decl decl) (* do not analyze implicit declarations *) then let an = Ctl_parser_types.Decl decl in (* The map should be visited when we enter the node before visiting children *) match decl with diff --git a/infer/src/backend/RestartScheduler.ml b/infer/src/backend/RestartScheduler.ml index c3e0f148c..3431c7826 100644 --- a/infer/src/backend/RestartScheduler.ml +++ b/infer/src/backend/RestartScheduler.ml @@ -59,8 +59,8 @@ let make sources = let if_restart_scheduler f = - if Int.equal Config.jobs 1 then () - else match Config.scheduler with File | SyntacticCallGraph -> () | Restart -> f () + if not (Int.equal Config.jobs 1) then + match Config.scheduler with File | SyntacticCallGraph -> () | Restart -> f () type locked_proc = diff --git a/infer/src/base/Location.ml b/infer/src/base/Location.ml index a68236785..e6f0ce654 100644 --- a/infer/src/base/Location.ml +++ b/infer/src/base/Location.ml @@ -40,8 +40,8 @@ let pp_file_pos f (loc : t) = F.fprintf f "%a:%a" SourceFile.pp loc.file pp_shor let pp_range f (loc_start, loc_end) = let pp_end loc_start f loc_end = - if Int.equal loc_end.line loc_start.line then - if Int.equal loc_end.col loc_start.col then () else F.fprintf f "-%d" loc_end.col + if Int.equal loc_end.line loc_start.line then ( + if not (Int.equal loc_end.col loc_start.col) then F.fprintf f "-%d" loc_end.col ) else F.fprintf f "-%a" pp_short loc_end in F.fprintf f "%a%a" pp_file_pos loc_start (pp_end loc_start) loc_end diff --git a/infer/src/base/ProcessPool.ml b/infer/src/base/ProcessPool.ml index 0aba38e82..85b31fc86 100644 --- a/infer/src/base/ProcessPool.ml +++ b/infer/src/base/ProcessPool.ml @@ -123,11 +123,10 @@ let marshal_to_pipe fd x = (** like [Unix.read] but reads until [len] bytes have been read *) let rec really_read ?(pos = 0) ~len fd ~buf = - if len <= 0 then () - else + if len > 0 then ( let read = Unix.read ~pos ~len fd ~buf in if Int.equal read 0 then raise End_of_file ; - really_read ~pos:(pos + read) ~len:(len - read) fd ~buf + really_read ~pos:(pos + read) ~len:(len - read) fd ~buf ) (** return a list of all updates coming from workers. The first update is expected for up to the diff --git a/infer/src/biabduction/Absarray.ml b/infer/src/biabduction/Absarray.ml index 0d993fc5a..fb0a00460 100644 --- a/infer/src/biabduction/Absarray.ml +++ b/infer/src/biabduction/Absarray.ml @@ -617,8 +617,8 @@ let check_after_array_abstraction tenv prop = | Predicates.Earray (_, esel, _) -> (* check that no more than 2 elements are in the array *) let typ_elem = Typ.array_elem (Some StdTyp.void) typ in - if List.length esel > 2 && array_typ_can_abstract typ then - if List.for_all ~f:(check_index root offs) esel then () else report_error prop + if List.length esel > 2 && array_typ_can_abstract typ then ( + if not (List.for_all ~f:(check_index root offs) esel) then report_error prop ) else List.iter ~f:(fun (ind, se) -> check_se root (offs @ [Predicates.Off_index ind]) typ_elem se) diff --git a/infer/src/biabduction/Prop.ml b/infer/src/biabduction/Prop.ml index 106cfd6cf..c0ed4fedf 100644 --- a/infer/src/biabduction/Prop.ml +++ b/infer/src/biabduction/Prop.ml @@ -322,8 +322,7 @@ let pp_prop pe0 f prop = F.fprintf f "@,@[%a@]" (pp_hpara_dll_simple pe env n) hpara_dll in let pp_predicates _ () = - if Predicates.Env.is_empty env then () - else ( + if not (Predicates.Env.is_empty env) then ( F.fprintf f "@,where" ; Predicates.Env.iter env iter_f iter_f_dll ) in diff --git a/infer/src/checkers/inefficientKeysetIterator.ml b/infer/src/checkers/inefficientKeysetIterator.ml index f41307ac6..108ebdae8 100644 --- a/infer/src/checkers/inefficientKeysetIterator.ml +++ b/infer/src/checkers/inefficientKeysetIterator.ml @@ -87,8 +87,7 @@ let when_dominating_preds_satisfy idom my_node ~fun_name ~class_name_f ~f = |> List.filter ~f:(fun node -> Dominators.dominates idom node my_node) in let rec aux node (counter : int) = - if Int.equal counter 0 then () - else + if not (Int.equal counter 0) then match preds node with | [pred_node] -> ( match find_first_arg_pvar pred_node ~fun_name ~class_name_f with diff --git a/infer/src/clang/CAddImplicitGettersSetters.ml b/infer/src/clang/CAddImplicitGettersSetters.ml index 43adf26cf..4c8adf187 100644 --- a/infer/src/clang/CAddImplicitGettersSetters.ml +++ b/infer/src/clang/CAddImplicitGettersSetters.ml @@ -59,8 +59,7 @@ let process_getter_setter proc_name proc_desc = | _ -> [] in - if List.is_empty getter_setter_instrs then () - else + if not (List.is_empty getter_setter_instrs) then ( let new_attributes = {attributes with is_defined= true} in Procdesc.set_attributes proc_desc new_attributes ; let start_node = Procdesc.create_node proc_desc location Procdesc.Node.Start_node [] in @@ -73,7 +72,7 @@ let process_getter_setter proc_name proc_desc = Procdesc.create_node proc_desc location node_kind getter_setter_instrs in Procdesc.node_set_succs proc_desc start_node ~normal:[getter_setter_node] ~exn:[] ; - Procdesc.node_set_succs proc_desc getter_setter_node ~normal:[exit_node] ~exn:[] + Procdesc.node_set_succs proc_desc getter_setter_node ~normal:[exit_node] ~exn:[] ) let process cfg = Procname.Hash.iter process_getter_setter cfg diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index e957b85f1..68a938268 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -109,8 +109,7 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron CMethod_trans.create_local_procdesc ~set_objc_accessor_attr ~is_cpp_lambda_call_operator trans_unit_ctx cfg tenv ms body_new [] then - if is_cpp_lambda_call_operator && not inside_cpp_lambda_expr then () - else + if (not is_cpp_lambda_call_operator) || inside_cpp_lambda_expr then add_method trans_unit_ctx tenv cfg curr_class procname body ms return_param_typ_opt None extra_instrs ~is_destructor_wrapper in diff --git a/infer/src/clang/cTrans_utils.ml b/infer/src/clang/cTrans_utils.ml index fdd0a6447..78fc82140 100644 --- a/infer/src/clang/cTrans_utils.ml +++ b/infer/src/clang/cTrans_utils.ml @@ -195,8 +195,7 @@ type control = let pp_control fmt {root_nodes; leaf_nodes; instrs; initd_exps; cxx_temporary_markers_set} = let pp_cxx_temporary_markers_set fmt = - if List.is_empty cxx_temporary_markers_set then () - else + if not (List.is_empty cxx_temporary_markers_set) then F.fprintf fmt ";@;cxx_temporary_markers_set=[%a]" (Pp.seq ~sep:";" (Pvar.pp Pp.text)) cxx_temporary_markers_set diff --git a/infer/src/integration/BuckFlavors.ml b/infer/src/integration/BuckFlavors.ml index a13630da3..1838a0577 100644 --- a/infer/src/integration/BuckFlavors.ml +++ b/infer/src/integration/BuckFlavors.ml @@ -110,8 +110,7 @@ let capture build_cmd = let {command; rev_not_targets; targets} = add_flavors_to_buck_arguments ClangFlavors ~extra_flavors:[] buck_args in - if List.is_empty targets then () - else + if not (List.is_empty targets) then ( let all_args = List.rev_append rev_not_targets targets in let updated_buck_cmd = command @@ -122,4 +121,4 @@ let capture build_cmd = updated_buck_cmd ; let prog, buck_build_cmd = (prog, updated_buck_cmd) in ResultsDir.RunState.set_merge_capture true ; - clang_flavor_capture ~prog ~buck_build_cmd + clang_flavor_capture ~prog ~buck_build_cmd ) diff --git a/infer/src/pulse/PulseFormula.ml b/infer/src/pulse/PulseFormula.ml index 92825e8b3..103b2712a 100644 --- a/infer/src/pulse/PulseFormula.ml +++ b/infer/src/pulse/PulseFormula.ml @@ -99,15 +99,13 @@ end = struct if Var.Map.is_empty vs then Q.pp_print fmt c else let pp_c fmt c = - if Q.is_zero c then () - else + if not (Q.is_zero c) then let plusminus, c_pos = if Q.geq c Q.zero then ('+', c) else ('-', Q.neg c) in F.fprintf fmt " %c%a" plusminus Q.pp_print c_pos in let pp_coeff fmt q = - if Q.is_one q then () - else if Q.is_minus_one q then F.pp_print_string fmt "-" - else F.fprintf fmt "%a·" Q.pp_print q + if not (Q.is_one q) then + if Q.is_minus_one q then F.pp_print_string fmt "-" else F.fprintf fmt "%a·" Q.pp_print q in let pp_vs fmt vs = Pp.collection ~sep:" + "