> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codeant.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Best practice

<AccordionGroup>
  <Accordion title="ocamllint-bool-true">
    Comparison to boolean. Just use `$X`
  </Accordion>

  <Accordion title="ocamllint-bool-false">
    Comparison to boolean. Just use `not $X`
  </Accordion>

  <Accordion title="ocamllint-str-first-chars">
    Use instead `Str.first_chars`
  </Accordion>

  <Accordion title="ocamllint-str-string-after">
    Use instead `Str.string_after`
  </Accordion>

  <Accordion title="ocamllint-str-last-chars">
    Use instead `Str.last_chars`
  </Accordion>

  <Accordion title="ocamllint-useless-sprintf">
    Useless sprintf
  </Accordion>

  <Accordion title="bad-reraise">
    You should not re-raise exceptions using 'raise' because it loses track of where the exception was raised originally, leading to a useless and possibly confusing stack trace. Instead, you should obtain a stack backtrace as soon as the exception is caught using 'try ... with exn -> let trace = Printexc.get\_raw\_backtrace () in ...', and keep it around until you re-raise the exception using 'Printexc.raise\_with\_backtrace exn trace'. You must collect the stack backtrace before calling another function which might internally raise and catch exceptions. To avoid false positives from Semgrep, write 'raise (Foo args)' instead of 'let e = Foo args in raise e'.
  </Accordion>

  <Accordion title="ocamllint-useless-else">
    Useless else. Just remove the else branch;
  </Accordion>

  <Accordion title="ocamllint-backwards-if">
    Backwards if. Rewrite the code as 'if not $E then $E2'.
  </Accordion>

  <Accordion title="hashtbl-find-outside-try">
    You should not use Hashtbl.find outside of a try, or you should use Hashtbl.find\_opt
  </Accordion>

  <Accordion title="list-find-outside-try">
    You should not use List.find outside of a try, or you should use List.find\_opt
  </Accordion>

  <Accordion title="ocamllint-ref-incr">
    You should use `incr`
  </Accordion>

  <Accordion title="ocamllint-ref-decr">
    You should use `decr`
  </Accordion>
</AccordionGroup>
