Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeldelboni authored Apr 6, 2024
0 parents commit 3c00981
Show file tree
Hide file tree
Showing 47 changed files with 1,574 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .clj-kondo/com.github.seancorfield/next.jdbc/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{:hooks
{:analyze-call
{next.jdbc/with-transaction
hooks.com.github.seancorfield.next-jdbc/with-transaction
next.jdbc/with-transaction+options
hooks.com.github.seancorfield.next-jdbc/with-transaction+options}}
:lint-as {next.jdbc/on-connection clojure.core/with-open
next.jdbc/on-connection+options clojure.core/with-open}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(ns hooks.com.github.seancorfield.next-jdbc
(:require [clj-kondo.hooks-api :as api]))

(defn with-transaction
"Expands (with-transaction [tx expr opts] body)
to (let [tx expr] opts body) pre clj-kondo examples."
[{:keys [:node]}]
(let [[binding-vec & body] (rest (:children node))
[sym val opts] (:children binding-vec)]
(when-not (and sym val)
(throw (ex-info "No sym and val provided" {})))
(let [new-node (api/list-node
(list*
(api/token-node 'let)
(api/vector-node [sym val])
opts
body))]
{:node new-node})))
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(ns hooks.com.github.seancorfield.next-jdbc
(:require [clj-kondo.hooks-api :as api]))

(defn with-transaction
"Expands (with-transaction [tx expr opts] body)
to (let [tx expr] opts body) per clj-kondo examples."
[{:keys [:node]}]
(let [[binding-vec & body] (rest (:children node))
[sym val opts] (:children binding-vec)]
(when-not (and sym val)
(throw (ex-info "No sym and val provided" {})))
(let [new-node (api/list-node
(list*
(api/token-node 'let)
(api/vector-node [sym val])
opts
body))]
{:node new-node})))

(defn with-transaction+options
"Expands (with-transaction+options [tx expr opts] body)
to (let [tx expr] opts body) per clj-kondo examples."
[{:keys [:node]}]
(let [[binding-vec & body] (rest (:children node))
[sym val opts] (:children binding-vec)]
(when-not (and sym val)
(throw (ex-info "No sym and val provided" {})))
(let [new-node (api/list-node
(list*
(api/token-node 'let)
(api/vector-node [sym val])
opts
body))]
{:node new-node})))
12 changes: 12 additions & 0 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{:config-paths ["com.github.seancorfield/next.jdbc"
"nubank/state-flow"
"marick/midje"
"metosin/malli-types"]
:hooks {:analyze-call {integration.microservice-boilerplate.aux/init-flow nubank.state-flow/defflow
state-flow.api/defflow nubank.state-flow/defflow}}
:linters {:unsorted-required-namespaces {:level :warning}
:unresolved-var {:exclude [honeysql.helpers/select
honeysql.helpers/from]}}
:lint-as {honeysql.helpers/defhelper clj-kondo.lint-as/def-catch-all
clojure.test.check.properties/for-all clojure.core/let
clojure.test.check.clojure-test/defspec clojure.test/deftest}}
9 changes: 9 additions & 0 deletions .clj-kondo/funcool/cats/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{:lint-as {cats.core/mlet clojure.core/let
cats.core/alet clojure.core/let
cats.core/ap-> clojure.core/->
cats.core/ap->> clojure.core/->>
cats.core/as-ap-> clojure.core/as->
cats.core/->= clojure.core/->
cats.core/->>= clojure.core/->>
cats.core/as->= clojure.core/as->
cats.core/for clojure.core/for}}
80 changes: 80 additions & 0 deletions .clj-kondo/marick/midje/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{:hooks {:analyze-call {midje.sweet/tabular marick.midje/tabular}}
:lint-as {midje.checking.checkers.defining/defchecker clojure.core/defn}
:linters {:unresolved-symbol {:exclude [(midje.sweet/fact
[throws
contains
as-checker
exactly
has
has-sufix
has-prefix
just
one-of
two-of
roughly
truthy
falsey
irrelevant
anything
=>
=not=>
=deny=>
=expands-to=>
=future=>
=contains=>
=streams=>
=throws=>
=test=>
=throw-parse-exception=>])
(midje.sweet/facts
[throws
contains
exactly
has
has-sufix
has-prefix
just
one-of
two-of
roughly
as-checker
truthy
falsey
irrelevant
anything
=>
=not=>
=deny=>
=expands-to=>
=future=>
=contains=>
=streams=>
=throws=>
=test=>
=throw-parse-exception=>])
(midje.sweet/tabular
[throws
contains
exactly
has
has-sufix
has-prefix
just
one-of
two-of
roughly
as-checker
truthy
falsey
irrelevant
anything
=>
=not=>
=deny=>
=expands-to=>
=future=>
=contains=>
=streams=>
=throws=>
=test=>
=throw-parse-exception=>])]}}}
68 changes: 68 additions & 0 deletions .clj-kondo/marick/midje/marick/midje.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
(ns marick.midje
(:require [clj-kondo.hooks-api :as hooks]
[clojure.string :as string]))

(def arrows '#{=>
=not=>
=deny=>
=expands-to=>
=future=>
=contains=>
=streams=>
=throws=>
=test=>
=throw-parse-exception=>})

(defn ^:private let-form [body bindings]
(let [new-bindings (vec (reduce (fn [acc i]
(concat acc [i (hooks/token-node 'identity)]))
[] bindings))]
(hooks/list-node
[(hooks/token-node 'let)
(hooks/vector-node new-bindings)
body])))

(defn ^:private do-form [forms]
(hooks/list-node
(concat [(hooks/token-node 'do)]
forms)))

(defn ^:private table-variable? [node]
(let [sexpr (hooks/sexpr node)]
(and (symbol? sexpr)
(string/starts-with? (str sexpr) "?"))))

(defn ^:private tabular-node [first-bindings bindings body]
(if (hooks/vector-node? first-bindings)
{:node (->> (hooks/sexpr first-bindings)
(map hooks/token-node)
(let-form body))}
{:node (->> bindings
(filter table-variable?)
(let-form body))}))

(defn ^:private handle-fact-outside-tabular [children arrow]
(let [body (do-form children)
bindings (->> children
(drop-while #(not (= arrow %)))
rest
(drop 1))]
(tabular-node (first bindings) bindings body)))

(defn fact-tabular [fact vec-bindings bindings]
(let [body (do-form (cons fact bindings))]
(tabular-node vec-bindings (cons vec-bindings bindings) body)))

(defn ^:private handle-fact-inside-tabular [children]
(if (hooks/string-node? (first children))
(let [[_name fact vec-bindings & bindings] children]
(fact-tabular fact vec-bindings bindings))
(let [[fact vec-bindings & bindings] children]
(fact-tabular fact vec-bindings bindings))))

(defn tabular [{:keys [node]}]
(let [children (rest (:children node))
fact-outside (first (filter #(contains? arrows (hooks/sexpr %)) children))]
(if fact-outside
(handle-fact-outside-tabular children fact-outside)
(handle-fact-inside-tabular children))))
1 change: 1 addition & 0 deletions .clj-kondo/metosin/malli-types-clj/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading

0 comments on commit 3c00981

Please sign in to comment.