Fork me on GitHub
#clj-kondo
<
2021-04-03
>
ericdallo20:04:01

Any reason why clj-kondo doesn't lint (Foo.) as unresolved-symbol but it does when Foo. without the parens? ๐Ÿงต

borkdude20:04:46

The second one might be a constructor call for a class that's available

ericdallo20:04:37

but the class is not imported, shouldn't lint as something like that?

borkdude20:04:14

you don't have to import a class to be able to use it

ericdallo20:04:18

I didn't know about it, besides java.lang is there other classes that one can configure to use without import?

borkdude20:04:42

you can use any class without importing it by using the classname

borkdude20:04:01

and in this case Foo is a single segment class name

ericdallo20:04:38

Oh yeah, it makes sense, you mean java.util.Date would be valid right?

borkdude20:04:46

The check for class names used to include a dot, but I lifted this since some people did have single segment classes

ericdallo20:04:04

I see, that's what I was about to suggest

borkdude20:04:22

you can probably find a unit test that explicitly supports this

borkdude20:04:25

and some issue number

ericdallo20:04:38

hahah no problem, I can see now why don 't restrict that

borkdude20:04:50

darn, now I'm curious myself what the issue number was ;)

ericdallo20:04:28

hahahaha sorry

borkdude21:04:07

I can find one here: https://github.com/clj-kondo/clj-kondo/issues/950 but that doesn't have this example

๐Ÿ‘ 3
borkdude21:04:31

that was just relaxing foo.bar.Baz to foo.Baz

borkdude21:04:07

there might be some rule in clj-kondo that says: if the call ends with a dot, just leave it alone, since it's a constructor and people know what they are doing with classes

๐Ÿ‘ 3
ericdallo21:04:13

yeah, I see, It would be really cool to find some way to lint that, but I can't think in anything that would always work/makes sense

borkdude21:04:51

if Foo was a record or deftype you would probably use ->Foo instead

๐Ÿ‘ 3
borkdude21:04:49

Maybe try adding a warning for a constructor call that only has a single segment and see if this breaks any tests

borkdude21:04:03

It could be that clj-kondo is just too relaxed for this case

ericdallo21:04:14

hum, it would be nice

ericdallo21:04:00

Would be hard to make clj-kondo support java classes arglists/docs in analysis output? ๐Ÿงต

ericdallo21:04:18

I think would be necessary to add support for java classes analysis that probably is no easy task

ericdallo21:04:41

I mean, I'd like to get a docs or signature of a java class via clojure-lsp

ericdallo21:04:29

ATM, java usages are just var-usages buckets, it'd be necessary to have a var-definition for those I think

borkdude21:04:47

clj-kondo doesn't analyze Java source code

borkdude21:04:05

but you could maybe retrieve those using reflection and put them somewhere

๐Ÿ‘ 3
borkdude21:04:11

currently clj-kondo uses some javadoc stuff to store all this info

borkdude21:04:29

but reflection might have been a better choice, easier

ericdallo21:04:40

you mean clojure.java.javadoc?

borkdude21:04:34

no, the javadoc command

๐Ÿ‘ 3