Added a rule for pointless/sloppy if statements

This commit is contained in:
Paul deGrandis 2012-03-05 12:42:03 -05:00
parent 95a3704279
commit 46180fb1af
2 changed files with 22 additions and 2 deletions

View file

@ -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"})

View 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)))))