Skip to content

Commit 6b669c3

Browse files
authored
Bump Methodical & Kondo (#198)
* Bump Methodical & Kondo * Improved Kondo for define-after-select * Improved hook for define-after-insert * Improved hook for define-after-update * Rework more macros into hooks * Hook for define-named-query * Improved hook for define-default-fields * Remove redundant ignores
1 parent b412026 commit 6b669c3

File tree

31 files changed

+282
-140
lines changed

31 files changed

+282
-140
lines changed

.clj-kondo/methodical/methodical/config.edn

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{:config-paths ["macros"]
22

3-
:lint-as
4-
{}
3+
:config-in-call
4+
{methodical.core/defmethod
5+
{:linters
6+
{:redundant-fn-wrapper {:level :off}}}}
57

68
:hooks
79
{:analyze-call

.clj-kondo/methodical/methodical/hooks/methodical/macros.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
'next-method
122122
'__FN__NAME__THAT__YOU__CANNOT__REFER__TO__))
123123
fn-tail))
124-
(vary-meta update :clj-kondo/ignore conj :redundant-fn-wrapper))]))]
124+
(with-meta (meta node)))]))]
125125
#_(println "=>")
126126
#_(clojure.pprint/pprint (hooks/sexpr result))
127127
{:node result})))

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
deploy:
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-latest
1111
environment: Deployment
1212
steps:
1313
- uses: actions/checkout@v4.1.7

.github/workflows/tests.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
kondo:
11-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-latest
1212
timeout-minutes: 10
1313
steps:
1414
- uses: actions/checkout@v4.1.7
@@ -29,7 +29,7 @@ jobs:
2929
clojure -M:kondo:kondo/all
3030
3131
tests-postgres:
32-
runs-on: ubuntu-20.04
32+
runs-on: ubuntu-latest
3333
timeout-minutes: 10
3434
steps:
3535
- uses: actions/checkout@v4.1.7
@@ -49,7 +49,7 @@ jobs:
4949
CI: TRUE
5050

5151
tests-mariadb:
52-
runs-on: ubuntu-20.04
52+
runs-on: ubuntu-latest
5353
timeout-minutes: 10
5454
services:
5555
mariadb:
@@ -72,7 +72,7 @@ jobs:
7272
CI: TRUE
7373

7474
tests-h2:
75-
runs-on: ubuntu-20.04
75+
runs-on: ubuntu-latest
7676
timeout-minutes: 10
7777
steps:
7878
- uses: actions/checkout@v4.1.7
@@ -86,7 +86,7 @@ jobs:
8686
CI: TRUE
8787

8888
whitespace-linter:
89-
runs-on: ubuntu-20.04
89+
runs-on: ubuntu-latest
9090
steps:
9191
- uses: actions/checkout@v4.1.7
9292
- name: Setup Java & Clojure
@@ -97,7 +97,7 @@ jobs:
9797
name: Run whitespace linter
9898

9999
check:
100-
runs-on: ubuntu-20.04
100+
runs-on: ubuntu-latest
101101
steps:
102102
- uses: actions/checkout@v4.1.7
103103
- name: Setup Java & Clojure
@@ -111,7 +111,7 @@ jobs:
111111
working-directory: toucan1
112112

113113
codecov:
114-
runs-on: ubuntu-20.04
114+
runs-on: ubuntu-latest
115115
steps:
116116
- uses: actions/checkout@v4.1.7
117117
- name: Setup Java & Clojure
@@ -128,7 +128,7 @@ jobs:
128128
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
129129

130130
codespell:
131-
runs-on: ubuntu-20.04
131+
runs-on: ubuntu-latest
132132
steps:
133133
- uses: actions/checkout@v4.1.7
134134
- uses: codespell-project/actions-codespell@v2

deps.edn

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
com.github.seancorfield/honeysql {:mvn/version "2.6.1147"}
88
com.github.seancorfield/next.jdbc {:mvn/version "1.3.939"}
99
environ/environ {:mvn/version "1.2.0"}
10-
methodical/methodical {:mvn/version "1.0.123"}
10+
methodical/methodical {:mvn/version "1.0.125"}
1111
mvxcvi/puget {:mvn/version "1.3.4"}
1212
org.clojure/tools.logging {:mvn/version "1.3.0"}
1313
org.clojure/tools.trace {:mvn/version "0.8.0"}
@@ -17,7 +17,8 @@
1717
:aliases
1818
{:dev
1919
{:extra-deps
20-
{com.h2database/h2 {:mvn/version "2.3.232"}
20+
{clj-kondo/clj-kondo {:mvn/version "2025.01.16"}
21+
com.h2database/h2 {:mvn/version "2.3.232"}
2122
eftest/eftest {:mvn/version "0.6.0"}
2223
io.github.camsaul/humane-are {:mvn/version "1.0.2"}
2324
org.clojure/java.classpath {:mvn/version "1.1.0"}
@@ -67,7 +68,7 @@
6768
;;
6869
;; clojure -M:kondo --copy-configs --dependencies --lint "$(clojure -A:dev -Spath)" --skip-lint --parallel
6970
:kondo
70-
{:replace-deps {clj-kondo/clj-kondo {:mvn/version "2024.08.29"}}
71+
{:replace-deps {clj-kondo/clj-kondo {:mvn/version "2025.01.16"}}
7172
:main-opts ["-m" "clj-kondo.main"]}
7273

7374
;; lint everything with Kondo

resources/clj-kondo.exports/com.github.camsaul/toucan2/config.edn

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@
1212
{:analyze-call
1313
{toucan2.connection/with-connection hooks.toucan2.connection/with-connection
1414
toucan2.connection/with-transaction hooks.toucan2.connection/with-transaction
15+
toucan2.core/define-after-insert hooks.toucan2.tools.after-insert/define-after-insert
16+
toucan2.core/define-after-select hooks.toucan2.tools.after-select/define-after-select
17+
toucan2.core/define-after-update hooks.toucan2.tools.after-update/define-after-update
18+
toucan2.core/define-before-delete hooks.toucan2.tools.before-delete/define-before-delete
19+
toucan2.core/define-before-insert hooks.toucan2.tools.before-insert/define-before-insert
20+
toucan2.core/define-before-select hooks.toucan2.tools.before-select/define-before-select
21+
toucan2.core/define-before-update hooks.toucan2.tools.before-update/define-before-update
1522
toucan2.core/with-connection hooks.toucan2.connection/with-connection
1623
toucan2.core/with-transaction hooks.toucan2.connection/with-transaction
24+
toucan2.tools.after-insert/define-after-insert hooks.toucan2.tools.after-insert/define-after-insert
25+
toucan2.tools.after-select/define-after-select hooks.toucan2.tools.after-select/define-after-select
26+
toucan2.tools.after-update/define-after-update hooks.toucan2.tools.after-update/define-after-update
27+
toucan2.tools.before-delete/define-before-delete hooks.toucan2.tools.before-delete/define-before-delete
28+
toucan2.tools.before-insert/define-before-insert hooks.toucan2.tools.before-insert/define-before-insert
29+
toucan2.tools.before-select/define-before-select hooks.toucan2.tools.before-select/define-before-select
30+
toucan2.tools.before-update/define-before-update hooks.toucan2.tools.before-update/define-before-update
31+
toucan2.tools.default-fields/define-default-fields hooks.toucan2.tools.default-fields/define-default-fields
32+
toucan2.tools.named-query/define-named-query hooks.toucan2.tools.named-query/define-named-query
1733
toucan2.tools.simple-out-transform/define-out-transform hooks.toucan2.tools.simple-out-transform/define-out-transform
1834
toucan2.tools.with-temp/with-temp hooks.toucan2.tools.with-temp/with-temp}
1935

2036
:macroexpand
2137
{toucan.db/with-call-counting macros.toucan2.execute/with-call-count
2238
toucan.models/defmodel macros.toucan.models/defmodel
23-
toucan2.core/define-after-insert macros.toucan2.tools.after-insert/define-after-insert
24-
toucan2.core/define-after-select macros.toucan2.tools.helpers/define-after-select
25-
toucan2.core/define-after-update macros.toucan2.tools.after-update/define-after-update
26-
toucan2.core/define-before-delete macros.toucan2.tools.helpers/define-before-delete
27-
toucan2.core/define-before-insert macros.toucan2.tools.before-insert/define-before-insert
28-
toucan2.core/define-before-select macros.toucan2.tools.helpers/define-before-select
29-
toucan2.core/define-before-update macros.toucan2.tools.before-update/define-before-update
30-
toucan2.execute/with-call-count macros.toucan2.execute/with-call-count
31-
toucan2.tools.after-insert/define-after-insert macros.toucan2.tools.after-insert/define-after-insert
32-
toucan2.tools.after-select/define-after-select macros.toucan2.tools.helpers/define-after-select
33-
toucan2.tools.after-update/define-after-update macros.toucan2.tools.after-update/define-after-update
34-
toucan2.tools.before-delete/define-before-delete macros.toucan2.tools.helpers/define-before-delete
35-
toucan2.tools.before-insert/define-before-insert macros.toucan2.tools.before-insert/define-before-insert
36-
toucan2.tools.before-select/define-before-select macros.toucan2.tools.helpers/define-before-select
37-
toucan2.tools.before-update/define-before-update macros.toucan2.tools.before-update/define-before-update
38-
toucan2.tools.default-fields/define-default-fields macros.toucan2.tools.default-fields/define-default-fields
39-
toucan2.tools.named-query/define-named-query macros.toucan2.tools.named-query/define-named-query}}}
39+
toucan2.execute/with-call-count macros.toucan2.execute/with-call-count}}}
Binary file not shown.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
(ns hooks.toucan2.tools.after-insert
2+
(:require
3+
[clj-kondo.hooks-api :as hooks]
4+
[hooks.toucan2.common]))
5+
6+
(defn define-after-insert [context]
7+
(letfn [(update-node [node]
8+
(let [[_ dispatch-value binding-node & body] (:children node)]
9+
(-> (hooks/list-node
10+
[(hooks/token-node `do)
11+
dispatch-value
12+
(hooks/list-node
13+
(list*
14+
(hooks/token-node `fn)
15+
(hooks/vector-node
16+
[(hooks/token-node '&model)
17+
(first (:children binding-node))])
18+
(-> body
19+
(hooks.toucan2.common/splice-into-body (hooks/token-node '&model)))))])
20+
(with-meta (meta node)))))]
21+
(update context :node update-node)))
22+
23+
(comment
24+
(as-> '(after-insert/define-after-insert ::venues.after-insert.composed
25+
[venue]
26+
{:pre [(map? venue)], :post [(map? %)]}
27+
(assoc venue :composed? true)) <>
28+
(pr-str <>)
29+
(hooks/parse-string <>)
30+
(define-after-insert {:node <>})
31+
(:node <>)
32+
(hooks/sexpr <>)))
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
(ns hooks.toucan2.tools.after-select
2+
(:require
3+
[clj-kondo.hooks-api :as hooks]
4+
[hooks.toucan2.common]))
5+
6+
(defn define-after-select [context]
7+
(letfn [(update-node [node]
8+
(let [[_ dispatch-value binding-node & body] (:children node)]
9+
(-> (hooks/list-node
10+
[(hooks/token-node `do)
11+
dispatch-value
12+
(hooks/list-node
13+
(list*
14+
(hooks/token-node `fn)
15+
(hooks/vector-node
16+
[(hooks/token-node '&query-type)
17+
(hooks/token-node '&model)
18+
(hooks/token-node '&parsed-args)
19+
(first (:children binding-node))])
20+
;; make these appear used.
21+
(-> body
22+
(hooks.toucan2.common/splice-into-body (hooks/token-node '&query-type)
23+
(hooks/token-node '&model)
24+
(hooks/token-node '&parsed-args)))))])
25+
(with-meta (meta node)))))]
26+
(update context :node update-node)))
27+
28+
(comment
29+
(as-> '(t2/define-after-select ::people
30+
[person]
31+
(assoc person :cool-name (str "Cool " (:name person)))) <>
32+
(pr-str <>)
33+
(hooks/parse-string <>)
34+
(define-after-select {:node <>})
35+
(:node <>)
36+
(hooks/sexpr <>)))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(ns hooks.toucan2.tools.after-update
2+
(:require
3+
[clj-kondo.hooks-api :as hooks]
4+
[hooks.toucan2.common]))
5+
6+
(defn define-after-update [context]
7+
(letfn [(update-node [node]
8+
(let [[_ dispatch-value binding-node & body] (:children node)]
9+
(-> (hooks/list-node
10+
[(hooks/token-node `do)
11+
dispatch-value
12+
(hooks/list-node
13+
(list*
14+
(hooks/token-node `fn)
15+
(hooks/vector-node
16+
[(hooks/token-node '&model)
17+
(first (:children binding-node))])
18+
;; make these appear used.
19+
(-> body
20+
(hooks.toucan2.common/splice-into-body (hooks/token-node '&model)))))])
21+
(with-meta (meta node)))))]
22+
(update context :node update-node)))

0 commit comments

Comments
 (0)