Fork me on GitHub
#clj-kondo
<
2022-02-04
>
mknoszlig11:02:53

re https://github.com/clj-kondo/clj-kondo/issues/1560 i’m still wondering about that switch to control the warning on private tasks. given

{:tasks
 {-a {:doc "private"}
  b {:doc "public"
     :depends [-a]}}}
bb tasks gives
> bb tasks
The following tasks are available:

b public
personally, my main reason for having clj-kondo remind me to provide doc strings is so task info will be available on the shell… :doc being used by babashka for private tasks in any way?

borkdude11:02:26

not really no

borkdude11:02:28

maybe default to no warning on private tasks then (and leave it at that for the first iteration)

👍 1
borkdude12:02:51

@maximilian I think a nice addition could be to actually get linting in the task code.

mknoszlig12:02:15

oh, that’s a nice one

borkdude12:02:24

The way this can be done is to wrap the task code as a function with :depends as the arguments

borkdude12:02:52

so {:task (+ a b c) :depends [a b c]} becomes (fn [a b c] (+ a b c)) and then lint that function

borkdude12:02:27

but this will cause unused function argument warnings... could also expand as (declare a b c) (+ a b c)

mknoszlig12:02:39

will probably have to account for :requires as well

borkdude12:02:48

that's closer to how it works in the tasks impl anyways. yes

borkdude12:02:34

we can talk in #clj-kondo-dev about this as to not disturb anyone else with details about this

porksausages17:02:41

can kondo be configured to not lint library code? e.g:

borkdude18:02:52

What editor is this? I need more context than a screenshot.

borkdude18:02:24

clj-kondo only lints what you provide to it, so it depends on whatever tool calls clj-kondo

porksausages18:02:59

it's vscode + calva, and its really strange because it doesn't happen when first loading up a project

porksausages18:02:21

it only happens after being open for 1-2 hours

porksausages18:02:07

and then after restarting, it's fine for another hour or two

borkdude18:02:32

Are you copying .jar files into your project somehow?

porksausages18:02:09

no it's just a project generated with lein new app [name] , zero changes to the structure of the project - not even a new file

borkdude18:02:57

I'm not sure why this happens. Have you also tried in #calva or #lsp?

ericdallo18:02:43

I think this happens indeed, when you open a external dependency the editor loads the content and add the file as a LSP workspace fie, to most navigation and other features work

ericdallo18:02:02

one of the drawbacks are the lint error

ericdallo18:02:22

I already faced this with multiple lsps, not only clojure, not sure how we could fix it

ericdallo18:02:55

maybe don't return diagnostics when the file is external, but the issue is how we know a file is external, need some POC

porksausages19:02:47

yeah i asked in #calva and pez recommended asking here, so i'm not really sure where the problem lies. i'm definitely not adding any external dependencies, i don't even know how to do that yet, but i'm not sure if leiningen or calva are adding a dependency or something.

borkdude19:02:21

Are you opening core.clj from clojure itself?

ericdallo19:02:41

external dependencies == opening a file not from your project like clojure.core, clojure.string etc

porksausages19:02:58

i'm not opening core.clj at all as far as i know?

borkdude19:02:26

I'm out of clues, sorry, clj-kondo is a pretty simple tool: it lints what you tell it to.

ericdallo19:02:49

yeah, for sure it's not a kondo issue

ericdallo19:02:09

but not sure it's a calva o lsp one, it's kind of expected this behavior

porksausages19:02:19

i don't know clojure at all i'm in the process of trying to learn so i probably can't help as much as i'd like to but here's exactly what i've done: 1. i generated a new project with lein new app clojure-noob 2. i opened the directory it created in vscode 3. i opened a repl 4. the error shows up an hour or two later

porksausages19:02:58

it makes sense if it's not a kondo issue but i don't see how this could possibly be expected behaviour?

porksausages19:02:09

unless i'm misunderstanding what that means lol

porksausages19:02:17

but thank you for your help either way

ericdallo19:02:29

for sure it's not expected if you didn't open a file, but I think you did at some point

porksausages19:02:57

hang on i'm being dumb here, i've only just realised that core.clj is the "main" file so yeah i am opening it

porksausages19:02:03

thats the file i'm working in

porksausages19:02:23

but these errors and warnings are not corresponding to anything inside the actual file

ericdallo19:02:39

are you sure? core.clj from your project and core.clj from clojure.core are different file. from your print it seems you opened clojure.core, maybe finding a definition of some function or something

porksausages19:02:51

this is the only file i've ever opened since starting to learn clojure in this project:

porksausages19:02:11

however you make a good point, maybe this is happening when i hover my mouse over a function and it shows the doc?

ericdallo19:02:32

it should not, we only lint when we open the file or itś a project file when starting lsp

porksausages19:02:31

weird. well, until i figure out exactly what action is making this happen this is probably just wasting your time so i'll just keep an eye on it for now until i figure it out

porksausages19:02:58

thank you for your help

ericdallo19:02:30

no problem, feel free to start with a issue on Calva, the entrypoint, where we can debug and find the root cause

pinkfrog03:02:03

I was just about to ask the same question in this channel.

pinkfrog03:02:41

Because of go to definitions and stuff like that, I often open the clojure.core file, and this brings a lot of clj kondo issues:

pinkfrog03:02:16

Possible to exclude the .m2/ files from linting?

👍 1
agold22:02:42

I'm having the same problem, but it only started a few days ago, possibly after latest Calva update. The errors are coming from clojure.core, which shouldn't be linted, as I haven't opened. They can be triggered by random changes in my code: deletion of a line, beginning a new form, etc. I have been using Calva for quite a while and first encountered this only a few days ago.

ericdallo23:02:41

this probably started to happen after we fixed on clojure-lsp the find definition of a jar, I think we can not return lint for jar dependencies, I'll do the proper changes on clojure-lsp side

🙏 1
ericdallo00:02:06

@U2CR1J4UV @UGC0NEP4Y @UH1SWK753 I just made a https://github.com/clojure-lsp/clojure-lsp/commit/4ef029d85d05bb4be435cdeb38fa538d33eadbecstopping linting external files which solve this issue, it should be available on next clojure-lsp release, if you wanna test it locally, you can clone the repo and run make to generate a local clojure-lsp

👍 3