Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

New rule to detect wrong character syntax #63

Open
wants to merge 1 commit into from

2 participants

@arosequist

Detects when character literals are written as 'a' instead of \a.

@danielcompton
Collaborator

This makes incorrect suggestions for

(def a' 1)
(check-file "test.clj")
At test.clj:null:
Consider using:
  \a
instead of:
  a'

Additionally ' is never used for any kind of character or string literals in Clojure so I'm not sure whether people would find this rule useful. Would this have caught some errors for you?

@danielcompton danielcompton self-assigned this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 2, 2012
  1. @arosequist
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 1 deletion.
  1. +8 −0 src/kibit/rules/misc.clj
  2. +2 −1  test/kibit/test/misc.clj
View
8 src/kibit/rules/misc.clj
@@ -99,6 +99,14 @@
(logic/project [form]
(logic/== sbst (concat form (list arg)))))]))])
+ ;; Wrong character syntax
+ (let [sym (logic/lvar)]
+ [#(logic/all
+ (logic/== % sym)
+ (logic/pred sym symbol?)
+ (logic/pred sym (fn [sym] (.matches (name sym) ".'"))))
+ #(logic/project [sym]
+ (logic/== % (first (name sym))))])
;; Other
[(not (some ?pred ?coll)) (not-any? ?pred ?coll)])
View
3  test/kibit/test/misc.clj
@@ -29,4 +29,5 @@
'(form arg) '(->> arg form)
'(:form arg) '(->> arg :form)
'(first-of-form rest-of-form arg) '(->> arg (first-of-form rest-of-form))
- '(not-any? pred coll) '(not (some pred coll))))
+ '(not-any? pred coll) '(not (some pred coll))
+ \a 'a'))
Something went wrong with that request. Please try again.