Skip to content

Commit

Permalink
Add :safe declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
vemv authored and bbatsov committed Oct 4, 2021
1 parent 526d78e commit 2374343
Showing 1 changed file with 58 additions and 28 deletions.
86 changes: 58 additions & 28 deletions clj-refactor.el
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@
(defcustom cljr-add-ns-to-blank-clj-files t
"If t, automatically add a ns form to new .clj files."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-auto-sort-ns t
"If t, sort ns form after any command that changes it."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-magic-requires t
"Whether to automatically require common namespaces when they are used.
Expand All @@ -85,64 +87,75 @@ Any other non-nil value means to add the form without asking."
"Alist of aliases and namespaces used by `cljr-slash'."
:type '(repeat (cons (string :tag "Short alias")
(string :tag "Full namespace")))
:safe #'listp
:group 'cljr)

(defcustom cljr-project-clean-prompt t
"If t, `cljr-project-clean' asks before doing anything.
If nil, the project clean functions are run without warning."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-project-clean-functions
(list #'cljr-clean-ns)
"List of functions called by `cljr-project-clean'.
These are called on all .clj files in the project."
:group 'cljr
:type '(repeat function))
:type '(repeat function)
:safe #'listp)

(defcustom cljr-project-clean-exceptions '("dev/user.clj" "project.clj" "boot.clj")
"A list of files that `cljr-project-clean' should avoid."
:group 'cljr
:type '(repeat string))
:type '(repeat string)
:safe #'listp)

(defcustom cljr-hotload-dependencies nil
"If t, newly added dependencies are also hotloaded into the repl.
This only applies to dependencies added by `cljr-add-project-dependency'."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-favor-private-functions t
"If t, refactorings insert private function declarations."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-favor-prefix-notation nil
"If t, `cljr-clean-ns' favors prefix notation in the ns form."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-insert-newline-after-require t
"If t, `cljr-clean-ns' will place a newline after the `:require` and `:import` tokens."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-use-multiple-cursors t
"If t, some refactorings use the `multiple-cursors' package.
This improves interactivity of the commands. If nil, those
refactorings will use regular prompts instead."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-auto-clean-ns t
"If t, call `cljr-clean-ns' after commands that change the ns."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-populate-artifact-cache-on-startup t
"If t, the middleware will eagerly populate the artifact cache.
This makes `cljr-add-project-dependency' as snappy as can be."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-warn-on-eval t
"If t, warn the user before running any op that requires ASTs to be built
Expand All @@ -151,26 +164,30 @@ This makes `cljr-add-project-dependency' as snappy as can be."
so if this is on the AST cache is not warmed at startup or after certain
operations."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-eagerly-build-asts-on-startup t
"If t, the middleware will eagerly populate the ast cache.
This makes `cljr-find-usages' and `cljr-rename-symbol' as snappy
as can be."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-suppress-middleware-warnings nil
"If t, no middleware warnings are printed to the repl."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-suppress-no-project-warning nil
"If t, no warning is printed when starting a REPL outside a project.
By default, a warning is printed in this case since clj-refactor
will not work as expected in such REPLs."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-ignore-analyzer-errors nil
"If t, `cljr-find-usages' `cljr-inline-symbol' `cljr-rename-symbol'
Expand All @@ -182,58 +199,68 @@ namespaces which can be analyzed.
If nil, `cljr-find-usages' `cljr-inline-symbol' `cljr-rename-symbol'
won't run if there is a broken namespace in the project."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(define-obsolete-variable-alias 'cljr-find-usages-ignore-analyzer-errors 'cljr-ignore-analyzer-errors "2.3.0")

(defcustom cljr-auto-eval-ns-form t
"When true refactorings which change the ns form also trigger
its re-evaluation."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-midje-test-declaration "[midje.sweet :as midje]"
"The require form to use when midje is in use."
:group 'cljr
:type 'string)
:type 'string
:safe #'stringp)

(defcustom cljr-expectations-test-declaration "[expectations :as e]"
"The require form to use when expectations is in use."
:group 'cljr
:type 'string)
:type 'string
:safe #'stringp)

(defcustom cljr-cljc-clojure-test-declaration "#?(:clj [clojure.test :as t]
:cljs [cljs.test :as t :include-macros true])"
"The require form to use when clojure.test and cljs.test is in use in a cljc file."
:group 'cljr
:type 'string)
:type 'string
:safe #'stringp)

(defcustom cljr-cljs-clojure-test-declaration "[cljs.test :as t :include-macros true]"
"The require form to use when cljs.test is in use in a cljs file."
:group 'cljr
:type 'string)
:type 'string
:safe #'stringp)

(defcustom cljr-clojure-test-declaration "[clojure.test :as t]"
"The require form to use when clojure.test is in use in a clj file."
:group 'cljr
:type 'string)
:type 'string
:safe #'stringp)

(defcustom cljr-clojure-test-namespace-under-test-alias "sut"
"The package alias to use for the namespace under test."
:group 'cljr
:type 'string)
:type 'string
:safe #'stringp)

(defcustom cljr-inject-dependencies-at-jack-in t
"When nil, do not inject repl dependencies (most likely nREPL middlewares) at `cider-jack-in' time."
:group 'cljr
:type 'boolean)
:type 'boolean
:safe #'booleanp)

(defcustom cljr-assume-language-context nil
"If set to 'clj' or 'cljs', clj-refactor will use that value in situations
where the language context is ambiguous. If set to nil, a popup will be
created in each ambiguous case asking user to choose language context."
:group 'cljr
:type 'string)
:type 'string
:safe #'stringp)

(defcustom cljr-libspec-whitelist
'("^cljsns" "^slingshot.test" "^monger.joda-time" "^monger.json")
Expand All @@ -242,7 +269,8 @@ won't run if there is a broken namespace in the project."
This is useful when `clean-ns' should leave a libspec alone even
if it appears to be unused."
:group 'cljr
:type '(repeat string))
:type '(repeat string)
:safe #'listp)

(defvar cljr-minimum-clojure-version "1.8.0"
"The oldest Clojure version supported by our middleware.")
Expand Down Expand Up @@ -290,7 +318,8 @@ if it appears to be unused."
"List of (Java style) regexes to paths that should be ignored
by the middleware."
:group 'cljr
:type '(repeat string))
:type '(repeat string)
:safe #'listp)

;;; Buffer Local Declarations

Expand Down Expand Up @@ -3258,6 +3287,7 @@ If customizing it, you most likely should `(setq cljr-suppress-middleware-warnin
for avoiding a warning that would be irrelevant for this case."
:group 'cljr
:type 'string
:safe #'stringp
:package-version "3.0.0")

(defun cljr--middleware-version ()
Expand Down

0 comments on commit 2374343

Please sign in to comment.