-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add clj-kondo exports and config, fix linting errors, some addt'l fix…
…es (#16) * Add clj-kondo exports and config, fix linting errors, some addt'l fixes * Add notes to CHANGELOG for next release * Add clj-kondo linter to github actions workflow
- Loading branch information
Showing
16 changed files
with
243 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{:config-paths ["../resources/clj-kondo.exports/cnuernber/ham-fisted"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ jobs: | |
uses: DeLaGuardo/[email protected] | ||
with: | ||
cli: 1.11.1.1413 | ||
- name: Run clojure linter | ||
run: scripts/lint | ||
- name: Run automated tests | ||
run: scripts/run-tests | ||
- name: Cache dependencies | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ pom.xml | |
*.asc | ||
issue-data | ||
jdk-* | ||
.clj-kondo | ||
.lsp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
resources/clj-kondo.exports/cnuernber/ham-fisted/config.edn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{:skip-comments true | ||
:lint-as {ham-fisted.defprotocol/defprotocol clojure.core/defprotocol | ||
ham-fisted.defprotocol/extend-protocol clojure.core/extend-protocol | ||
ham-fisted.defprotocol/extend-type clojure.core/extend-type} | ||
:hooks {:analyze-call {ham-fisted.hlet/let hooks.ham-fisted/analyze-hlet-macro | ||
ham-fisted.function/function hooks.ham-fisted/analyze-1-arg-fn-macro | ||
ham-fisted.function/long-predicate hooks.ham-fisted/analyze-1-arg-fn-macro | ||
ham-fisted.function/long-unary-operator hooks.ham-fisted/analyze-1-arg-fn-macro | ||
ham-fisted.function/double-predicate hooks.ham-fisted/analyze-1-arg-fn-macro | ||
ham-fisted.function/double-unary-operator hooks.ham-fisted/analyze-1-arg-fn-macro | ||
ham-fisted.function/obj->long hooks.ham-fisted/analyze-1-arg-fn-macro | ||
ham-fisted.function/long->double hooks.ham-fisted/analyze-1-arg-fn-macro | ||
ham-fisted.function/bi-function hooks.ham-fisted/analyze-2-arg-fn-macro | ||
ham-fisted.function/binary-predicate hooks.ham-fisted/analyze-2-arg-fn-macro | ||
ham-fisted.function/long-binary-operator hooks.ham-fisted/analyze-2-arg-fn-macro | ||
ham-fisted.function/double-binary-operator hooks.ham-fisted/analyze-2-arg-fn-macro | ||
ham-fisted.reduce/long-accumulator hooks.ham-fisted/analyze-2-arg-fn-macro | ||
ham-fisted.reduce/double-accumulator hooks.ham-fisted/analyze-2-arg-fn-macro | ||
ham-fisted.reduce/indexed-accum hooks.ham-fisted/analyze-indexed-reduce-fn-macro | ||
ham-fisted.alists/make-prim-array-list hooks.ham-fisted/analyze-make-prim-array-list-macro | ||
ham-fisted.lazy-noncaching/make-readonly-list hooks.ham-fisted/analyze-indexed-make-list-macro}}} |
149 changes: 149 additions & 0 deletions
149
resources/clj-kondo.exports/cnuernber/ham-fisted/hooks/ham_fisted.clj_kondo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
(ns hooks.ham-fisted | ||
(:require [clj-kondo.hooks-api :as api])) | ||
|
||
(defn node-value | ||
[node] | ||
(when node | ||
(api/sexpr node))) | ||
|
||
(defn analyze-hlet-macro | ||
[{:keys [:node]}] | ||
(let [[bindings & body] (rest (:children node)) | ||
new-node (api/list-node | ||
(list* | ||
(api/token-node 'clojure.core/let) | ||
(api/vector-node | ||
(concat | ||
[(api/token-node 'dbls) | ||
(api/token-node 'clojure.core/vec) | ||
(api/token-node 'lngs) | ||
(api/token-node 'clojure.core/vec) | ||
(api/token-node 'lng-fns) | ||
(api/token-node 'clojure.core/vec) | ||
(api/token-node 'dbl-fns) | ||
(api/token-node 'clojure.core/vec) | ||
(api/token-node 'obj-fns) | ||
(api/token-node 'clojure.core/vec)] | ||
(:children bindings))) | ||
body))] | ||
{:node new-node})) | ||
|
||
(defn analyze-1-arg-fn-macro | ||
[{:keys [:node]}] | ||
(let [[arg1 & body] (rest (:children node)) | ||
new-node (api/list-node | ||
(list* | ||
(api/token-node 'clojure.core/fn) | ||
(api/vector-node [arg1]) | ||
body))] | ||
{:node new-node})) | ||
|
||
(defn analyze-2-arg-fn-macro | ||
[{:keys [:node]}] | ||
(let [[arg1 arg2 & body] (rest (:children node)) | ||
new-node (api/list-node | ||
(list* | ||
(api/token-node 'clojure.core/fn) | ||
(api/vector-node [arg1 arg2]) | ||
body))] | ||
{:node new-node})) | ||
|
||
(defn analyze-indexed-reduce-fn-macro | ||
[{:keys [:node]}] | ||
(let [[acc-arg idx-arg obj-arg & body] (rest (:children node)) | ||
new-node (api/list-node | ||
(list* | ||
(api/token-node 'clojure.core/fn) | ||
(api/vector-node [acc-arg | ||
(api/vector-node [idx-arg obj-arg])]) | ||
body))] | ||
{:node new-node})) | ||
|
||
(defn analyze-indexed-make-list-macro | ||
[{:keys [:node]}] | ||
(let [children (rest (:children node)) | ||
_input-args (drop-last 3 children) | ||
[nel-arg idx-arg & body] (take-last 3 children) | ||
new-node (api/list-node | ||
(list | ||
(api/token-node 'clojure.core/map) | ||
(api/list-node | ||
(list* | ||
(api/token-node 'clojure.core/fn) | ||
(api/vector-node [idx-arg]) | ||
body)) | ||
(api/list-node | ||
(list | ||
(api/token-node 'clojure.core/range) | ||
(api/token-node nel-arg)))))] | ||
{:node new-node})) | ||
|
||
(defn analyze-make-prim-array-list-macro | ||
[{:keys [:node]}] | ||
(let [[lname ary-tag iface getname setname addname set-cast-fn get-cast-fn obj-cast-fn add-all-reduce] (rest (:children node)) | ||
new-node (api/list-node | ||
(list | ||
(api/token-node 'clojure.core/deftype) | ||
(vary-meta lname assoc :tag (node-value ary-tag)) | ||
(api/vector-node | ||
[(api/token-node 'data) | ||
(api/token-node 'n-elems) | ||
(api/token-node 'm)]) | ||
iface | ||
(api/list-node | ||
(list | ||
getname | ||
(api/vector-node | ||
[(api/token-node '_) | ||
(api/token-node 'idx)]) | ||
(api/list-node | ||
(list | ||
get-cast-fn | ||
(api/list-node | ||
(list | ||
(api/token-node 'clojure.core/aget) | ||
(api/token-node 'data) | ||
(api/token-node 'idx))))))) | ||
(api/list-node | ||
(list | ||
setname | ||
(api/vector-node | ||
[(api/token-node '_) | ||
(api/token-node 'idx) | ||
(api/token-node 'v)]) | ||
(api/list-node | ||
(list | ||
(api/token-node 'clojure.core/aset) | ||
(api/token-node 'data) | ||
(api/token-node 'idx) | ||
(api/list-node | ||
(list | ||
set-cast-fn | ||
(api/token-node 'v))))))) | ||
(api/list-node | ||
(list | ||
addname | ||
(api/vector-node | ||
[(api/token-node '_) | ||
(api/token-node 'v)]) | ||
(api/list-node | ||
(list | ||
(api/token-node 'clojure.core/aset) | ||
(api/token-node 'data) | ||
(api/token-node 'n-elems) | ||
(api/list-node | ||
(list | ||
obj-cast-fn | ||
(api/token-node 'v))))))) | ||
(api/list-node | ||
(list | ||
(api/token-node 'addAllReducible) | ||
(api/vector-node | ||
[(api/token-node 'this) | ||
(api/token-node 'coll)]) | ||
(api/list-node | ||
(list | ||
add-all-reduce | ||
(api/token-node 'this) | ||
(api/token-node 'coll)))))))] | ||
{:node new-node})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
scripts/compile | ||
clojure -M:dev:test:clj-kondo --copy-configs --dependencies --parallel --lint "$(clojure -A:dev:test -Spath)" | ||
clojure -M:dev:test:clj-kondo --lint "src:test" --fail-level "error" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...sted/defprotocol_test/hash_collisions.clj → ...defprotocol_test/hash_collisions_test.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.