๐Ÿ“ฆ Bogdanp / racket-review

A linter for Racket.

โ˜… 46 stars โ‘‚ 4 forks ๐Ÿ‘ 46 watching โš–๏ธ BSD 3-Clause "New" or "Revised" License
linterracket
๐Ÿ“ฅ Clone https://github.com/Bogdanp/racket-review.git
HTTPS git clone https://github.com/Bogdanp/racket-review.git
SSH git clone git@github.com:Bogdanp/racket-review.git
CLI gh repo clone Bogdanp/racket-review
Bogdan Popa Bogdan Popa lint: improve handling of class{,*} forms 5c95228 1 days ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ elisp
๐Ÿ“ media
๐Ÿ“ tests
๐Ÿ“„ .gitignore
๐Ÿ“„ cli.rkt
๐Ÿ“„ ext.rkt
๐Ÿ“„ info.rkt
๐Ÿ“„ LICENSE
๐Ÿ“„ lint.rkt
๐Ÿ“„ problem.rkt
๐Ÿ“„ README.md
๐Ÿ“„ run-tests.rkt
๐Ÿ“„ README.md

racket-review

GitHub Actions status

a screenshot of racket-review being used inside Emacs

racket-review performs surface-level linting of individual Racket modules with the intent of finding issues as quickly as it can. It does not expand the programs it lints, so there may be cases where it is wrong, but, in practice, it performs reasonably well on #lang racket{,/base} programs.

It currently reports the following issues:

  • [error] "identifier is already defined"
  • [error] "if expressions must contain one expression for the then-branch and another for the else-branch"
  • [error] "let forms must contain at least one body expression"
  • [error] "syntax error"
  • [error] "use _ instead of else in the fallthrough case of a match expression"
  • [error] "case clause must be in the form ( ...), not '"
  • [error] "use '() for match pattern instead of null or empty"
  • [warning] "bindings within a let should be surrounded by square brackets"
[warning] "identifier provided but not defined" [warning] "identifier is already defined" [warning] "identifier is never used" [warning] "identifier shadows an earlier binding"
  • [warning] "missing module (#lang) declaration"
  • [warning] "require (for-syntax ...) should come before all others"
[warning] "require should come after *" [warning] "require should come before *"
  • [warning] "this cond expression does not have an else clause"
  • [warning] "use a cond expression instead of nesting begin or let inside an if"
Various packages provide [extensions] to these rules.

Setup

$ raco pkg install review

Usage

$ raco review filename.rkt

To tell the linter to ignore an entire module, add a comment like

`` racket #|review: ignore|# %%CODEBLOCK0%% racket ;; noqa ;; lint: ignore ;; review: ignore %%CODEBLOCK1%% emacs-lisp (flycheck-define-checker racket-review "check racket source code using racket-review" :command ("raco" "review" source) :error-patterns ((error line-start (file-name) ":" line ":" column ":error:" (message) line-end) (warning line-start (file-name) ":" line ":" column ":warning:" (message) line-end)) :modes racket-mode) (add-to-list 'flycheck-checkers 'racket-review) %%CODEBLOCK2%%shell (cd elisp && make install) ``

Prior work

  • http://planet.racket-lang.org/package-source/clements/no-brainer.plt/1/5/
  • http://tmp.barzilay.org/code-ayatollah.rkt
  • https://github.com/jackfirth/syntax-warn

License

racket-review is licensed under the 3-Clause BSD license.