Fork me on GitHub
#clj-kondo
<
2019-12-03
>
p-himik10:12:22

The highlighting seems a bit different with the LSP server. Notice how the locals are highlighted along with the adjacent bracket. But the underlining is correct. Is it something that could be fixed on clj-kondo's side, or is it an issue with LSP?

borkdude10:12:56

This is probably the plugin. clj-kondo is unaware of the editor it's used in

borkdude10:12:44

I'm not too familiar with the plugin itself. I don't even know how to build it: https://github.com/gtache/intellij-lsp/issues/122

borkdude10:12:28

But I think it's possible to build a standalone IntelliJ plugin from it. So if there will be someone stepping up and tweaking the necessary stuff, it can be a better experience maybe. And there can be a clj-kondo IntelliJ extension in the Jetbrains marketplace

Ian Fernandez14:12:40

hello, I'm running into linter error, but I don't understand why,

can't parse name_of_file.clj, no conversion to symbol

Ian Fernandez14:12:08

someone here can give me a hint?

borkdude14:12:40

@d.ian.b can you give more context?

borkdude14:12:52

can you make a repro?

Ian Fernandez14:12:10

I'm running:

clj-kondo --lint src --config '{:output {:format :json}}' 
into a repository

Ian Fernandez14:12:51

the linter is accusing this can't parse for every file on the repository

Ian Fernandez14:12:44

and joker does not give me any error

borkdude14:12:12

@d.ian.b can you make a repro that I can run locally? using the information you gave me I still can't reproduce it

borkdude14:12:58

what version of clj-kondo are you running? what OS?

Ian Fernandez14:12:49

clj-kondo version: 2019.11.23-1

Ian Fernandez14:12:01

OS, both in ubuntu and manjaro

Ian Fernandez14:12:28

I'll see here this

borkdude14:12:41

I don't know where the -1 comes from in the version. I didn't release that: https://github.com/borkdude/clj-kondo/releases

dharrigan14:12:02

It's from the packager, arch in particular

dharrigan14:12:16

i.e., the pkgrel

👍 4
dharrigan14:12:29

it's only for the OS, has no relation to what you have released 🙂 which is 2019.11.23

borkdude14:12:23

@d.ian.b Try to narrow down the issue by linting only one file from the directory.

borkdude14:12:38

And run with CLJ_KONDO_DEV=true that might give you some more info

dharrigan14:12:02

It's useful if the package meta around the release has changed, i.e., maybe a new depends or arch or url, but the underlying version of the package is the same, i.e., if you where to change the URL to ' then I would change the pkgrel to 2, but keep the pkgver to 2019.11.23, so then what would be installed would be 2019.11.23-2

borkdude14:12:10

@d.ian.b and if possible, try to isolate the case to the smallest piece of code that still triggers the error for you and post it here.

borkdude14:12:38

@d.ian.b Do you get the same error when you try to lint an empty file, e.g. put an empty file src/foo.clj in your project

borkdude14:12:48

and then run clj-kondo --lint src/foo.clj

Ian Fernandez14:12:15

I couldn't reproduce the error =<

borkdude15:12:35

so the error is gone now?

Ian Fernandez15:12:14

foo does not in the error

Ian Fernandez15:12:24

but other namespaces are in error

Ian Fernandez15:12:29

every one another

borkdude15:12:49

can you paste code from such a file into foo.clj and then see if that produces the error?

borkdude15:12:19

and if so, remove some code, lint again, until you see no error, and paste the smallest bit of code that still produced the error

Ian Fernandez17:12:54

it happens when I add (ns folder.foo)

Ian Fernandez17:12:15

src/folder/foo.clj:0:0: error: can't parse src/folder/foo.clj, no conversion to symbol

Ian Fernandez17:12:03

I have deps.edn src/folder/foo.clj

borkdude17:12:24

seems to work just fine here:

$ clj-kondo --lint - <<< '(ns folder.foo) (inc)'
<stdin>:1:17: error: clojure.core/inc is called with 0 args but expects 1
linting took 10ms, errors: 1, warnings: 0

Ian Fernandez17:12:02

clj-kondo --lint - <<< '(ns folder.foo) (inc)' <stdin>:0:0: error: can't parse <stdin>, no conversion to symbol linting took 4ms, errors: 1, warnings: 0

borkdude17:12:14

can you try with:

CLJ_KONDO_DEV=true clj-kondo --lint src/folder/foo.clj

borkdude17:12:29

can you also type:

clj-kondo --version

Ian Fernandez17:12:13

CLJ_KONDO_DEV=true clj-kondo --lint src/folder/foo.clj src/folder/foo.clj:0:0: error: can't parse src/folder/foo.clj, no conversion to symbol linting took 4ms, errors: 1, warnings: 0

Ian Fernandez17:12:22

clj-kondo v2019.11.23

borkdude17:12:28

Can you try the same command but from a new directory in /tmp, like mkdir -p /tmp/foo && cd /tmp/foo && CLJ_KONDO_DEV=true clj-kondo --lint - <<< '(ns folder.foo) (inc)'

Ian Fernandez17:12:58

mkdir -p /tmp/foo && cd /tmp/foo && clj-kondo --lint - <<< '(ns folder.foo) (inc)' <stdin>:1:17: error: clojure.core/inc is called with 0 args but expects 1 linting took 8ms, errors: 1, warnings: 0

Ian Fernandez17:12:11

do you know why?

borkdude17:12:22

Can you move aside the configuration you have in .clj-kondo/config.edn to .clj-kondo/config.bak

borkdude17:12:33

if you have any

borkdude17:12:09

and then try linting your project again

Ian Fernandez17:12:21

the problem was my config.edn

borkdude17:12:39

ah. I'll make an issue to better report the errors in the config

Ian Fernandez17:12:42

{:lint-as {folder.test.integrant/with-system when-let}}

Ian Fernandez17:12:58

this was the config

borkdude17:12:16

the second symbol has to be fully qualified as well

clj 4
Ian Fernandez15:12:58

OK, I'll try =)

andrea.crotti16:12:51

I wonder if something like (def x (function-call ...)) should be linted

andrea.crotti16:12:25

the amount oif hours wasted because of weird behaviours of things that should have been a defn but were a def is incredible

andrea.crotti16:12:00

and they are usually bugs that only happen after a while in specific conditions, so if it's not actually a "simple" constant, should you really use def?

borkdude17:12:37

@andrea.crotti I do that quite often

borkdude17:12:09

at least, I think I do. I'll keep it in mind

andrea.crotti17:12:36

well in many cases it's safe to do so

borkdude17:12:46

(def init-in (fn []
               #?(:clj (-> (.StringReader. "")
                           clojure.lang.LineNumberingPushbackReader.))))

(def init-out (fn [] (new #?(:clj .StringWriter
                             :cljs goog.string/StringBuffer))))

(def init-err (fn [] #?(:clj (.StringWriter.))))

(def in (vars/dynamic-var '*in* (init-in)))

(def out (vars/dynamic-var '*out* (init-out)))

(def err (vars/dynamic-var '*err* (init-err)))

andrea.crotti17:12:48

but when it's not you can end up with some really weird bugs

andrea.crotti17:12:34

I was taking more about things like (def truncate-db (jdbc/execute conn "TRUNCATE TABLE x"))

andrea.crotti17:12:50

which in this case it's clearly a problem of course, but it's not always so clear

borkdude17:12:12

yeah, it's quite impossible to know when it's not intended I think

andrea.crotti17:12:43

yeah it's tricky

Ian Fernandez17:12:26

@borkdude could you do some linting for hodur files?

Ian Fernandez17:12:36

it's another request 😃

borkdude18:12:00

what is hodur?

dominicm18:12:28

there was a talk on it at Clojutre

borkdude18:12:50

I need examples of what's currently not linted correctly about this library in a Github issue. Input + current errors + expected solutions.

Ian Fernandez20:12:37

ok, I'll do it later! 😃