Sweet! Just while I was looking for it. I was about to try to write it out, but I'm still pretty new to clojure. So i was scratching my head a little on this one (the rum hook does look like a good place to start though)
Let me know if you need any help or have any questions
The docs for hooks are here: https://github.com/borkdude/clj-kondo/blob/master/doc/hooks.md
@borkdude Just spotted this in the analysis of deps.edn
:
#:worldsingles{worldsingles-test
#:local{:root "../worldsingles-test"}}
and clj-kondo
flags worldsingles-test
as being an unqualified lib name (which it isn't). I guess clj-kondo
isn't reading namespaced-maps correctly?crap. I just pushed the button for release ;)
And it actually recommends changing the above to this, which is definitely wrong:
{worldsingles-test {:local/root "../worldsingles-test"}}/{worldsingles-test {:local/root "../worldsingles-test"}}
@lee ^ interesting issue with namespaced maps in rewrite-clj wrt analysis..
yes, that's because it doesn't look at a namespaced map like it should.
issue welcome
I'll fix it in the next release, I just hit the release button
Interesting, thanks for the ping! I should have a look at how clj-kondo is using rewrite-clj here and make sure we are properly covered for rewrite-cljc.
It could in fact be a bug in my own fork of rewrite-clj now I think about it. I'll hold off on releasing clj-kondo for today and take a look.
In any case, I’m interested to learn more. I’ll be lurking! :simple_smile:
I'm calling sexpr on those nodes... and probably my version of sexpr for this thing doesn't work correctly... https://github.com/borkdude/clj-kondo/blob/master/src/clj_kondo/impl/linters/deps_edn.clj
hmm, it does appear to work:
user=> (n/sexpr (p/parse-string "#:foo{:a 1}"))
#:foo{:a 1}
Then maybe the bug is in the deps_edn.clj code itself.
yeah, namespaced element support is weak in rewrite-clj but my notes say that particular case is covered.
Hmm, this looks wrong:
user=> (n/sexpr (p/parse-string "#:worldsingles{worldsingles-test #:local{:root \"../worldsingles-test\"}}"))
{worldsingles-test #:local{:root "../worldsingles-test"}}
It appears to go wrong when the map has symbols:
user=> (n/sexpr (p/parse-string "#:foo{x 1}"))
{x 1}
I have never seen this case before. TIL.
But symbols shouldn’t be namespaced, only keywords, right?
user=> (keys (edn/read-string "#:foo{x 1}"))
(foo/x)
hmmm
otoh:
user=> (keys (edn/read-string "#:foo{\"x\" 1}"))
("x")
@lee does rewrite-cljc do this correctly?
So I’m looking at my handy reference https://clojure.atlassian.net/browse/CLJ-1910
> A keyword or symbol key without a namespace is read with the default namespace as its namespace.
hmm… I think I missed that “symbol key” detail…
so no, rewrite-cljc namespaced element support WIP does not handle this correctly yet!
In clj-kondo this is a small fix:
user=> (keys (n/sexpr (p/parse-string "#:foo{x 1}")))
(foo/x)
modified parser/clj_kondo/impl/rewrite_clj/node/seq.clj
@@ -56,9 +56,11 @@
m (first (node/sexprs children))
nspace (name nspace-k)]
(->> (for [[k v] m
- :let [k' (cond (not (keyword? k)) k
+ :let [k' (cond (not (ident? k)) k
(namespace k) k
- :else (keyword nspace (name k)))]]
+ :else (if (keyword? k)
+ (keyword nspace (name k))
+ (symbol nspace (name k))))]]
oh foo! :simple_smile: …but am happy to realize this fact!
CLJ-1910 does deliver the gritty details, it just needs to be absorbed.
@seancorfield Pushed a fix for https://github.com/borkdude/clj-kondo/issues/1093 to master. Re-scheduled the release for coming weekend.
Nice! Thank you, sir!