Added a rule for pointless/sloppy if statements
This commit is contained in:
parent
95a3704279
commit
46180fb1af
2 changed files with 22 additions and 2 deletions
|
@ -5,5 +5,6 @@
|
|||
(if ?x nil ?y) when-not
|
||||
(if ?x (do . ?y)) when
|
||||
(if (not ?x) ?y ?z) if-not
|
||||
(when (not ?x) . ?y) when-not})
|
||||
|
||||
(when (not ?x) . ?y) when-not
|
||||
(if true ?x . ?y) "do or removing the if"})
|
||||
|
||||
|
|
19
test/kibit/test/control_structures.clj
Normal file
19
test/kibit/test/control_structures.clj
Normal file
|
@ -0,0 +1,19 @@
|
|||
(ns kibit.test.control-structures
|
||||
(:require [jonase.kibit.core :as kibit])
|
||||
(:use [clojure.test]))
|
||||
|
||||
;; ==========
|
||||
;; NOTE
|
||||
;; ==============
|
||||
;; YOU SHOULD ALWAYS CHECK WITH ALL RULES
|
||||
;;
|
||||
;; Please ensure that new rules generate fully expected results across all
|
||||
;; rule sets.
|
||||
|
||||
(deftest sloppy-if
|
||||
(let [exp-data '(if true (println "X"))
|
||||
expected "[Kibit] Consider do or removing the if instead of (if true (println \"X\"))"
|
||||
actual (doall (kibit/check-form exp-data))]
|
||||
(is (= (count actual) 1))
|
||||
(is (= expected (first actual)))))
|
||||
|
Loading…
Reference in a new issue