Best practice
ocamllint-bool-true
ocamllint-bool-true
Comparison to boolean. Just use $X
ocamllint-bool-false
ocamllint-bool-false
Comparison to boolean. Just use not $X
ocamllint-str-first-chars
ocamllint-str-first-chars
Use instead Str.first_chars
ocamllint-str-string-after
ocamllint-str-string-after
Use instead Str.string_after
ocamllint-str-last-chars
ocamllint-str-last-chars
Use instead Str.last_chars
ocamllint-useless-sprintf
ocamllint-useless-sprintf
Useless sprintf
bad-reraise
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’.
ocamllint-useless-else
ocamllint-useless-else
Useless else. Just remove the else branch;
ocamllint-backwards-if
ocamllint-backwards-if
Backwards if. Rewrite the code as ‘if not E2’.
hashtbl-find-outside-try
hashtbl-find-outside-try
You should not use Hashtbl.find outside of a try, or you should use Hashtbl.find_opt
list-find-outside-try
list-find-outside-try
You should not use List.find outside of a try, or you should use List.find_opt
ocamllint-ref-incr
ocamllint-ref-incr
You should use incr
ocamllint-ref-decr
ocamllint-ref-decr
You should use decr