package camelot

  1. Overview
  2. Docs
An OCaml Linter / Style Checker

Install

Dune Dependency

Authors

Maintainers

Sources

1.4.4.tar.gz
md5=40eb62589bbe9712a429b9d35c8f0a02
sha512=9c6f99aabd1b2e0b12aa34b3e4b780b8a89d8d78221c956d14ac1562913bd020f5813d6c621f8e5607c09dc9c67741b2cf8c0e0704a8e3a9b9c0ae03b198a655

Description

Published: 25 Sep 2020

README

Camelot

An OCaml Linter / Style Checker for the OCaml compiler version 4.10.0. Make sure you have ocaml version 4.10.0, otherwise the parsetree will be different

Dependencies (handled by opam)

  • ocaml >= v4.10.0

  • dune >= 2.5.0

  • compiler-libs.common

  • fswatch (for Build + Watch)

  • ANSITerminal

  • ppx_expect >= 0.13.1 (for testing)

  • yojson >= 1.7.0

  • odoc (for documentation builds)

Note:

This project is dependent on compiler-libs, an inherently unstable library that changes between OCaml installations.

Installation

To install from the latest opam release, run: opam install camelot

Building From Source

Build: dune build bin/camelot.exe

Build + Watch: dune build bin/camelot.exe -w

Writing and running tests

To run tests: dune test

If any changes you make break code, dune test will flag it and highlight the differences. If there are no issues, dune will not print anything.

To write tests, see the dune documentation for expect-tests. If you implement a new rule, you'll have to do the following:

  • Add your test case ( a program that you expect the linter to show a match for) to either a new file or an existing file in the examples/ directory.

    • If you create a new file in the examples/ directory, edit the dune file's deps stanza to make it visible to the build system. If you create a new programs file in examples/, you'll have to add a new let%expect_test in the style of the ones prior to the file test.ml, except with the ``[%expect {| ... |} ]``` clause blank.

    • If you added a test program to an existing file, it'll automatically be linted by the appropriate expect_test.

  • Run dune runtest. If your code for linting worked, runtest should highlight that there was a difference due to your new rule - run dune promote to accept this difference. Only promote if the difference that dune shows is appropriate - if there is a difference in the linted output, verify that your code did not break things, fix the issue, and then promote.

  • Reloading test.ml should show that the difference was added to the appropriate expect tests. In a PR, mention this - the reviewer should examine the expect test and make sure it makes sense (e.g. that the old prints were not messed up + the new test case appropriately printed).

Camelot flags

-d <lintdir> : Specify the directory in which to lint

-show <ta | student | gradescope> : Specify the reporting type - does a student see this output or a ta? If this argument is malformed or not present, the reporting type defaults to student

-f <filename> : Lints the given file

Acknowledgements

This project wouldn't have been possible without the following three repos:

  • sml-style-check from the folks at CMU: for guiding the design of the linter, as well as basically contributing the structure of our project (especially the extendable checker modules :) ),

  • hlint for a good reference on building a linter,

  • ppx_tools/rewriter, for giving us useful starter code and being the building block on which camelot started.

Dependencies (4)

  1. yojson >= "1.7.0"
  2. ANSITerminal >= "0.8"
  3. ocaml >= "4.10.0" & < "4.13"
  4. dune >= "2.5"

Dev Dependencies (2)

  1. odoc with-doc & >= "1.5.0"
  2. ppx_expect with-test & >= "v0.13.0"

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.