Skip to content

Commit 3c00981

Browse files
Initial commit
0 parents  commit 3c00981

File tree

47 files changed

+1574
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1574
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{:hooks
2+
{:analyze-call
3+
{next.jdbc/with-transaction
4+
hooks.com.github.seancorfield.next-jdbc/with-transaction
5+
next.jdbc/with-transaction+options
6+
hooks.com.github.seancorfield.next-jdbc/with-transaction+options}}
7+
:lint-as {next.jdbc/on-connection clojure.core/with-open
8+
next.jdbc/on-connection+options clojure.core/with-open}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
(ns hooks.com.github.seancorfield.next-jdbc
2+
(:require [clj-kondo.hooks-api :as api]))
3+
4+
(defn with-transaction
5+
"Expands (with-transaction [tx expr opts] body)
6+
to (let [tx expr] opts body) pre clj-kondo examples."
7+
[{:keys [:node]}]
8+
(let [[binding-vec & body] (rest (:children node))
9+
[sym val opts] (:children binding-vec)]
10+
(when-not (and sym val)
11+
(throw (ex-info "No sym and val provided" {})))
12+
(let [new-node (api/list-node
13+
(list*
14+
(api/token-node 'let)
15+
(api/vector-node [sym val])
16+
opts
17+
body))]
18+
{:node new-node})))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(ns hooks.com.github.seancorfield.next-jdbc
2+
(:require [clj-kondo.hooks-api :as api]))
3+
4+
(defn with-transaction
5+
"Expands (with-transaction [tx expr opts] body)
6+
to (let [tx expr] opts body) per clj-kondo examples."
7+
[{:keys [:node]}]
8+
(let [[binding-vec & body] (rest (:children node))
9+
[sym val opts] (:children binding-vec)]
10+
(when-not (and sym val)
11+
(throw (ex-info "No sym and val provided" {})))
12+
(let [new-node (api/list-node
13+
(list*
14+
(api/token-node 'let)
15+
(api/vector-node [sym val])
16+
opts
17+
body))]
18+
{:node new-node})))
19+
20+
(defn with-transaction+options
21+
"Expands (with-transaction+options [tx expr opts] body)
22+
to (let [tx expr] opts body) per clj-kondo examples."
23+
[{:keys [:node]}]
24+
(let [[binding-vec & body] (rest (:children node))
25+
[sym val opts] (:children binding-vec)]
26+
(when-not (and sym val)
27+
(throw (ex-info "No sym and val provided" {})))
28+
(let [new-node (api/list-node
29+
(list*
30+
(api/token-node 'let)
31+
(api/vector-node [sym val])
32+
opts
33+
body))]
34+
{:node new-node})))

.clj-kondo/config.edn

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{:config-paths ["com.github.seancorfield/next.jdbc"
2+
"nubank/state-flow"
3+
"marick/midje"
4+
"metosin/malli-types"]
5+
:hooks {:analyze-call {integration.microservice-boilerplate.aux/init-flow nubank.state-flow/defflow
6+
state-flow.api/defflow nubank.state-flow/defflow}}
7+
:linters {:unsorted-required-namespaces {:level :warning}
8+
:unresolved-var {:exclude [honeysql.helpers/select
9+
honeysql.helpers/from]}}
10+
:lint-as {honeysql.helpers/defhelper clj-kondo.lint-as/def-catch-all
11+
clojure.test.check.properties/for-all clojure.core/let
12+
clojure.test.check.clojure-test/defspec clojure.test/deftest}}

.clj-kondo/funcool/cats/config.edn

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{:lint-as {cats.core/mlet clojure.core/let
2+
cats.core/alet clojure.core/let
3+
cats.core/ap-> clojure.core/->
4+
cats.core/ap->> clojure.core/->>
5+
cats.core/as-ap-> clojure.core/as->
6+
cats.core/->= clojure.core/->
7+
cats.core/->>= clojure.core/->>
8+
cats.core/as->= clojure.core/as->
9+
cats.core/for clojure.core/for}}

.clj-kondo/marick/midje/config.edn

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{:hooks {:analyze-call {midje.sweet/tabular marick.midje/tabular}}
2+
:lint-as {midje.checking.checkers.defining/defchecker clojure.core/defn}
3+
:linters {:unresolved-symbol {:exclude [(midje.sweet/fact
4+
[throws
5+
contains
6+
as-checker
7+
exactly
8+
has
9+
has-sufix
10+
has-prefix
11+
just
12+
one-of
13+
two-of
14+
roughly
15+
truthy
16+
falsey
17+
irrelevant
18+
anything
19+
=>
20+
=not=>
21+
=deny=>
22+
=expands-to=>
23+
=future=>
24+
=contains=>
25+
=streams=>
26+
=throws=>
27+
=test=>
28+
=throw-parse-exception=>])
29+
(midje.sweet/facts
30+
[throws
31+
contains
32+
exactly
33+
has
34+
has-sufix
35+
has-prefix
36+
just
37+
one-of
38+
two-of
39+
roughly
40+
as-checker
41+
truthy
42+
falsey
43+
irrelevant
44+
anything
45+
=>
46+
=not=>
47+
=deny=>
48+
=expands-to=>
49+
=future=>
50+
=contains=>
51+
=streams=>
52+
=throws=>
53+
=test=>
54+
=throw-parse-exception=>])
55+
(midje.sweet/tabular
56+
[throws
57+
contains
58+
exactly
59+
has
60+
has-sufix
61+
has-prefix
62+
just
63+
one-of
64+
two-of
65+
roughly
66+
as-checker
67+
truthy
68+
falsey
69+
irrelevant
70+
anything
71+
=>
72+
=not=>
73+
=deny=>
74+
=expands-to=>
75+
=future=>
76+
=contains=>
77+
=streams=>
78+
=throws=>
79+
=test=>
80+
=throw-parse-exception=>])]}}}
+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
(ns marick.midje
2+
(:require [clj-kondo.hooks-api :as hooks]
3+
[clojure.string :as string]))
4+
5+
(def arrows '#{=>
6+
=not=>
7+
=deny=>
8+
=expands-to=>
9+
=future=>
10+
=contains=>
11+
=streams=>
12+
=throws=>
13+
=test=>
14+
=throw-parse-exception=>})
15+
16+
(defn ^:private let-form [body bindings]
17+
(let [new-bindings (vec (reduce (fn [acc i]
18+
(concat acc [i (hooks/token-node 'identity)]))
19+
[] bindings))]
20+
(hooks/list-node
21+
[(hooks/token-node 'let)
22+
(hooks/vector-node new-bindings)
23+
body])))
24+
25+
(defn ^:private do-form [forms]
26+
(hooks/list-node
27+
(concat [(hooks/token-node 'do)]
28+
forms)))
29+
30+
(defn ^:private table-variable? [node]
31+
(let [sexpr (hooks/sexpr node)]
32+
(and (symbol? sexpr)
33+
(string/starts-with? (str sexpr) "?"))))
34+
35+
(defn ^:private tabular-node [first-bindings bindings body]
36+
(if (hooks/vector-node? first-bindings)
37+
{:node (->> (hooks/sexpr first-bindings)
38+
(map hooks/token-node)
39+
(let-form body))}
40+
{:node (->> bindings
41+
(filter table-variable?)
42+
(let-form body))}))
43+
44+
(defn ^:private handle-fact-outside-tabular [children arrow]
45+
(let [body (do-form children)
46+
bindings (->> children
47+
(drop-while #(not (= arrow %)))
48+
rest
49+
(drop 1))]
50+
(tabular-node (first bindings) bindings body)))
51+
52+
(defn fact-tabular [fact vec-bindings bindings]
53+
(let [body (do-form (cons fact bindings))]
54+
(tabular-node vec-bindings (cons vec-bindings bindings) body)))
55+
56+
(defn ^:private handle-fact-inside-tabular [children]
57+
(if (hooks/string-node? (first children))
58+
(let [[_name fact vec-bindings & bindings] children]
59+
(fact-tabular fact vec-bindings bindings))
60+
(let [[fact vec-bindings & bindings] children]
61+
(fact-tabular fact vec-bindings bindings))))
62+
63+
(defn tabular [{:keys [node]}]
64+
(let [children (rest (:children node))
65+
fact-outside (first (filter #(contains? arrows (hooks/sexpr %)) children))]
66+
(if fact-outside
67+
(handle-fact-outside-tabular children fact-outside)
68+
(handle-fact-inside-tabular children))))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)