Home

Awesome

Aave

malli powered code checking for Clojure.

Pre-alpha - highly subject to change.

“Wherever we find orderly, stable systems in Nature, we find that they are hierarchically structured, for the simple reason that without such structuring of complex systems into sub-assemblies, there could be no order and stability-except the order of a dead universr filled with a uniformly distributed gas.”

-- Arthur Koestler, The Ghost in the Machine

About

aave enables you to write inline schema definitions for your functions. It is highly configurable enabling you to choose what happens when various checks fail. It also provides utilities for common code-quality checks, such as naming conventions.

Examples / Features

In/Outstrumentation

Checks that function inputs and outputs adhere to their schemas before/after invoking function bodies.

Flags:

Hooks:

(ns example
  (:require [aave.core :refer [>defn] :as a]))

(>defn bad-return-val
  [x y]
  [int? int? => string?]
  (+ x y))

;; (bad-return-val 1 "foo") will raise `on-instrument-fail`
;; (bad-return-val 1 2) will raise `on-outstrument-fail`

Stub Generation

Causes function definitions with empty bodies to return randomly generated data instead of nil.

Flags:

(ns example
  (:require [aave.core :refer [>defn] :as a]))

(>defn add
  {::a/generate-stubs true}
  [x y]
  [int? int? => int?])

;; (add 1 2) => -1

Purity Enforcement

Checks that functions that call functions with ! are also named with a !.

Flags:

Hooks:

(ns example
  (:require [aave.core :refer [>defn] :as a]))

(def counter (atom nil))

(>defn increment-counter
  "Increments the coutner and returns the old value"
  {::a/enforce-purity true
   ::a/on-purity-fail (fn [] (throw (ex-info "Purity mismatch")))}
  []
  [=> int?]
  (swap! some-atom inc)))
;; Will raise an exception. Will pass if function is named `increment-counter!`

Development

aave is an open-source project and contributions are more than welcome!

Roadmap

Testing

clojure -Atest

Important Namespaces

Inspiration

Aave borrows and builds upon ideas of many fantastic projects. Most directly, it is largely inspired by tools like ghostwheel and orchestra. Thanks to the authors and many others that have provided an amazing foundation of ideas to build upon.