Skip to content
hyphatechPublic

About

The linter for modern OCaml.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

litany

ci release license OCaml 5.5 Hypha Stack

The linter for modern OCaml. Deterministic and fixable. Reads what the compiler wrote.

Hypha's fork of invariant-hq/litany.

Documentation: hyphatech.github.io/litany

Features

  • The compiler's own view: rules read the typed tree, and a stale artifact is a skip, never a stale finding.
  • Identity, not spelling: an alias or an open fires, and a local name that shadows one never does.
  • Fixes that compile: a safe fix is proven by its rule's tests, and every write must reparse.
  • In your editor: one dune rule brings findings in as compiler warnings.
  • Suppressions audited: an allow needs a reason, and one that hides nothing is a finding.

Install

opam repo add open-opam https://github.com/open-opam/opam-repository.git
opam install hypha-litany

Install it in the switch of the project it lints, on OCaml 5.5.

Example

(* lib/inventory.ml *)
type t = { stock : (string * int) list }

let restock t = t
let check t = if List.length t.stock = 0 then restock t else t
let find t name = List.find (fun (n, _) -> n == name) t.stock
$ litany check
File "lib/inventory.ml", line 4, characters 17-40:
4 | let check t = if List.length t.stock = 0 then restock t else t
                     ^^^^^^^^^^^^^^^^^^^^^^^
Warning 0 [needless-list-length]: comparison through List.length is a needless emptiness test
  fix (safe): compare with []

File "lib/inventory.ml", line 5, characters 43-52:
5 | let find t name = List.find (fun (n, _) -> n == name) t.stock
                                               ^^^^^^^^^
Warning 0 [suspicious-physical-equality]: physical comparison has a non-immediate operand

30 rules selected · 1 unit · 2 findings (1 fixable — run `litany check --fix`) · 0 skipped

litany check --fix rewrites the first to t.stock = []; the second has no fix, since that judgement is yours. Next: Getting started and all 84 rules.

Contributing

See AGENTS.md.

Licence

ISC, copyright Invariant Systems and Hypha Technologies Ltd. See LICENSE.

About

The linter for modern OCaml.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages