Skip to content

Commit

Permalink
add clj-kondo to linting phase
Browse files Browse the repository at this point in the history
Signed-off-by: yenda <[email protected]>
  • Loading branch information
yenda committed May 7, 2020
1 parent 8b81c9a commit 1bf6809
Show file tree
Hide file tree
Showing 172 changed files with 1,095 additions and 1,393 deletions.
3 changes: 2 additions & 1 deletion .clj-kondo/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
status-im.utils.fx/defn clj-kondo.lint-as/def-catch-all
quo.previews.preview/list-comp clojure.core/for
status-im.utils.styles/def clojure.core/def
status-im.utils.styles/defn clojure.core/defn}
status-im.utils.styles/defn clojure.core/defn
taoensso.tufte/defnp clojure.core/defn}
:linters {:invalid-arity {:skip-args [status-im.utils.fx/defn]}
;;TODO remove number when this is fixed
;;https://github.com/borkdude/clj-kondo/issues/867
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ endif

lint: export TARGET := clojure
lint: ##@test Run code style checks
yarn clj-kondo --confg .clj-kondo/config.edn --lint src && \
clojure -Sdeps '{:deps {cljfmt {:mvn/version "0.6.7"}}}' \
-m cljfmt.main check src \
--indents indentation.edn
Expand Down Expand Up @@ -391,4 +392,4 @@ repl-ios: ##@repl-ios start repl for ios project

repl-android: export TARGET := clojure
repl-android: ##@repl-android start repl for android project
yarn shadow-cljs cljs-repl android
yarn shadow-cljs cljs-repl android
2 changes: 1 addition & 1 deletion mobile/js_files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@react-native-community/masked-view": "^0.1.6",
"@react-native-community/netinfo": "^4.4.0",
"@react-navigation/bottom-tabs": "^5.1.1",
"@react-navigation/native": "^5.0.9",
"@react-navigation/native": "^5.2.3",
"@react-navigation/stack": "^5.1.1",
"bignumber.js": "git+https://github.com/status-im/bignumber.js.git#v4.0.2-status",
"buffer": "^5.4.2",
Expand Down
28 changes: 14 additions & 14 deletions mobile/js_files/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1327,29 +1327,29 @@
color "^3.1.2"
react-native-iphone-x-helper "^1.2.1"

"@react-navigation/core@^5.3.4":
version "5.3.4"
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-5.3.4.tgz#272eb48381c4db251f4dc5cd044db1606a551551"
integrity sha512-ul8J7oHC1/k/qWORr7uI710nKofbcD2clYI0bK0Bix+xgAoiFPgrwRDrQcjWw4YQViYlR8CGF/DhnKK+BFA+Yw==
"@react-navigation/core@^5.4.0":
version "5.4.0"
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-5.4.0.tgz#6b4973d48396d28ed3efee582b28807682a5865d"
integrity sha512-tDmfw7nzbJg186cXHUPl/VYEGSepzBXNiHRv4GTxLQ+S9cnZgPyrGv56kiSvHhxCzyNGN0nHscCY9IUv08KL6Q==
dependencies:
"@react-navigation/routers" "^5.4.0"
"@react-navigation/routers" "^5.4.2"
escape-string-regexp "^2.0.0"
nanoid "^3.0.2"
query-string "^6.12.0"
react-is "^16.13.0"
use-subscription "^1.4.0"

"@react-navigation/native@^5.0.9":
version "5.1.6"
resolved "https://registry.yarnpkg.com/@react-navigation/native/-/native-5.1.6.tgz#932ff1b5b8b9f051d8e5cd3b016d05badaa01898"
integrity sha512-DLLSnh29AndrGjPrHJoAgObeO9TiyrGtrASl+SA3B4ksmz4dUV2t6vaRwHogn1kejvRd+1T8VD923d3K1rjy7w==
"@react-navigation/native@^5.2.3":
version "5.2.3"
resolved "https://registry.yarnpkg.com/@react-navigation/native/-/native-5.2.3.tgz#2e2ec88396d2be96d11f9430b4af6dcea34029b0"
integrity sha512-fQfW506n9eTwBGiUbuxSvI7DTBXwR3IqAlooBCUHRJC0WiuSUm3aGg6eESJc8nW1A64hu33i/ITf10mn3Ec6Tg==
dependencies:
"@react-navigation/core" "^5.3.4"
"@react-navigation/core" "^5.4.0"

"@react-navigation/routers@^5.4.0":
version "5.4.0"
resolved "https://registry.yarnpkg.com/@react-navigation/routers/-/routers-5.4.0.tgz#2fce2a3880e84a110d4eaea317bb7dadee27d57c"
integrity sha512-Z5mQF/oQH9CRLilNm1H7h0wjY3dKomWOhuuDehW8UKuLiFp2mWJI1P5N9qwaSraxhcoiVfb9QXwKZru/wBzWMQ==
"@react-navigation/routers@^5.4.2":
version "5.4.2"
resolved "https://registry.yarnpkg.com/@react-navigation/routers/-/routers-5.4.2.tgz#10c1f32b0ddde935d1fc9123fb1683472bf31815"
integrity sha512-YjGv4H0LXD2YnDjSBAJzIKzlZehFRqWfR2IJtZor/mfLkOi6qDl8yJeqZKbLEeQsu6o6493QdxM81tqX293kyQ==
dependencies:
nanoid "^3.0.2"

Expand Down
1 change: 0 additions & 1 deletion src/quo/components/header.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[quo.components.text :as text]
[quo.design-system.colors :as colors]
[quo.design-system.spacing :as spacing]
[quo.react :as react]
[quo.react-native :as rn]
[reagent.core :as reagent]
[status-im.ui.components.icons.vector-icons :as icons]))
Expand Down
1 change: 0 additions & 1 deletion src/quo/components/tooltip.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(:require [reagent.core :as reagent]
[oops.core :refer [oget]]
[quo.animated :as animated]
[quo.react :as react]
[quo.react-native :as rn]
[quo.design-system.colors :as colors]
[quo.design-system.spacing :as spacing]
Expand Down
3 changes: 1 addition & 2 deletions src/quo/design_system/typography.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(ns quo.design-system.typography
(:require [quo.platform :as platform]))
(ns quo.design-system.typography)

(def tiny {:font-size 10
:line-height 14})
Expand Down
5 changes: 2 additions & 3 deletions src/quo/gesture_handler.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
[reagent.core :as reagent]
["react-native-gesture-handler"
:refer (TapGestureHandler PanGestureHandler LongPressGestureHandler
PureNativeButton TouchableWithoutFeedback createNativeWrapper State)]))
PureNativeButton TouchableWithoutFeedback
createNativeWrapper State)]))

(def tap-gesture-handler
(reagent/adapt-react-class TapGestureHandler))
Expand All @@ -19,8 +20,6 @@

(def touchable-without-feedback-class TouchableWithoutFeedback)

(def createNativeWrapper createNativeWrapper)

(def touchable-without-feedback
(reagent/adapt-react-class touchable-without-feedback-class))

Expand Down
3 changes: 1 addition & 2 deletions src/quo/previews/main.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns quo.previews.main
(:require [oops.core :refer [ocall]]
[quo.previews.header :as header]
(:require [quo.previews.header :as header]
[quo.previews.text :as text]
[quo.previews.text-input :as text-input]
[quo.previews.tooltip :as tooltip]
Expand Down
26 changes: 12 additions & 14 deletions src/shadow/cljs/devtools/client/react_native.cljs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
(ns shadow.cljs.devtools.client.react-native
(:require
[clojure.string :as str]
[cljs.reader :as reader]
[goog.object :as gobj]
[goog.net.XhrIo :as xhr]
[shadow.cljs.devtools.client.env :as env]
[status-im.reloader :as reloader]))
(:require [cljs.reader :as reader]
[clojure.string :as str]
[goog.net.XhrIo :as xhr]
[shadow.cljs.devtools.client.env :as env]
[status-im.reloader :as reloader]))

(defonce repl-ns-ref (atom nil))

Expand Down Expand Up @@ -51,7 +49,7 @@
(callback [])
(xhr/send
(env/files-url)
(fn [res]
(fn [_]
(this-as ^goog req
(let [content
(-> req
Expand All @@ -64,10 +62,10 @@
:sources (into [] (map :resource-id) sources)})
#js {"content-type" "application/edn; charset=utf-8"})))

(defn noop [& args])
(defn noop [& _])

(defn handle-build-complete [{:keys [info reload-info] :as msg}]
(let [{:keys [sources compiled]}
(let [{:keys [sources]}
info

warnings
Expand Down Expand Up @@ -97,7 +95,7 @@
(assoc :id id)
(ws-msg))))

(defn repl-require [{:keys [id sources reload-namespaces js-requires] :as msg} done]
(defn repl-require [{:keys [id sources reload-namespaces]} done]
(let [sources-to-load
(->> sources
(remove (fn [{:keys [provides] :as src}]
Expand Down Expand Up @@ -188,7 +186,7 @@
(env/process-ws-msg (. e -data) handle-message)))

(set! (.-onopen socket)
(fn [e]
(fn [_]
;; :module-format :js already patches provide
(when (= "goog" env/module-format)
;; patch away the already declared exception
Expand All @@ -199,7 +197,7 @@
(devtools-msg "WebSocket connected!")))

(set! (.-onclose socket)
(fn [e]
(fn [_]
;; not a big fan of reconnecting automatically since a disconnect
;; may signal a change of config, safer to just reload the page
(devtools-msg "WebSocket disconnected!")
Expand All @@ -216,7 +214,7 @@
;; pretty much only for me while working on this file
(when-let [s @socket-ref]
(devtools-msg "connection reset!")
(set! (.-onclose s) (fn [e]))
(set! (.-onclose s) (fn [_]))
(.close s)
(vreset! socket-ref nil))

Expand Down
6 changes: 3 additions & 3 deletions src/status_im/bootnodes/core.cljs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
(ns status-im.bootnodes.core
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.i18n :as i18n]

[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.navigation :as navigation]
[status-im.utils.fx :as fx]))

Expand Down Expand Up @@ -46,7 +45,8 @@
(set-input :name (str name)))]
(assoc fxs :dispatch [:navigate-to :edit-bootnode])))

(defn custom-bootnodes-in-use? [{:keys [db] :as cofx}]
(defn custom-bootnodes-in-use?
[{:keys [db]}]
(let [network (:networks/current-network db)]
(get-in db [:multiaccount :custom-bootnodes-enabled? network])))

Expand Down
5 changes: 2 additions & 3 deletions src/status_im/browser/permissions.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
(:require [status-im.constants :as constants]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.i18n :as i18n]
[status-im.qr-scanner.core :as qr-scanner]
[status-im.navigation :as navigation]
[status-im.utils.fx :as fx]
[status-im.browser.webview-ref :as webview-ref]))
[status-im.qr-scanner.core :as qr-scanner]
[status-im.utils.fx :as fx]))

(declare process-next-permission)
(declare send-response-to-bridge)
Expand Down
5 changes: 3 additions & 2 deletions src/status_im/chat/db.cljs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
(ns status-im.chat.db
(:require [clojure.set :as clojure.set]
[status-im.multiaccounts.core :as multiaccounts]
[clojure.string :as clojure.string]
[status-im.contact.db :as contact.db]
[status-im.group-chats.db :as group-chats.db]
[status-im.mailserver.constants :as mailserver.constants]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.utils.gfycat.core :as gfycat]))

(defn group-chat-name
[{:keys [public? name]}]
(str (when public? "#") name))

(defn enrich-active-chat
[contacts {:keys [chat-id public? group-chat name] :as chat} current-public-key]
[contacts {:keys [chat-id group-chat] :as chat} current-public-key]
(if group-chat
(let [pending-invite-inviter-name
(group-chats.db/get-pending-invite-inviter-name contacts
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/chat/db_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
message-3
message-2
message-1]
[m1 d1 m2 m3 m4 d2 :as ms] (db/add-datemarks ordered-messages)]
[m1 d1 m2 m3 m4 d2] (db/add-datemarks ordered-messages)]
(is (= "Jan 1, 2000"
(:datemark m1)))
(is (= {:type :datemark
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/chat/models.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,10 @@
(i18n/label :cooldown/warning-message)
#())))

(defn set-dock-badge-label [label]
(defn set-dock-badge-label
"Sets dock badge label (OSX only for now).
Label must be a string. Pass nil or empty string to clear the label."
[label]
(.setDockBadgeLabel ^js react/desktop-notification label))

(re-frame/reg-fx
Expand Down
6 changes: 3 additions & 3 deletions src/status_im/chat/models/input.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
[re-frame.core :as re-frame]
[status-im.chat.constants :as chat.constants]
[status-im.chat.models :as chat]
[status-im.chat.models.message-content :as message-content]
[status-im.chat.models.message :as chat.message]
[status-im.chat.models.message-content :as message-content]
[status-im.constants :as constants]
[status-im.utils.datetime :as datetime]
[status-im.utils.fx :as fx]
Expand Down Expand Up @@ -140,13 +140,13 @@
(fn [^js ref]
(try
(.focus ref)
(catch :default e
(catch :default _
(log/debug "Cannot focus the reference")))))

(re-frame/reg-fx
::clear-rn-component
(fn [ref]
(try
(.clear ref)
(catch :default e
(catch :default _
(log/debug "Cannot clear the reference")))))
5 changes: 2 additions & 3 deletions src/status_im/chat/models/input_test.cljs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
(ns status-im.chat.models.input-test
(:require [cljs.test :refer-macros [deftest is testing]]
[status-im.chat.constants :as constants]
[status-im.utils.config :as config]
[status-im.utils.datetime :as datetime]
[status-im.chat.models.input :as input]))
[status-im.chat.models.input :as input]
[status-im.utils.datetime :as datetime]))

(deftest text->emoji
(is (nil? (input/text->emoji nil)))
Expand Down
25 changes: 10 additions & 15 deletions src/status_im/chat/models/message.cljs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
(ns status-im.chat.models.message
(:require [re-frame.core :as re-frame]
[status-im.multiaccounts.model :as multiaccounts.model]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.chat.db :as chat.db]
[status-im.waku.core :as waku]
[status-im.chat.models :as chat-model]
[status-im.chat.models.loading :as chat-loading]
[status-im.chat.models.message-list :as message-list]
[status-im.chat.models.message-content :as message-content]
[status-im.chat.models.message-list :as message-list]
[status-im.constants :as constants]
[status-im.contact.db :as contact.db]
[status-im.data-store.messages :as data-store.messages]
[status-im.ui.screens.chat.state :as view.state]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.multiaccounts.model :as multiaccounts.model]
[status-im.transport.message.protocol :as protocol]
[status-im.utils.datetime :as time]
[status-im.ui.screens.chat.state :as view.state]
[status-im.utils.fx :as fx]
[status-im.waku.core :as waku]
[taoensso.timbre :as log]))

(defn- prepare-message
[{:keys [content content-type] :as message} chat-id current-chat?]
[{:keys [content content-type] :as message} current-chat?]
(cond-> message
current-chat?
(assoc :seen true)
Expand Down Expand Up @@ -56,7 +53,7 @@
(let [current-public-key (multiaccounts.model/current-public-key cofx)
message-to-be-removed (when replace
(get-in db [:chats chat-id :messages replace]))
prepared-message (prepare-message message chat-id seen-by-user?)]
prepared-message (prepare-message message seen-by-user?)]
(fx/merge cofx
(when message-to-be-removed
(hide-message chat-id message-to-be-removed))
Expand Down Expand Up @@ -100,13 +97,14 @@
(get-in db [:chats chat-id :messages message-id]))

(defn- earlier-than-deleted-at?
[{:keys [db]} {:keys [chat-id clock-value message-id from]}]
[{:keys [db]} {:keys [chat-id clock-value]}]
(let [{:keys [deleted-at-clock-value]}
(get-in db [:chats chat-id])]
(>= deleted-at-clock-value clock-value)))

(defn extract-chat-id [cofx {:keys [chat-id from message-type]}]
(defn extract-chat-id
"Validate and return a valid chat-id"
[cofx {:keys [chat-id from message-type]}]
(cond
(and (= constants/message-type-private-group message-type)
(and (get-in cofx [:db :chats chat-id :contacts from])
Expand Down Expand Up @@ -200,9 +198,6 @@
(chat-model/join-time-messages-checked-for-chats (keys grouped-messages)))))))

;;;; Send message

(def ^:private transport-keys [:content :content-type :message-type :clock-value :timestamp :name])

(fx/defn update-message-status
[{:keys [db] :as cofx} chat-id message-id status]
(fx/merge cofx
Expand Down
Loading

0 comments on commit 1bf6809

Please sign in to comment.