ocaml.lang.best-practice.ifs.ocamllint-backwards-if

Author
4,866
Download Count*
License
Backwards if. Rewrite the code as 'if not $E then $E2'.
Run Locally
Run in CI
Defintion
rules:
- id: ocamllint-backwards-if
pattern: if $E then () else $E2
message: Backwards if. Rewrite the code as 'if not $E then $E2'.
languages:
- ocaml
severity: WARNING
metadata:
category: best-practice
technology:
- ocaml
license: Commons Clause License Condition v1.0[LGPL-2.1-only]
Examples
ifs.ml
let test a =
(* ruleid:ocamllint-useless-else *)
if a
then print_string a
else ()
let test2 a =
(* ruleid:ocamllint-backwards-if *)
if a
then ()
else print_string a
Short Link: https://sg.run/b7Ov