ocaml.lang.correctness.useless_if.ocamllint-useless-if

profile photo of returntocorpreturntocorp
Author
5,693
Download Count*

Useless if. Both branches are equal.

Run Locally

Run in CI

Defintion

rules:
  - id: ocamllint-useless-if
    pattern: if $X then $E else $E
    message: Useless if. Both branches are equal.
    languages:
      - ocaml
    severity: ERROR
    metadata:
      category: correctness
      license: Commons Clause License Condition v1.0[LGPL-2.1-only]

Examples

useless_if.ml

let test a b =
  (* ruleid:ocamllint-useless-if *)
  if foo
  then a+b
  else a+b