Fork me on GitHub
#clj-kondo
<
2020-03-10
>
sogaiu00:03:11

(i line-break my urls using backslashes -- breaks links but keeps my code sane) πŸ˜›

ikitommi07:03:21

is there a way to find out unused public vars?

dharrigan11:03:49

Carve is pretty darn good πŸ™‚

borkdude12:03:12

Maybe the #kaocha channel?

dominicm12:03:20

Too many Ks, sorry :)

serioga18:03:11

clj-kondo warns here:

src\app\lib\vk\java_sdk\core.clj:10:47: warning: Unused import GetResponse
src\app\lib\vk\java_sdk\core.clj:12:35: warning: Unused import DomainResolved
but imports are used in type hints. @borkdude is it a bug or I missed something?

borkdude18:03:34

seems like a false positive when using type hints in ->. welcome to post a repro with a minimal example in an issue

didibus20:03:21

@serioga I do always forget the right place to type hints, but if I remember correctly, you have your return type hints in the wrong place

didibus20:03:29

(defn ^:private ^ServiceActor conn-service-actor
  "Service actor from connection."
  [{:keys [::app-id
           ::app-service-token]}]
  (ServiceActor. app-id app-service-token))

didibus20:03:52

You want ^ServiceActor hint to be on the arg vector, not the var

didibus20:03:17

Like so:

(defn ^:private conn-service-actor
  "Service actor from connection."
  ^ServiceActor [{:keys [::app-id
           ::app-service-token]}]
  (ServiceActor. app-id app-service-token))

serioga20:03:59

Maybe But I've put type hints to get rid of warning from Cursive and reflection warning πŸ™‚

didibus20:03:59

Ya, but those probably do nothing

didibus20:03:11

So whatever got rid of your warnings it's not that

serioga20:03:03

I'll have a look with macroexpand

didibus20:03:58

> For function return values, the type hint can be placed before the arguments vector

didibus20:03:44

I actually think clj-kondo should warn against that 😝

didibus20:03:40

When you type hint where you did, you're type hinting the Var, but the Var holds a Fn, so its correct type is Fn, not ServiceActor

serioga20:03:55

In the code above the problem is with result from .execute which has different types

serioga20:03:02

@didibus are we talking about this code fragment?

(try
    (-> vk-api-client
        (.friends)
        (.get (conn-service-actor conn))
        (.userId (Integer/parseInt user-id))
        ^GetResponse (.execute)
        (.getItems)
        (->> (mapv str)))
    (catch ApiAccessException _
      (private-profile-friends))
    (catch ApiPrivateProfileException _
      (private-profile-friends)))

didibus20:03:35

I'm talking about:

(defn ^:private ^ServiceActor conn-service-actor
  "Service actor from connection."
  [{:keys [::app-id
           ::app-service-token]}]
  (ServiceActor. app-id app-service-token))

serioga20:03:49

the warnings are about type hints in -> (2 places)

didibus20:03:04

I just mean, in your function signature, I think the correct place to type hint the return value is the args vector

serioga20:03:26

β€œI think the correct place to type hint the return value is the args vector” Agree I also think those hints are useless But I did not know this when wrote that code πŸ™‚

serioga20:03:16

Maybe yet another case for clj-kondo to check and warn :-)

borkdude21:03:17

Shall we focus on the first issue first (type hints in threading macros do prevent from unused import warnings). I haven't seen a Github issue for that yet πŸ˜‰

borkdude21:03:03

@serioga I think this is a minimal repro for your issue:

$ clj-kondo --lint - <<< '(ns foo (:import [foo Bar])) (defn foo [x] x) (defn bar [x] (-> x ^Bar (foo)))'
<stdin>:1:23: warning: Unused import Bar
linting took 11ms, errors: 0, warnings: 1

borkdude21:03:38

@tanzoniteblack Thanks, duplicate of #787

tanzoniteblack21:03:11

I saw that one and wasn't clear they were duplicates of each other or not

tanzoniteblack21:03:19

seemed like the same error, but probably due to different reasons

borkdude21:03:36

@tanzoniteblack I might have closed it prematurely. I'll take another look.

borkdude21:03:47

re-opened it. I'll have a look at it before the next release

borkdude22:03:12

@serioga @tanzoniteblack issues are solved on master now