Skip to content

Commit 75ce642

Browse files
committed
quality-gate: capture more unnecessary List.length cases
Signed-off-by: Pau Ruiz Safont <pau.safont@vates.tech>
1 parent 91e949e commit 75ce642

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

ocaml/sdk-gen/c/gen_c_binding.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ and gen_impl cls =
346346
; ("async_params", `A (List.map paramJson (asyncParams msg)))
347347
; ("msg_params", `A (List.map paramJson msg.msg_params))
348348
; ("abstract_result_type", `String (result_type msg))
349-
; ("has_params", `Bool (List.length msg.msg_params <> 0))
349+
; ("has_params", `Bool (msg.msg_params <> []))
350350
; ("param_count", `String (string_of_int (List.length msg.msg_params)))
351351
; ("has_result", `Bool (String.compare (result_type msg) "" <> 0))
352352
; ("init_result", `Bool (init_result msg))

ocaml/xapi/repository.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ let sync ~__context ~self ~token ~token_id ~username ~password =
232232
Xapi_stdext_pervasives.Pervasiveext.finally
233233
(fun () ->
234234
let config_repo config =
235-
if List.length config <> 0 then (* Set params to yum/dnf *)
235+
if config <> [] then (* Set params to yum/dnf *)
236236
let Pkg_mgr.{cmd; params} = Pkgs.config_repo ~repo_name ~config in
237237
ignore
238238
(Helpers.call_script ~log_output:Helpers.On_failure cmd params)

ocaml/xapi/xapi_vm_lifecycle.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,7 @@ let check_operation_error ~__context ~ref =
507507
(* if other operations are in progress, check that the new operation is allowed concurrently with them. *)
508508
let current_error =
509509
check current_error (fun () ->
510-
if
511-
List.length current_ops <> 0
512-
&& not (is_allowed_concurrently ~op ~current_ops)
510+
if current_ops <> [] && not (is_allowed_concurrently ~op ~current_ops)
513511
then
514512
report_concurrent_operations_error ~current_ops ~ref_str
515513
else

quality-gate.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ unnecessary-length () {
130130
UNNECESSARY_LENGTH=$(local_grep "List.length.*=+\s*0")
131131
UNNECESSARY_LENGTH=$((UNNECESSARY_LENGTH+$(local_grep "0\s*=+\s*List.length")))
132132
UNNECESSARY_LENGTH=$((UNNECESSARY_LENGTH+$(local_grep "List.length.*\s>\s*0")))
133+
UNNECESSARY_LENGTH=$((UNNECESSARY_LENGTH+$(local_grep "List.length.*\s<>\s*0")))
133134
UNNECESSARY_LENGTH=$((UNNECESSARY_LENGTH+$(local_grep "0\s*<\s*List.length")))
135+
UNNECESSARY_LENGTH=$((UNNECESSARY_LENGTH+$(local_grep "0\s*<>\s*List.length")))
134136
UNNECESSARY_LENGTH=$((UNNECESSARY_LENGTH+$(local_grep "List.length.*\s<\s*1")))
135137
UNNECESSARY_LENGTH=$((UNNECESSARY_LENGTH+$(local_grep "1\s*>\s*List.length")))
136138
if [ "$UNNECESSARY_LENGTH" -eq "$N" ]; then

0 commit comments

Comments
 (0)