This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Cleanup based on kibit output, thank you @jonase

  • Loading branch information...
1 parent c9ea592 commit 356016548b64f30d68c98680ae78238c17b4decd @semperos committed Mar 13, 2012
@@ -136,19 +136,19 @@
(let [excludes (get-in driver [:cache-spec :exclude])]
(if (element? query)
;; WebElement
- (let [excludes (remove #(map? %) excludes)]
+ (let [excludes (remove map? excludes)]
(not (some #{true} (map (fn [f] (f query)) excludes))))
;; xpath, css or ancestry
- (let [excludes (remove #(fn? %) excludes)]
+ (let [excludes (remove fn? excludes)]
(not (some (fn [exclude-item] (= query exclude-item)) excludes)))))
;; handle includes
(let [includes (get-in driver [:cache-spec :include])]
(if (element? query)
;; WebElement
- (let [includes (remove #(map? %) includes)]
+ (let [includes (remove map? includes)]
(some #{true} (map (fn [f] (f query)) includes)))
;; xpath, css or ancestry
- (let [includes (remove #(fn? %) includes)]
+ (let [includes (remove fn? includes)]
(some (fn [include-item] (= query include-item)) includes))))))))
(defn set-status
@@ -206,7 +206,7 @@
(vector? bindings) "a vector for its binding"
(even? (count bindings)) "an even number of forms in binding vector")
(cond
- (= (count bindings) 0) `(do ~@body)
+ (zero? (count bindings)) `(do ~@body)
(symbol? (bindings 0)) `(let ~(subvec bindings 0 2)
(try
(with-driver ~(subvec bindings 2) ~@body)
@@ -57,7 +57,7 @@
(let [expr (str expr)]
(if (re-find #"\s" expr)
(let [classes (string/split expr #"\s+")
- class-query (apply str (interpose "." classes))]
+ class-query (string/join "." classes)]
(by-css (str "*." class-query)))
(By/className (name expr)))))
@@ -71,7 +71,7 @@
(cond
(= :class attr) (if (re-find #"\s" value)
(let [classes (string/split value #"\s+")
- class-query (apply str (interpose "." classes))]
+ class-query (string/join "." classes)]
(by-css (str (name tag) class-query)))
(by-class-name value))
(= :id attr) (by-id value)
@@ -231,12 +231,10 @@
(find-elements
([driver attr-val]
- (if (and (or
- (map? attr-val)
- (vector? attr-val))
- (empty? attr-val))
- ;; Return nil, not everything
- nil
+ (when-not (and (or
+ (map? attr-val)
+ (vector? attr-val))
+ (empty? attr-val))
(try
(cond
;; Accept by-clauses
@@ -25,9 +25,8 @@
"truespeed", "willvalidate"]
webdriver-result (.getAttribute (:webelement element) (name attr))]
(if (some #{attr} boolean-attrs)
- (if (= webdriver-result "true")
- attr
- nil)
+ (when (= webdriver-result "true")
+ attr)
webdriver-result))))
(click [element]

0 comments on commit 3560165

Please sign in to comment.