Liking cljdoc? Tell your friends :D

Linters

SICMUtils ships with a configuration that allows clj-kondo to lint the library's macros. This page contains installation instructions, as well as a directory of all customizable linter warnings.

For all available linters offered by clj-kondo, see their linters.md.

Table of Contents

Installation

To use the configuration exported by SICMUtils, you'll need to install it into your project.

The steps listed here mirror the instructions in the clj-kondo repo.

To install the exported linter configuration:

  1. Install the SICMUtils dependency into your project using the appropriate entry listed at Clojars. For example, If you are using deps.edn, add the project to the map under :deps:
;; See https://clojars.org/sicmutils to pick an explicit version!
{:deps
 {sicmutils/sicmutils {:mvn/version "RELEASE"}}
  1. Install clj-kondo using these instructions. I highly recommend configuring editor integration for your text editor.

3.. If it doesn't exist yet, create a .clj-kondo folder in your project:

mkdir .clj-kondo
  1. Run clj-kondo using the following command. This will import the sicmutils config and populate clj-kondo's cache with linting information about all of your dependencies:
# If you're using Leiningen:
$ clj-kondo --copy-configs --dependencies --lint "$(lein classpath)"
Imported config to .clj-kondo/sicmutils/sicmutils. To activate, add "sicmutils/sicmutils" to :config-paths in .clj-kondo/config.edn.

# If you're using deps.edn:
$ clj-kondo --copy-configs --dependencies --lint "$(clojure -Spath)"
Imported config to .clj-kondo/sicmutils/sicmutils. To activate, add "sicmutils/sicmutils" to :config-paths in .clj-kondo/config.edn.
  1. As instructed, either create or edit .clj-kondo/config.edn so that it contains a :config-paths entry with "sicmutils/sicmutils":
{:config-paths ["clj-kondo/claypoole"]}
  1. Check the imported files into source control in your project.

Linter Directory

This section describes all of the custom warnings emitted by the SICMUtils clj-kondo config.

Invalid Pattern Binding Symbol

Keyword: :sicmutils.pattern/binding-sym

Description: warn when a binding form like (? x) in the pattern argument to a pattern.rule macro contains anything other than a simple, non-qualified symbol.

Default level: :error

Example trigger:

(require '[sicmutils.rule :as r])

(r/rule (+ (? "x") ?y) => "match!")

Example message:: Binding variable "x" must be a non-namespaced symbol.

Ignored Segment Restriction

Keyword: :sicmutils.pattern/ignored-restriction

Description: warn when a segment binding form like (?? x) or ($$ x) contain restrictions like (?? x all-odd?). These don't error but aren't currently used.

Default level: :warning

Example trigger:

.clj-kondo/config.edn:

(require '[sicmutils.rule :as r])

(r/rule (+ (?? x odd?) ?y) => "match!")

Example message: Restrictions are (currently) ignored on ?? binding forms: odd?

Invalid Restriction in Consequence

Keyword: :sicmutils.pattern/consequence-restriction

Description: warn when a binding form like (? x), (?? x) or ($$ x) in a consequence contains restrictions like (? x odd?). These are meaningless in consequences, and may error in the future.

Default level: :error

Example trigger:

(require '[sicmutils.rule :as r])

(r/rule (+ (? x) (? y)) => (+ (? y odd?) (? x)))

Example message: Restrictions are not allowed in consequence bindings: odd?.

Ruleset Argument Count

Keyword: :sicmutils.pattern/ruleset-args

Description: warn when the sicmutils.pattern/ruleset receives arguments that aren't grouped into three. Each triplet should match the arguments you would supply to the 3-arity of sicmutils.pattern/rule.

Default level: :error

Example trigger:

(require '[sicmutils.rule :as r])

(r/ruleset (+ (? x) (? y))
           (fn [m] (- ('?x m) ('?y m))))

Example message: ruleset requires bindings in groups of 3. Received 2 bindings.

Invalid with-literal-functions Binding

Keyword: :sicmutils.abstract.function/invalid-binding

Description: warn when an binding entry passed to the first argument of with-literal-functions (in either sicmutils.abstract.function or sicmutils.env) is anything other than an unqualified symbol or a 3-vector containing a symbol, a domain and a range.

Default level: :error

Example trigger:

(require '[sicmutils.env :as e])

(e/with-literal-functions [x 10 y]
  [x y])

Example message: Bindings must be either bare symbols or 3-vectors of the form [sym domain range]. Received: 10.

Invalid Coordinate System Bindings

Keyword: :sicmutils.calculus.coordinate/invalid-binding

Description: warn when the left side of a binding pair passed to let-coordinates or using-coordinates (in either sicmutils.calculus.coordinate or sicmutils.env) is anything other than a potentially-nested structure of vectors or lists beginning with up or down with unqualified symbols at the leaves.

Default level: :error

Example trigger:

(require '[sicmutils.env :as e])

(e/let-coordinates [[x (up {:key "val"})] R3-rect]
  ,,,)

Example message: Bindings must be either a vector or list (optionally beginning withupordown) or a bare symbol. Received: {:key "val"}.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close