Fork me on GitHub
#clj-kondo
<
2022-10-14
>
pavlosmelissinos02:10:44

This

(let [size 1
        seed 500]
    (gen/generate ::c/some-spec size seed))
gives me an error on emacs with flycheck: clojure.test.check.generators/generate is called with 3 args but expects 1 or 2 The 3-args call is correct (the code evaluates and the docs https://clojure.github.io/test.check/clojure.test.check.generators.html#var-generate) so could someone tell me what's going on here? 🙂

borkdude14:10:52

Can you try linting the dependency that you have on your classpath with clj-kondo? Could be a built-in vs what you have difference

pavlosmelissinos14:10:41

Damn, I should have thought of that 😞. Yes I'll try that and let you know if it's a clj-kondo issue

pavlosmelissinos18:10:27

Doesn't seem to be an emacs issue.

pavlos$ clojure -M:clj-kondo --fail-level error --lint src/lala.clj | grep error
...
src/lala.clj:5:1: error: clojure.test.check.generators/generate is called with 3 args but expects 1 or 2
linting took 81ms, errors: 1, warnings: 0
src/lala.clj contains:
(ns lala
  (:require [clojure.spec.alpha :as s]
            [clojure.test.check.generators :as gen]))

(gen/generate (s/gen int?) 1 500)
pavlos$ clojure -M:clj-kondo --version                                             
clj-kondo v2022.10.05
Should I open an issue on Github?

pavlosmelissinos18:10:21

The clj-kondo alias in deps.edn looks like this:

:clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "RELEASE"}}
                         :main-opts ["-m" "clj-kondo.main" ]}

borkdude18:10:42

Did you lint your dependencies?

facepalm 1
borkdude18:10:49

@UEQPKG7HQ

clojure -M:clj-kondo --lint $(clojure -Spath) --dependencies

borkdude18:10:55

after that, try again

pavlosmelissinos19:10:10

You're right, it works now... The instructions are very prominent in the clj-kondo docs as well, not sure how I missed it. However, I don't really understand why clj-kondo recognized the 1- and 2-arity signatures but needed a cache refresh for the 3-arity. I would understand it if the 3-arity was a recent addition but it was actually https://github.com/clojure/test.check/blame/b6a318af92e836f1f20960f38a5944168b88d60d/src/main/clojure/clojure/test/check/generators.cljc#L198.

borkdude19:10:48

Maybe you first linted with an old dependency from 6 years ago? I can't reproduce the issue locally :)

$ clj-kondo --lint - <<< '(ns lala
  (:require [clojure.spec.alpha :as s]
            [clojure.test.check.generators :as gen]))

(gen/generate (s/gen int?) 1 500)'
linting took 28ms, errors: 0, warnings: 0

pavlosmelissinos19:10:14

Ah, yes. That's very likely, the project in question had some dependencies that were quite old and we upgraded them recently. Would it be possible for clj-kondo to check if the cache is outdated when it runs and warn the user if so?

borkdude19:10:01

how are you using clj-kondo, from your editor or command line?

pavlosmelissinos19:10:02

Usually from emacs (during development) but every now and then I'll do a full sweep of the entire project as a maintenance task

borkdude19:10:27

and which editor?

borkdude19:10:38

and using which "plugin"?

pavlosmelissinos19:10:54

emacs + flycheck (is that what you mean?)

borkdude19:10:22

and you're not using lsp right?

borkdude19:10:41

ok. clj-kondo doesn't do anything to keep in sync with your dependencies automatically, but you can run:

clj-kondo --lint $(clojure -Spath) --dependencies --parallel
which is pretty fast since it will skip already linted jar files

borkdude19:10:05

so any time you change your project / deps file, you can re-run this. clojure-lsp does this automatically for you

pavlosmelissinos19:10:37

I see, that's good to know! I'll see if I can set up emacs to mimic that fire-and-forget behaviour, thanks for all the info 🙂

👍 1
borkdude14:10:24

We already have that as the :consistent-alias linter

sheluchin14:10:35

I did see that one, but it requires user configuration. My thought was that including a default list with the aliases listed in the Clojure Style Guide would be helpful to make code bases more consistent. Not sure if putting a default list on :consistent-aliases or adding a whole new linter for it would be better.

borkdude14:10:29

We could add an option to :consistent-aliases that populates the idiomatic list from the community guide

borkdude14:10:34

:community-guide true

borkdude14:10:39

Having to use the spec alias for clojure.spec.alpha already puts me off though :P

1
sheluchin14:10:59

That is a nice idea. I wonder if such a flag can be useful in other linters as well. > Having to use the spec alias for clojure.spec.alpha already puts me off though 😛 That straight up seems like a bug in the community guide :face_with_raised_eyebrow: How is that idiomatic when every bit of official documentation uses s? I guess this is a good argument to making the entries in the :community-guide option override-able with explicit configuration.

borkdude14:10:41

I had to laugh a bit because of the story "someone suggests linter for community guide aliases" and then the conversation goes "how is that entry in the guide idiomatic!"

😂 1
sheluchin14:10:40

This turns clj-kondo configs into a voting mechanism.

borkdude14:10:06

I guess you could also do the community guide aliases as a clj-kondo library which is merged automatically when imported

sheluchin14:10:50

I'll file an issue for the :community-guide/idiomatic aliases flag so it's on the radar. Seems like it could use some more thought.

sheluchin14:10:10

> I guess you could also do the community guide aliases as a clj-kondo library which is merged automatically when imported I'm not sure what you mean by that..?

borkdude14:10:27

Same mechanism as hooks

sheluchin14:10:03

Do you mean to create a new lib that would just export the community guide alias configuration for clj-kondo so that anyone that wants to use the list can do so by installing the lib?

borkdude14:10:57

by adding the lib to your :deps

sheluchin14:10:00

Interesting approach. I guess that would require no new work for clj-kondo but would require maintaining a separate library and users would need to understand the path and install the dep.

sheluchin14:10:53

Okay, @U04V15CAJ. Thanks for your consideration. I will log the ideas in the ticket.

borkdude14:10:58

but it would also not need a new release of clj-kondo to get these defaults

sheluchin14:10:51

In the least it'll require some clj-kondo documentation to explain it, I think.

skylize15:10:51

> That straight up seems like a bug in the community guide :face_with_raised_eyebrow: How is that idiomatic when every bit of official documentation uses s? Seems like an issue should also be opened with the style guide to get this fixed.

Noah Bogart17:10:10

I think having a “community-guide true” flag would be nice. Extra dependencies are hard, especially when running clj-kondo as a standalone bin instead of a project dependency.

Sam Ritchie16:10:38

this is a bit strange; I just pushed to a sicmutils branch for the first time in a while, and the linter is failing on many of my cljc files with

Warning: Unknown require option: :include-macros
Here is the output: https://github.com/sicmutils/sicmutils/actions/runs/3251402996/jobs/5336339401

Sam Ritchie16:10:53

Looks like this is with

Downloading  to /tmp

Sam Ritchie16:10:31

Locally, I get no errors with

[sritchie@wintermute ~/code/clj/sicmutils (sritchie/tidying)]$ clj-kondo --version
clj-kondo v2022.03.04

lread16:10:43

Heya @U017QJZ9M7W this is a little bug that slipped into last release.

Sam Ritchie16:10:02

got it, no worries, glad to hear it’s something that’s on your radar!

borkdude16:10:16

It's already been fixed on master

borkdude16:10:30

I guess I could do a new release for just that :-s

borkdude16:10:52

Since this is the only reported unknown require option in a week, I think I'll do a new release this weekend and leave the linter on

👍 1
borkdude16:10:07

With an :exclude option which still has to be made

borkdude19:10:39

@U017QJZ9M7W I just published a new version of clj-kondo to clojars, could you test with that?

Sam Ritchie19:10:24

sure, will do shortly

borkdude19:10:14

Clj-kondo: static analyzer and linter for clojure Small intermittent release 2022.10.14 • https://github.com/clj-kondo/clj-kondo/issues/1831: Add :redundant-fn-wrapper support for keyword and binding calls (https://github.com/NoahTheDuke) • https://github.com/clj-kondo/clj-kondo/issues/1830: Fix warning on :include-macros in .cljs and .cljc for :unknown-require-option linter. (https://github.com/NoahTheDuke) • https://github.com/clj-kondo/clj-kondo/issues/1238: Build a linux/aarch64 executable in CI (https://github.com/cap10morgan) • Add :exclude option to :unknown-require-option • Enable :unused-value by default • Publish .sha256 files along with released artifacts

🎉 2
clj-kondo 1