DRSNJM / board-ultimatum

Board game recommendation web app using the board ultimatum library.
board-ultimatum.herokuapp.com
2 stars 0 forks source link

Improve Code Qualitiy #6

Closed RyanMcG closed 11 years ago

RyanMcG commented 12 years ago

I ran across a very cool static analysis tool called kibit. I ran it against our code and got the following. If you notice one of these in something you did then change it if you want. Or I might later... whatever.

At src/board_ultimatum/engine/model.clj:28: Consider using:

  (when-not (nil? (:username connection-info))
    (mg/authenticate
      db-name
      (:username connection-info)
      (into-array Character/TYPE (:password connection-info))))

instead of:

  (when (not (nil? (:username connection-info)))
    (mg/authenticate
      db-name
      (:username connection-info)
      (into-array Character/TYPE (:password connection-info))))

At src/board_ultimatum/engine/model.clj:null: Consider using:

  time-map

instead of:

  #(time-map %)

At src/board_ultimatum/engine/model.clj:null: Consider using:

  :value

instead of:

  #(:value %)

At src/board_ultimatum/engine/model.clj:69: Consider using:

  :tags

instead of:

  (fn [g] (:tags g))

At src/board_ultimatum/engine/model.clj:142: Consider using:

  (neg? (.indexOf (name num-key) "+"))

instead of:

  (< (.indexOf (name num-key) "+") 0)

At src/board_ultimatum/engine/model.clj:null: Consider using:

  recommended-num-player-votes

instead of:

  #(recommended-num-player-votes %1 %2)

At src/board_ultimatum/engine/model.clj:193: Consider using:

  (pos? (count players))

instead of:

  (> (count players) 0)

At src/board_ultimatum/engine/model.clj:228: Consider using:

  (pos? (:score p1__224194#))

instead of:

  (> (:score p1__224194#) 0)

At src/board_ultimatum/engine/model.clj:237: Consider using:

  (pos? (count selected-times))

instead of:

  (> (count selected-times) 0)

At src/board_ultimatum/engine/model.clj:243: Consider using:

  (pos? (count selected-num-players))

instead of:

  (> (count selected-num-players) 0)

Check failed -- skipping rest of file java.lang.RuntimeException: Map literal must contain an even number of forms At src/board_ultimatum/engine/neural.clj:52: Consider using:

  (vec (map (fn [game] (:bgg_id game)) (model/find-all)))

instead of:

  (into [] (map (fn [game] (:bgg_id game)) (model/find-all)))

At src/board_ultimatum/engine/neural.clj:54: Consider using:

  :bgg_id

instead of:

  (fn [game] (:bgg_id game))

At src/board_ultimatum/engine/neural.clj:60: Consider using:

  (vec (concat (get-vector id-A) (get-vector id-B)))

instead of:

  (into [] (concat (get-vector id-A) (get-vector id-B)))

At src/board_ultimatum/engine/neural.clj:66: Consider using:

  (.getData (. net compute (. pair getInput)) 0)

instead of:

  (. (. net compute (. pair getInput)) getData 0)

At src/board_ultimatum/engine/neural.clj:66: Consider using:

  (.compute net (. pair getInput))

instead of:

  (. net compute (. pair getInput))

At src/board_ultimatum/engine/neural.clj:66: Consider using:

  (.getInput pair)

instead of:

  (. pair getInput)

At src/board_ultimatum/engine/vector_convert.clj:42: Consider using:

  (set
    (remove
      nil?
      (map
        (fn [tag] (cond (= (:subtype tag) "category") (:value tag)))
        (:tags game))))

instead of:

  (into
    #{}
    (remove
      nil?
      (map
        (fn [tag] (cond (= (:subtype tag) "category") (:value tag)))
        (:tags game))))

At src/board_ultimatum/engine/vector_convert.clj:48: Consider using:

  (set
    (remove
      nil?
      (map
        (fn [tag] (cond (= (:subtype tag) "mechanic") (:value tag)))
        (:tags game))))

instead of:

  (into
    #{}
    (remove
      nil?
      (map
        (fn [tag] (cond (= (:subtype tag) "mechanic") (:value tag)))
        (:tags game))))

At src/board_ultimatum/engine/vector_convert.clj:201: Consider using:

  (vec (map (fn [game] (:bgg_id game)) (model/find-all)))

instead of:

  (into [] (map (fn [game] (:bgg_id game)) (model/find-all)))

At src/board_ultimatum/engine/vector_convert.clj:203: Consider using:

  :bgg_id

instead of:

  (fn [game] (:bgg_id game))

At src/board_ultimatum/engine/vector_convert.clj:206: Consider using:

  (vec (map (fn [game] (:data game)) (map to-vector (model/find-all))))

instead of:

  (into
    []
    (map (fn [game] (:data game)) (map to-vector (model/find-all))))

At src/board_ultimatum/engine/vector_convert.clj:207: Consider using:

  :data

instead of:

  (fn [game] (:data game))

At src/board_ultimatum/engine/vector_convert.clj:217: Consider using:

  (vec (map (fn [i] (sel components :cols i)) (range 10)))

instead of:

  (into [] (map (fn [i] (sel components :cols i)) (range 10)))

At src/board_ultimatum/engine/vector_convert.clj:222: Consider using:

  (vec (map (fn [i] (mmult full-data (nth pc i))) (range 10)))

instead of:

  (into [] (map (fn [i] (mmult full-data (nth pc i))) (range 10)))

At src/board_ultimatum/views/common.clj:47: Consider using:

  (when (seq errs) [:div.help-block [:ul (map #(html [:li %]) errs)]])

instead of:

  (when-not (empty? errs)
    [:div.help-block [:ul (map #(html [:li %]) errs)]])

At src/board_ultimatum/views/expert.clj:101: Consider using:

  (zero? remainder)

instead of:

  (= remainder 0)

At src/board_ultimatum/views/expert.clj:216: Consider using:

  (remove input-game-filter games)

instead of:

  (filter (complement input-game-filter) games)

At src/board_ultimatum/views/expert.clj:230: Consider using:

  (when (seq relationships)
    (relationship/add-many
      (into
        {}
        (map
          (fn [[pair-str value]] [(map
                                    #(Integer/parseInt %)
                                    (string/split
                                      pair-str
                                      (re-pattern "-")))
                                  (Integer/parseInt value)])
          relationships))
      (current-expert-id)))

instead of:

  (when-not (empty? relationships)
    (relationship/add-many
      (into
        {}
        (map
          (fn [[pair-str value]] [(map
                                    #(Integer/parseInt %)
                                    (string/split
                                      pair-str
                                      (re-pattern "-")))
                                  (Integer/parseInt value)])
          relationships))
      (current-expert-id)))
RyanMcG commented 11 years ago

Duplicate of #5.