ocaml.lang.best-practice.bool.ocamllint-bool-true

profile photo of semgrepsemgrep
Author
4,866
Download Count*

Comparison to boolean. Just use $X

Run Locally

Run in CI

Defintion

rules:
  - id: ocamllint-bool-true
    pattern-either:
      - pattern: $X = true
      - pattern: $X == true
      - pattern: $X != false
    message: Comparison to boolean. Just use `$X`
    languages:
      - ocaml
    severity: WARNING
    metadata:
      category: best-practice
      technology:
        - ocaml
      license: Commons Clause License Condition v1.0[LGPL-2.1-only]

Examples

bool.ml

let test a =
  (* ruleid:ocamllint-bool-true *)
  let x = a = true in
  (* ruleid:ocamllint-bool-true *)
  let x = a == true in
  (* ruleid:ocamllint-bool-false *)
  let x = a = false in
  (* ruleid:ocamllint-bool-false *)
  let x = a == false in
  (* ruleid:ocamllint-bool-true *)
  let x = a != false in
  (* ruleid:ocamllint-bool-false *)
  let x = a <> true in
  ()