clj-kondo

https://github.com/clj-kondo/clj-kondo
ericdallo 2021-04-03T20:50:01.183200Z

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

ericdallo 2021-04-03T20:50:22.183300Z

borkdude 2021-04-03T20:52:46.183700Z

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

ericdallo 2021-04-03T20:53:37.183900Z

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

borkdude 2021-04-03T20:54:14.184200Z

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

ericdallo 2021-04-03T20:55:18.184400Z

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

borkdude 2021-04-03T20:55:42.184700Z

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

borkdude 2021-04-03T20:56:01.184900Z

and in this case Foo is a single segment class name

ericdallo 2021-04-03T20:56:38.185100Z

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

borkdude 2021-04-03T20:56:46.185300Z

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

borkdude 2021-04-03T20:56:51.185500Z

yes

ericdallo 2021-04-03T20:57:04.185700Z

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

borkdude 2021-04-03T20:57:22.185900Z

you can probably find a unit test that explicitly supports this

borkdude 2021-04-03T20:57:25.186100Z

and some issue number

ericdallo 2021-04-03T20:57:38.186300Z

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

borkdude 2021-04-03T20:58:50.187Z

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

ericdallo 2021-04-03T20:59:28.187300Z

hahahaha sorry

borkdude 2021-04-03T21:01:07.187500Z

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

๐Ÿ‘ 1
borkdude 2021-04-03T21:01:31.187900Z

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

borkdude 2021-04-03T21:02:07.188300Z

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

๐Ÿ‘ 1
ericdallo 2021-04-03T21:02:13.188500Z

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

borkdude 2021-04-03T21:02:51.188800Z

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

๐Ÿ‘ 1
ericdallo 2021-04-03T21:08:00.189400Z

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

ericdallo 2021-04-03T21:08:18.189500Z

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

ericdallo 2021-04-03T21:09:41.189800Z

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

borkdude 2021-04-03T21:09:49.190Z

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

borkdude 2021-04-03T21:10:03.190200Z

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

ericdallo 2021-04-03T21:10:29.190400Z

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

borkdude 2021-04-03T21:10:47.190600Z

clj-kondo doesn't analyze Java source code

borkdude 2021-04-03T21:11:05.190800Z

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

๐Ÿ‘ 1
ericdallo 2021-04-03T21:11:14.191Z

hum, it would be nice

borkdude 2021-04-03T21:12:11.191300Z

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

borkdude 2021-04-03T21:12:29.191500Z

but reflection might have been a better choice, easier

ericdallo 2021-04-03T21:12:40.191700Z

you mean clojure.java.javadoc?

borkdude 2021-04-03T21:13:34.191900Z

no, the javadoc command

๐Ÿ‘ 1