Liking cljdoc? Tell your friends :D

Naming

naming/conventional-aliases

Enabled by defaultSafeAutocorrectVersion AddedVersion Updated
truetruefalse1.3.01.3.0

Through community and core practices over the years, various core libraries have gained standard or expected aliases. To better align with the community, it's best to use those aliases in favor of alternatives.

Current namespaces and aliases:

namespacealias
clojure.core.asyncasync
clojure.core.matrixmat
clojure.core.protocolsp
clojure.core.reducersr
clojure.data.csvcsv
clojure.data.xmlxml
clojure.datafydatafy
clojure.ednedn
clojure.java.ioio
clojure.java.shellsh
clojure.mathmath
clojure.pprintpp
clojure.setset
clojure.spec.alphas
clojure.stringstr
clojure.tools.clicli
clojure.tools.logginglog
clojure.walkwalk
clojure.zipzip

Examples

; avoid
(:require [clojure.string :as string])

; prefer
(:require [clojure.string :as str])

Reference


naming/conversion-functions

Enabled by defaultSafeAutocorrectVersion AddedVersion Updated
truefalsefalse0.1.940.1.94

Use -> instead of to in the names of conversion functions.

Will only warn when there is no - before the -to-.

Safety

Uses simple string checking and can misunderstand English intention when X-to-Y isn't a conversion function.

Examples

; avoid
(defn f-to-c ...)

; prefer
(defn f->c ...)
(defn expect-f-to-c ...)

Reference


naming/lisp-case

Enabled by defaultSafeAutocorrectVersion AddedVersion Updated
truefalsefalse1.3.01.3.0

Use lisp-case for function and variable names. (Replacement is generated with camel-snake-kebab.)

Safety

Interop, json, and other styles can make it necessary to use such forms.

Examples

; avoid
(def someVar ...)
(def some_fun ...)

; prefer
(def some-var ...)
(defn some-fun ...)

Reference


naming/predicate

Enabled by defaultSafeAutocorrectVersion AddedVersion Updated
truefalsefalse0.1.690.1.94

Functions that return a boolean should end in a question mark.

Safety

Doesn't verify the kind of function, just checks for anti-patterns in the names. Also doesn't actually check the classic Common Lisp convention as we have no way to know when a function name uses a word that naturally ends in a 'p' (such as map).

Examples

; avoid
(defn palindrome-p ...)
(defn is-palindrome ...)

; prefer
(defn palindrome? ...)

Reference


naming/record-name

Enabled by defaultSafeAutocorrectVersion AddedVersion Updated
truetruefalse0.1.691.15.2

Records should use PascalCase. (Replacement is generated with camel-snake-kebab.)

Examples

; avoid
(defrecord foo [a b c])
(defrecord foo-bar [a b c])
(defrecord Foo-bar [a b c])

; prefer
(defrecord Foo [a b c])
(defrecord FooBar [a b c])

Reference


naming/single-segment-namespace

Enabled by defaultSafeAutocorrectVersion AddedVersion Updated
truetruefalse1.3.01.3.0

Namespaces exist to disambiguate names. Using a single segment namespace puts you in direct conflict with everyone else using single segment namespaces, thus making it more likely you will conflict with another code base.

Examples

; avoid
(ns simple)

; prefer
(ns noahtheduke.simple)

Reference

Can you improve this documentation?Edit on GitHub

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

× close