Fork me on GitHub
#clj-kondo
<
2024-07-25
>
andrea.crotti08:07:41

:discouraged-namespace {clj-time.core {:message "Use java.time instead"
                                                  :level :error}}
If I had that config it should be an error right? I still get
tokens_test.clj:5:14: warning: Use java.time instead

andrea.crotti08:07:15

(deftest level-test
  (assert-submaps2
   [{:file "<stdin>",
     :row 1,
     :col 24,
     :level :error,
     :message "Discouraged var: foo/bar"}]
   (lint! "(ns foo) (defn bar []) (bar)"
          '{:linters {:discouraged-var {foo/bar {:level :error}}}})))

andrea.crotti08:07:31

I can see a test in the code, so it should work in theory

borkdude09:07:48

what version of clj-kondo

andrea.crotti09:07:10

which I think was the latest

borkdude09:07:00

can you make a repro repository so I can test this?

borkdude09:07:08

(in theory, it should work)

andrea.crotti09:07:59

ah yeah I can repropduce it also there

borkdude09:07:08

thanks! 🚀

borkdude09:07:12

let me check

borkdude09:07:36

ah you're referencing the discouraged-<var> test, not the discouraged-namespace, so this might still have to be implemented for that linter

borkdude09:07:39

issue welcome

andrea.crotti09:07:12

ahh ok makes sense,I was using both actually but maybe only the namespace has the problem yeah

andrea.crotti09:07:27

(deftest discouraged-namespace-test
  (assert-submaps2
   '({:file "<stdin>" :row 1 :col 12 :level :error :message "Discouraged namespace: closed.source"})
   (lint! "(require '[closed.source :as s]) (s/baz)"
          '{:linters {:discouraged-namespace {closed.source {}
                                              :level :error}}}))

andrea.crotti09:07:36

there is a test also for namespace as far as I can see

borkdude09:07:54

I'll check what's going on there...

borkdude10:07:45

ah the difference in that test is that the level is set on the level of the whole linter, not just for one var

borkdude10:07:47

This would be the desired behavior that isn't implemented yet:

(assert-submaps2
   '({:file "<stdin>" :row 1 :col 12 :level :error :message "Discouraged namespace: closed.source"})
   (lint! "(require '[closed.source :as s]) (s/baz)"
          '{:linters {:discouraged-namespace {closed.source {:level :error}}}}))

andrea.crotti10:07:00

Ahh ok cool I can try to fix maybe

borkdude10:07:38

I'm already fixing it, as I was looking into it. You can still help by posting an issue

borkdude10:07:10

The fix is pushed to the branch discouraged-var-level

borkdude10:07:26

I'll merge after getting an issue for this, gotta step away now for a bit

andrea.crotti14:07:13

another question about --copy-config, I would just to not check in git all the files that are copied over with --copy-config, and then I realised that I don't even know how these files are ending up in my machine. I guess it's maybe Emacs doing it, but well I just deleted all the copied configs and I can't get them back. I also tried

% clj-kondo --lint src test --dependencies --copy-configs --skip-lint
clj-kondo --lint src test --dependencies --copy-configs --skip-lint
No configs copied.
and it copies nothing. Am I doing something wrong? I'd like to just change the CI script to download the configs before running, which means that we don't need them checked in anymore, or how else are people doing that?

borkdude16:07:33

you need to lint your dependencies, not just src test

andrea.crotti20:07:30

mm how do I do that?

andrea.crotti20:07:43

I just thought it would pick up the dependencies from project.clj or deps.edn?

andrea.crotti20:07:32

it's interesting how that always worked without me really ever understanding how

borkdude20:07:02

clj-kondo --lint "$(clojure -Spath)" --dependencies

borkdude20:07:22

it won't pick up deps from project.clj or deps.edn, never did

andrea.crotti20:07:20

ahh right, I still don't know what magic tools got them downloaded to my machine then

borkdude21:07:19

clojure-lsp probably

andrea.crotti07:07:33

ah yeah actually only after clojure-lsp diagnostics I'm seeing all the files